Sign in to follow this  
MARS_999

Use a static self shadowing lightmap on model mesh

Recommended Posts

I am thinking about sticking with my static lightmap I calculate on the CPU for my terrain to do self shadowing. Now what would I need to do to take that same texture and apply it to my model meshes so the seem like they are being shadowed by the terrain hills vs. when I drive under a hill the model stays lit and the ground is darkened? Thanks

Share this post


Link to post
Share on other sites
Your terrain shadows are, I presume, being calculated using some basic raytracing method? I suppose you could raytrace a small, say 32x32 pixel shadowmap from the vehicle's position, billboard-oriented towards the light source and made large enough to cover the projection of the vehicle's bounding sphere from that angle, and use that shadowmap as a projected texture onto the vehicle?

Alternatively, if your terrain shadowmap is already high-enough quality (if you do localized higher-detail re-rendering, say), you could take the 8 corners of your vehicle bounding box, raycast them onto the terrain in the light direction, and sample the terrain shadowmap to get 8 lighting values; then use a simple shader to brighten the vehicle's texels based on their position in that 2x2x2 3D texture created.

Lastly, you could just raytrace a single point from the vehicle center-of-mass in the light direction to the terrain, and change the ambient lighting coefficient of the vehicle's materials to match that sample.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this