VSM, the expensive shader

Started by
24 comments, last by AndyTX 15 years, 5 months ago
Hi there! I have done the vsm shader in my """engine""", and I hit a newer problem. For a shadow I create a depthmap in the light VP space (indeed, in the "depth, depth*depth" form). I blur that. Then I compute the ratio of the shadow using the vsm formula. And here is the problem. I can't draw the result to the same texture. So i draw the reults into an other texture. And so I have two texture for a shadowmap (a blurred depthmap and a vsm map) It's clear, sure. But how can I manage that? I'm sure using vsm shader with one texture can be. Any Idea? Thx ahead your help! And sorry my veryvery bad english! I hope I disturbed noone! BB
Advertisement
How would you manage that problem?
I also do things this way in my current project, I render out the shadow map, then I do a single full-screen pass where I render out the shadow occlusion factor to a screen-sized texture. Then during my main pass where I render all of the opaque geometry and apply lighting, I just sample the shadow occlusion texture and use that to adjust the lighting.

What part exactly are you having difficulty managing?
So. I have the blurred vsm map. And i have to draw that "occlusion factor"
to somewhere. Now somewhere surely doesn't mean the same texture.
If I drew to the same texture, I would overwrite some pixels, them I'd probably need. Therefore I can't use the same texture for computing vsm and computing "occlusion factor". I need two textures.

You said:
"I render out the shadow map, then I do a single full-screen pass where I render out the shadow occlusion factor to a screen-sized texture."
You also use two textures per one shadow. One to render shadow map, and another one to render "occlusion factor to a screen-sized texture".
I think You use the second one at the final render. Am I right?

So how to avoid using two maps per one shadow?
I just create a new texture whose size is the same as the backbuffer. I only store the occlusion value from one light source since I only do shadows for the sun, but if you wanted you could could store the occlusion for up to 4 sources in one A8R8G8B8 texture (use one channel for each light source).
This is also called a shadow mask or shadow collector. If you have several different shadow sources you can just alpha blend them in there. For example dedicated character shadows that are blended over the shadows coming from the Cascaded shadow maps can be stored in there or indoor shadows coming from several light sources cached in a texture atlas etc ...
To MJP:
So I definitely need as much texture as much shadows I want plus one to store the occlusion value (one texture/4 shadow). Right?

To wolf:
Okay! It looks like It worth to watch that page. Thx


And can I ask U guyz, 3 shadows enough are in the most of situations?
Quote:Original post by AmidaBucu
And can I ask U guyz, 3 shadows enough are in the most of situations?


Well. of course it depends on your scenes, your methods of navigations, etc. But, Whta you are saying essentially is two point lights plus a sun-shadow? Crysis supports at the least 4 point lights plus sun..

For many occasions, that may be enough. But maybe you write the engine in such a way that if a new light (greater than 3) is created, the resources for it can be created on demand, although you may get a little skip when you create the textures the first time.

All that said I would say 4 point lights and one sun shadow is enough for alsmot every occasion if used judiciously (I'm not a fan of VSM for a number of reasons, like the fact you need more than 1 channel of a floating point surface---means you cant pack 4 lgiht into one suface).

Quote:I'm not a fan of VSM for a number of reasons, like the fact you need more than 1 channel of a floating point surface
good point ... check out exponential shadow maps. They only use one channel and look similar or better (?).
Quote:Original post by wolf
Quote:I'm not a fan of VSM for a number of reasons, like the fact you need more than 1 channel of a floating point surface
good point ... check out exponential shadow maps. They only use one channel and look similar or better (?).


ESM's are pretty nice, but they can have some bad artifacts in certain situations. VSM's with an exponential warp can look a lot better IMO, but their precision requirements make them impractical for most hardware (certainly on consoles).

This topic is closed to new replies.

Advertisement