Jump to content
  • Advertisement
Sign in to follow this  
Galshin

Multi-pass rendering with Transparency

This topic is 4888 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been recently experimenting with multi-pass rendering, where I render the scene for each light, so that I can do full dynamic shadows for each light. The problem I am running into is transparency. I can't think of any intelligent way to work transparent objects into this one pass per light technique intelligently (obviously, additive effects, or unlit transparency is easy). Since I am generating a cube shadow map for each light, I need to be able to render the transparent objects at the same general time as I render the opaque objects (so I can generate the shadow cube map only once ). But I can't just additively blend the transparent objects contribution into the scene, as I do with the opaque objects. Anyone know of any typical approaches for this?

Share this post


Link to post
Share on other sites
Advertisement
I don't see a reasonable way to store both the semitransparent occluder and actual occluder (and retrieve them) with one pass.
You could always ignore the transparent objects, then use stencil shadowing using polyhedrea the colors of the semitransparent occluders.
Of course doing this you can't project the semitransparent textures... maybe that'd be a better way... projective texturemapping might be plausable (haven't thought it through yet.)
Anyway, all I really have to give is food for thought, good luck.

-Michael g.

Share this post


Link to post
Share on other sites
Ok, I'm a bit confused.

I don't see any problem with partially transparent objects receiving shadows from opaque objects. Is this what you're having trouble with?

In general with depth-based shadow maps, objects in the scene can receive shadows even if they are not rendered into the shadow map.

Are you talking about the difficulty of rendering the transparent objects into the shadow map itself?

Share this post


Link to post
Share on other sites
If you must use multipass, this can be a hard problem. Carmack has mentioned using a dithering pattern, and then blurring over it. Apparently that works pretty well for him.

In more detail: Say you have a translucent surface with %50 translucency. Instead of using alpha blending, render every other pixel in the surface, maybe using alpha test, or perhaps some kind of frame buffer operation is available that will do this. So you have a pattern of opaque pixels like so:

X X X X X X
X X X X X
X X X X X X

[edit]Ok, the formatting makes my X's not come out the way I wanted here. Suffice it to say that they're in a checkerboard pattern.

Each opaque pixel can easily be correctly shadowed and lit, because it's not translucent. Then, when you have render all lights onto all translucent surfaces, somehow blur/downsample them. This will average them with the frame buffer and you'll get correct lighting with translucency.

NVidia's new supersampling transparent AA might be able to help with this, by doing the blurring for you.

There are disadvantages to the technique, of course, and you should check out Carmack's 2004 Quakecon speech for more details.

Another option: render all of your shadow buffers beforehand. Then, render all opaque objects, using whatever shadow buffers they need. Then, render translucent objects. If you want to use multipass on translucent objects, you could try something like:

initial pass:

multiply frame buffer (dest) colors by translucent alpha

for each light:

add src color * translucent alpha to frame buffer

This is equivalent to doing a alpha blend with the correct "multipassed" color.

Share this post


Link to post
Share on other sites
Quote:
Original post by SimmerD
Ok, I'm a bit confused.

I don't see any problem with partially transparent objects receiving shadows from opaque objects. Is this what you're having trouble with?

In general with depth-based shadow maps, objects in the scene can receive shadows even if they are not rendered into the shadow map.

Are you talking about the difficulty of rendering the transparent objects into the shadow map itself?


I believe his problems stem from the fact that he is using multipass rendering; you can't conveniently alpha blend multiple passes.

BTW, if you have lots of alpha blended objects (not just alpha test) you might consider trying to go to a single-pass technique.

Share this post


Link to post
Share on other sites
hmmm... sounds like it isn't a trivial solution. I had read about that Carmack dithering thing, but it seemed like there must be a better way :p It's really not practical to render all the shadow buffers beforehand, there are quite a few, and it would take up a lot of memory.

Share this post


Link to post
Share on other sites
One idea is to use single pass for the translucent polygons. So that after you have have rendered all your multipass stuff you sort the translucent polys and render all lightning for it in a single pass. This will only work with shaders that allows loops (ps 3.0), but for other shaders you could just use one light or make some kinda light that is an average of all lights affecting the poly.

I haven't tried this though...so I dunno how good it works/looks.

Share this post


Link to post
Share on other sites
for the dithering you might be able to use the alpha to coverage function. though i don't know if it's multi-pass capable. it also removes the need for sorting.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!