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

## Recommended Posts

I have been reading alot of different tutorials and stuff here on this forum, but one thing I havn't understand yet is if I need one depthmap for each light that cast shadows? but then I need to activate all of them at the same time when doing the test against the depthmap?

##### Share on other sites
Yes, you need a separate depth map for each lightsource. When rendering the shadowed geometry, you perform as many tests as there are lights, and somehow combine the results. I said "somehow", because different people use different methods, it's more often than not an artistic decision. The physically most correct way is to add the light contribution of all sources together, each one multiplied with the shadow comparison factor of its depth map.

1) Start by rendering each light to its individual depth surface

2) Bind each surface to a separate texture (imaging) unit.

3) Set up a depth compare for each unit, making sure that the generated projected texture coordinates for each unit match the one of the respective lightsource.

4) Use the following equation per pixel:

c(final_light) = c(light0) * depthCompareResult(0) + c(light1) * depthCompareResult(1) + ...

5) Multiply the c(final_light) with whatever diffuse texture or colour you might need.

##### Share on other sites
EDIT Beaten by Yann

-Mezz

##### Share on other sites
I have a question relating to Shadow maps.. I think I sort of understand how the process of setting up the depth map works, but what I dont understand is the rendering process.. (basically) how does the texture create these shadows on the screen, and do you use a textured quad in front of the camera? I know a quad is involved somehow, but.. I just don't see how it all fits together at the moment. Maybe someone could direct me to a nice explanation of shadow mapping.

##### Share on other sites

nVidia paper

Paul's Projects tutorial

To provide a bit of answer to your question Mikey, shadow mapping makes use of projective texturing, to project the shadow map onto the geometry into the scene. Using this you can easily figure out which texel in the shadow map applies to the particular part of the geometry you are rendering, and thus know if it is in shadow or not WRT the light source.

-Mezz

##### Share on other sites
Do shadow casters/reciever meshes need to have UV coordinates?

##### Share on other sites
The depth map is projected onto the shadow receivers, so the uv coords are generated. The nVidia paper that Mezz posted is a very good reference, especially when you first start to learn about shadow maps.

##### Share on other sites
ok, I'll look into the nVidia paper... but so far I can't really understand how the shadow maps can be valid at the same time.. this will cost alot of texunits? or do I create an extra pass that project all of them into one big depthmap and use that one only?

##### Share on other sites
Quote:
 Original post by McZI can't really understand how the shadow maps can be valid at the same time..

I'm not sure I understand this question. If you have one shadow map for each light, then render the scene from each light's POV into their shadow maps, then all the shadow maps contain valid information. After you've done this, you can use these shadow maps when drawing your actual scene from the viewer's perspective, to tell whether certain objects are in shadow or not.

Quote:
 Original post by McZthis will cost alot of texunits?

It will if you do multiple lights in one pass, but you can do a pass per light and only bind one of your shadow map textures at a time, hence only using one texture unit.

Quote:
 Original post by McZor do I create an extra pass that project all of them into one big depthmap and use that one only?

I've never heard of this as a technique, so I couldn't recommend it.

-Mezz

##### Share on other sites
ahh thank you! now I understand :)

I use up all tex units I have free for a pass.. but what if my texunits isn't enough for one pass? how do I split it into several passes? do the extra passes also need depthmap testing?

and what to do if I have more depthmaps then tex units?

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633385
• Total Posts
3011600
• ### Who's Online (See full list)

There are no registered users currently online

×