To Basil RE: 3D Fog
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Omni

I was messing with Winamp visualizations just now when I stumbled on an idea to create the 3D 'fog' effect in our engines. Feel free to use this method--it's pretty darn simple.

First of all, the best way to improve FPS speed is to limit the draw distance. But...when polygons disappear after appearing in the screen for just a few seconds while moving, it looks really fake.

So! The fog effect can help obscure the disappearing polygons in the distance. Right, obvious enough.

So, here's my idea:

1. Set yourself a 3D_FogActive flag to control if fog is enabled/disabled
2. Have a 3D_FogColor icon, where FogColor is an RGB integer.

On rendering:
3. When you clear the screen, fill the screen with the fog color.
4. Proceed to draw polygons.
5. Take the maximum Z-distance displayed, and the minimum Z-distance displayed, say, 0 to 1000.
6. Interpolate 100 shades of lucency for the polgyon's distance.
IE, polgyon_fog_obscured_value = ( polgyon_z_value * 100 / (polygon max z value - polygon min z value) ) / 100

7. Set lucency to the correct degree, and draw the polgyon.

This way, polygons further in the distance are drawn more lucenctly...which means the fog color is shown, and it looks like the polygon is obscured by the fog. When polygons are almost out of vision, the lucency is very near 100, so they look very obscured.

Of course, this would probably take a lot of processing speed, so it wouldn't be perfect, but it'd be pretty neat, and you could toggle it on and off.

Posted on 2004-09-30 21:59:13

Technetium

The problem I see here is that you would also be able to see polygons through other polygons.

I think it would be much easier to just adjust the color of the triangles based on their distance..

Posted on 2004-09-30 23:59:20

basil

Quote:Originally posted by Technetium


I think it would be much easier to just adjust the color of the triangles based on their distance..


That trick is z-flat shading, which I never tried but apparently looks pretty annoying. With regards to the fog, it's an interesting idea and would probably make for a nice visual effect. I don't believe it would be much of a speed improvement though, since unless your scene is huge you're unlikely to be culling all that much.

Posted on 2004-10-01 01:14:33

Omni

Ah, cull a ton of stuff. The fog itself wouldn't be a speed improvement at all, I just suggest it because I kept wondering how to maybe pull it off.

In fact, you could do certain shades, like a giant blue fog for underwater and stuff like that.

Also, remember Die Hard Arcade? If the polygons were Z-sorted too close to the camera, they were rendered translucent so you could see despite the terrible camera work. That's kinda a reverse method of the fog, because they disappear as they approach the camera, but anyway...

I remember viewing demo videos of a Sega 32X pulling off gouraud shading, texture mapping, and light sources. Had it not been for an incredible amount of culling, the demo would have been very slow. Gave me a bit more respect for it.



Also, I realize that it might be a problem with lucency, Technetium. Since we both do Z-ordering, all polygons are drawn even if they aren't visible. If we either developed true hidden surface removal so out-of-order polygons wouldn't show through as they became translucent, or maybe if we could detect and draw over polygons that are out of view, then those could be solutions. Or, maybe it won't be a problem at all. I dunno, but I am interested to try this out sometime just to see how it looks.

PS: Do you think that image distortion code will be of any use?

Posted on 2004-10-01 02:10:08 (last edited on 2004-10-01 02:14:20)

Omni

Wait. Another idea. Basically, blit another triangle --the fog shader-- on top of the flat triangle. Blit the flat triangle normally, so it does not blend with other flats.

1. Blit the normal flat shade..
2. Then calculate z-lucency...
3. And blit the fog shading triangle (which becomes more and more intense as the distance increases, thus obscuring more and more of the flat).

This way...every flat triangle is not actually blitted lucent, so flats on top of flats don't blend into each other, yet are still tinted with the fog shade.

However, this would be theoretically even slower, since instead of blitting a lucent triangle, you are blitting a flat and a lucent triangle. Still, I think the visual result would be exactly what we would want.



EDIT: Technetium's idea of recalculating the triangle color would probably be faster, but it wouldn't work for a texture/distorted primitive, and it might be difficult if you also include your flat shade lighting calculations in that same color.

In fact, this could probably be done with the CalcColor function Vecna made. In fact, that could be better. Either approach would work, Technetium's is faster but maybe less flexible.

Posted on 2004-10-01 03:50:45 (last edited on 2004-10-01 03:53:47)

basil

I had a look at the image distortion script, and regardless of it's merits if I ever end up texture mapping I'll probably do it myself, primarily because this whole thing is just a project for me to learn some stuff. My priorities right now are speed, texture mapping and animation, so I'll leave the fog to you to have a play with.

Posted on 2004-10-01 06:57:52


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.