Per pixel diffuse+spec and depth shadow mapping in DX8

Started by
3 comments, last by GameDev.net 19 years, 7 months ago
Hi all... This is getting a bit longer I guess. I have a DirectX 8.1 compatible hardware platform with 4 texture stages which is capable of depth shadow mapping. What I want to do is to have fully blown per pixel lighting (diffuse & specular) plus depth shadow mapping for the scene. My current idea is to have two framebuffers. The first framebuffer is rendered using only the lighting information (say, do per pixel light calculations plus depth shadowing) which would mean one render pass per light there. The second one would be rendered in a single pass using only textures. In a final step those two buffers then are blended together. This seems somewhat reasonable to me since it means 2 passes per light (shadow buffer generation & ppl) and a final pass for textures (at the moment I don't have an idea about how to reduce that count). The thing is: it won't work properly because the diffuse component has to be modulated with the textures where the specular component has to be added. Another idea would be to do diffuse and specular separately. This would average to the same amount of passes since I can do two lights diffuse or specular per pass. However, I'd need 3 render targets there. Hm. I don't even want to thing about alpha blending right now. :) I am ready to try anything promising, but it's just a huge amount of work so I wanted to hear your opinions / ideas about that topic before diving right into it. Thanks, Alex
Alexander Stockinger
Programmer
Advertisement
Hm. When I think about it the second solution doesn't sound too bad to me. But I guess that'll get me into a real mesh uploading / framebuffer changin hell.
Alexander Stockinger
Programmer
If you don't use colored specular, just white, you can accumulate it exactly like you accumulate color, except in the alpha. When you do your final blend, do framebuffer.rgb*texturediffuse.xyz + framebuffer.a

If the specular color changes per object, but not per light, you can accumulate a specularamount as above, then do framebuffer.rgb*texturediffuse.xyz + framebuffer.a*objectspecularcolor.rgb

Hm. Good idea. Even white specular highlights might actually look good for colored light sources - of course depends on the scene.
Alexander Stockinger
Programmer
Here's a rough idea that I haven't actually tried yet - for a shadow mapping method with just one framebuffer - render just an ambient pass into framebuffer color, then render all shadows into framebuffer alpha, then do a final alpha blended diffuse/specular pass into framebuffer color using: dst_color + (src_color * dst_alpha). If framebuffer alpha is cleared to white, and shadows are rendered as dark, then: fully unshadowed pixels will be dst_color + src_color (i.e. ambient + diff/spec) and fully shadowed shadowed pixels will be dst_color (ambient only). Partially shadowed pixels have some diff/spec. Naturally, there are a dozen details I've left out (and probably ar least one fatal flaw), but the general idea is: no diff/spec on shadowed pixels.

joe
image space

This topic is closed to new replies.

Advertisement