PDA

View Full Version : stencil shadows and fog



Pswin
02-24-2008, 10:49 AM
hi
why stencil shadows not affected with the fog(look to the picture)?
http://psware.persiangig.com/e/KGE_test/fog_shadow.JPG

how can i solve this problem?

Jackis
02-24-2008, 03:04 PM
That is because your shadowing algo is rather dumb - sou simply blend your screen picture with dark-gray rectangle, isn't it? And fog applies depending on the screen-distance. So to do this correctly, you should think a little bit.
You may write rather simple fragment program, which takes screen depth, converts it to distance and simulates fog, and use it when full-screen blend pass occurs.
Or you may cancel with full-screen blending and make double-pass, first one is Z-fill pass with ambient lighting, stencil-test disabled, second pass doesn't modifies depth, makes diffuse lighting, and stencil-test enabled.
Or you may implement smth your own.