2 registered members (AndrewAMD, Ayumi),
884
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Realtime shadow mapping
#95651
10/24/06 11:10
10/24/06 11:10
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
OP
Expert
|
OP
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Hi, This is a shot from my realtime shadowmapping shader. Some info: -The cube in the top left is the lightsource. -All objects can cast and recieve shadows. -The shadows aren't smooth yet, I'm planning to add a smoothing method I have come up with. If it doesn't work or produces other problems I will implement percentage-closer filtering. -Requires vs 1.1 and ps 2.0. -No plugins.
|
|
|
Re: Realtime shadow mapping
[Re: broozar]
#95655
10/24/06 11:46
10/24/06 11:46
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
OP
Expert
|
OP
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Thanks for your comments. Quote:
how does it work?
1) The scene is rendered from the lightsource with a shader that outputs the depth. 2) The scene is then rendered with the normal camera and the depth texture is projected from the lightsource onto the scene. I then check the depth in the depth texture to the distance from pixel to the lightsource. If the pixel's distance to the light is greater than the depth stored in the depth texture, it is in shadow.
Quote:
does the light source have to have special parameters? or the block (like _litAndShodow)?
The light source is basicly a view, so you can set it's position, angle, arc, etc. The occluder/reciever doesn't need anything, it just needs to be a mesh.
Right now the scene is only rendered once from the camera but I'm planning to change it so that the camera is first rendered with the normal shaders, and then with a shader that only draws the shadows (with the other areas transparent) and overlay that on the first render. That way, you can still use your normal shaders.
This also allows to use a simple screenspace blur on the shadow texture. However this will result in dark halos around the silhouette of the model. I will try to prevent that by using the differntial of the neighbouring pixels on the shadow map (Don't blur if neighbouring pixels are much 'deeper'). If that doesn't work I will use percentage closer filtering: check how many points near this pixel are in shadow to decide shadow darkness. The drawback of PCF is that a smoother shadow will require more samples (thus slower rendering).
Quote:
can we set if a surface can receive shadows?
Everything casts and recieves shadows by default. You can use a different material in the depth-pass that doesn't render the object so that it is 'ignored'.
Quote:
Please talk with JCL about this topic. Maybe he can add your excellent shaders into the upcoming shader template package?
When the shader is done, I'll talk to JCL about this.
Quote:
what about multiple lights?
Not yet supported, I'll have to think about the implications of adding another light but it should be possible.
I think implementing this shader in your project could be as easy as including a script and passing a vector pointer to a function. You can then set that vector to any position and angle you want. You will probably also have to add two lines of code to all your materials for switching to a depth material when rendering from the lightsource.
|
|
|
Re: Realtime shadow mapping
[Re: Excessus]
#95656
10/24/06 12:44
10/24/06 12:44
|
Joined: May 2002
Posts: 2,541 Berlin
EX Citer
Expert
|
Expert
Joined: May 2002
Posts: 2,541
Berlin
|
Interesting... If you do multiple lights, could you try to make the shadow the more transparent the closer they are to the light. It would be good if a second light source is within the shadow of another lightsource it would lighten up around the light the closer the "part" of the shadow is.
:L
|
|
|
Re: Realtime shadow mapping
[Re: EX Citer]
#95657
10/24/06 18:46
10/24/06 18:46
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
This looks very intriguing and interesting !! It looks like the effect you create is very realistic Het goede oude Hollandse verstand, wa zouden we zonder Mooie werk Excessus Cheers Frazzle
Antec® Case Intel® X58 Chipset Intel® i7 975 Quad Core 8 GB RAM DDR3 SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB NVIDIA® GeForce GTX 295 Memory 1795GB
|
|
|
|