Jump to content
  • Advertisement
Sign in to follow this  
HurtLockeR

Shadow Mapping - How to make geomtery block shadow casting

This topic is 2214 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

If only the dynamic objects are casting real time shadows, you can build a unique shadow map for each, then have them project into the scene by rendering small boxes around the gynamic geo extruded/ stretched in the light direction (deferred shadow map style). You could then limit this extrusion by some arbitrary amount to avoid them reaching casting too far, based on your scene. Kind of hacky, but would work in most cases.

Share this post


Link to post
Share on other sites
Advertisement

Thanks for the ideas. Hope I can get somewhere smile.png

 

Would it be an idea/possible to have 2 shadow depth textures (D3DFMT_32F), and then in one I render the entire scene: static + dynamic models.

(Even though I don't want static models like bridges, houses, walls, etc. to cast shadows since I use lightmapping for those)

 

And then to the 2nd texture I only render all dynamic models.

 

Then in the 2nd pass shadow shader, I test against the 1st buffer but if the test passes I use the data from the 2nd?

 

 

I keep thinking some games must have used something like this (lightmapped scenes + dynamic shadows)? It sounds pretty simple to implementsad.png

Edited by HurtLockeR

Share this post


Link to post
Share on other sites

A better approach is to use a G16R16F texture and store dynamic geometry into the red channel and static in the green channel. Then when you read it in you can compare the shadow to the static depth too, without needing to read extra textures (or wasting more memory).

 

Honestly though, if you're going to go through the trouble of rendering your static geometry into a shadow map anyway, you might as well use them in the shadow mapping stage and reserve your lightmaps for your indirect lighting. It will look a lot more consistent to have the same shadows on all objects (look at "The Last of Us", they do this).

 

Most of the time "the other guys" use some form of blending like I mentioned. Just pre-compute the lightmap shadows (no GI or indirect lighting, just shadows) to the alpha channel of your lightmap textures (or wherever) and use this as a mask for your shadows. Then you can check if your shadow is inside a lightmapped shadow and just remove it. Rendering all your static objects to a shadow map and not using them at all for shadows (just masking) is a bit redundant and negates the point of having lightmap shadows in the first place.

Edited by Styves

Share this post


Link to post
Share on other sites

A better approach is to use a G16R16F texture and store dynamic geometry into the red channel and static in the green channel. Then when you read it in you can compare the shadow to the static depth too, without needing to read extra textures (or wasting more memory).

 

Honestly though, if you're going to go through the trouble of rendering your static geometry into a shadow map anyway, you might as well use them in the shadow mapping stage and reserve your lightmaps for your indirect lighting. It will look a lot more consistent to have the same shadows on all objects (look at "The Last of Us", they do this).

 

Most of the time "the other guys" use some form of blending like I mentioned. Just pre-compute the lightmap shadows (no GI or indirect lighting, just shadows) to the alpha channel of your lightmap textures (or wherever) and use this as a mask for your shadows. Then you can check if your shadow is inside a lightmapped shadow and just remove it. Rendering all your static objects to a shadow map and not using them at all for shadows (just masking) is a bit redundant and negates the point of having lightmap shadows in the first place.

 

http://miciwan.com/SIGGRAPH2013/Lighting%20Technology%20of%20The%20Last%20Of%20Us.pdf

There is presentation that explain how "Last of us" does their lights and shadows. Some levels only contains fully baked lightmap that contain main directional component of lighting and ambient color. These are used by gpu and sub resolution copy of screen space buffer about is handed to SPU. Then per pixel direction value is used as starting point for cone trace against dynamics objects that are approximated with spheres. This is how they get super soft dynamic directional and ambient occlusion shadows that blend perfectly with baked light maps. Quite hacky and complicated(at least implementation wise).

Edited by kalle_h

Share this post


Link to post
Share on other sites

Yeah I finally got to look at the paper after my post, seems I jumped the gun on using it as a reference. I remember them mentioning this for Uncharted 2 though. At any rate I didn't see any lightmapped shadows in the Uncharted games, only lightmapped GI.

 

Still, the concept can work for the OP. smile.png The idea is to blend the lighting together to make it consistent, doesn't really matter how OP chooses to do it.

Edited by Styves

Share this post


Link to post
Share on other sites

Hello Styves, kale_h,

 

Thanks for your suggestions! I decided to go with the lightmap blending option. This is the easiest to implement: just make sure the world light is in the same position as the lightmap lighting, and then blend the realtime dynamic shadows with the baked lightmaps in the shader.

 

This makes the realtime shadows and the lightmap shadows blend perfectly, and there's no need to depth pass the static models! Frame rate = happy.

 

This whole thing of blending lightmaps and realtime shadows is actually interesting since it could give you the best of both worlds until hardware will be fast enough to do global illumination + shadows on detailed levels, which is probably a few years off yet.

 

If you make the realtime shadows soft, then you can't really tell the difference between what's pre-lightmapped and what's real time.

 

Thanks again, next step will be to look into the Last of Us shadowing! (especially hard edged shadows close up and softer at a larger model distance).

Edited by HurtLockeR

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!