Archived

This topic is now archived and is closed to further replies.

MumbleFuzz

Using surface shaders with real time lighting

Recommended Posts

I''ve been playing around with a basic lighting system (diffuse and specular lighting, using shadow volumes and the stencil buffer for shadows). At the moment, each surface is completely opaque, and has a diffuse, specular and emissive texture, so the rendering order isn''t too important since all the passes are additive. However, I was going to try and implement a more flexible shader system (hopefully a Quake 3 style one that allows for as many layers as needed). My problem arises when a surface is only partly opaque, for example with a grate or wire mesh texture. In this case, the area beyond the grate must be drawn first, and then the grate rendered over the top, so that, through the grating, the scene beyond is still visible. Unfortunately, with lighting and shadowing involved, this isn''t so easy: the shadow volume geometry has to be rendered twice, once for the scene beyond the grate, and then again for the grate itself. This could potentially have to be done for each polygon with a shader which doesn''t simply require an additive blending function, and, clearly, this is an unfeasibly large number of polygons to draw. Anyone know how to get around this?

Share this post


Link to post
Share on other sites
I think you could probably just sort your surfaces by whether they have an alpha value or not and then draw the partly opaque surfaces last with the depth test enabled.

Share this post


Link to post
Share on other sites
Thanks for the reply, JinJo.

I did think about polygon sorting, but I think it''s more complicated than that. The trouble is, each light produces a different set of shadow volumes, which then have to be drawn to set up the stencil buffer for shadowing. This can be done once per light for the solid surfaces, but as far as I can see, when the semi opaque polygons are drawn over the top, the shadow voumes have to be rendered again so that the semi opaque polygons can be properly lit and shadowed.

I just can''t see any way around this. Am I missing something?

Share this post


Link to post
Share on other sites
I don''t think I can''t help much there then, you could just searchthe forums or the nvidia website for tutorials on shadowing, or even google.

Share this post


Link to post
Share on other sites