Skip to main content
gamedev.net
🔒 Locked

Lights and objects behind objects

Started by brekehan 0 replies 400+ views
Original Post
brekehan
brekehan
I just barely got a basic directional light working where after reading 2 books and several articles. However, all of them seem to process light as an entire object is being rendered. I can't help but think ahead and wonder, how do we tell our engine not to process any light from source A on some light of pixels for object B, because the light is being blocked by object C? For example, in a space scene I have a sun and the planet earth with a space ship that the player moved halfway behind the earth where the light from the sun is being blocked. How do I tell me engine, "hey stop pretending the earth is transparent when lighting the spaceship? Is this a simple thing? I know simple is subjective, but I am a bit scared and wonder if I should just trash my whole realistic lighting ideas for now and just make everything ambient.
Sc4Freak
Sc4Freak
Usually you'd use a shadowing model to achieve this (for example, shadow maps). But in your case, with such a massive object such as the Earth occluding the light source, it may be better to perform an occlusion test. A really simple method would be to cast a ray between your spaceship and the sun. If it intersects the Earth, turn off directional lighting for your ship.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.