Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

Use a static self shadowing lightmap on model mesh

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!