Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!agate!soda.berkeley.edu!dwallach From: dwallach@soda.berkeley.edu (Dan Wallach) Newsgroups: comp.sys.sgi Subject: Re: GL questions to the world (how to do cool fog) Message-ID: <1991May15.052043.15753@agate.berkeley.edu> Date: 15 May 91 05:20:43 GMT References: <1991May14.193934.6923@jarvis.csri.toronto.edu> Sender: root@agate.berkeley.edu (Charlie Root) Organization: UC Berkeley, Computer Science Undergraduate Association Lines: 46 In article <1991May14.193934.6923@jarvis.csri.toronto.edu> rodney@dgp.toronto.edu (Rodney Hoinkes) writes: > >Not having the source to Flight, I can only speculate how the fog is >done as I am trying to replicate the effect in some of my code. Well, I haven't seen flight source, but I can tell you how we did it for our final CS project (soon to be posted to the net, or made available via anonymous ftp as soon as we fix some more bugs...). We're drawing a fractal mountain landscape which you "drive" through. As a cheap way of deciding when to stop drawing distant polygons, we set an arbitrary distance as the end of the universe. For every vertex, we linearly interpolate between the vertex's color, and the background color, based on how far away the vertex is from the viewer. Voila! Instant fog (or murk, under water...). A second method we came up with uses the Iris lighting. Stick a light source on top of your head with some attenuation, and a constant ambient light. Polygons that are far away will just be the ambient (background...) color, while closer polygons will be lit nicely. A third method would use the Iris depthcue() call, but depthcue() didn't seem to get along nicely with the hardware lighting (any polygons which were clipped came out flat shaded). This may only be a PI weirdism. We haven't yet figured out a nice way to be half above water and half below water with correct fogging in both places. Doing it right would probably require something like BSP trees, and a lot of ugly hacking. Our Personal Irises don't have alpha buffers, or we'd probably come up with some stranger ways of doing things. Actually, the biggest headache was going from a view-up-vector and view-plane- normal to a nice out-the-window view. lookat() is difficult to get the twist right, and no amount of mucking with translate() and rotate() seemed to do the right thing, if you were looking straight down or up (y-axis). We ended up generating the matrix by hand and using multmatrix() with the system perspective matrix. Hope this helps, Dan Wallach dwallach@soda.berkeley.edu (thanks go to SGI for donating the 8 PI's which our graphics class lives on. Before that were Tek 4125 terminals...)