• Advertisement
Sign in to follow this  

Inconsistent shadows from a directional light

This topic is 1685 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'm writing a D3D game where the player's ship flies along and casts a shadow nearly directly underneath to give a clue to the player on the height of the ship. I'm attempting to make this a directional light by using an orthogonal projection for the projection matrix of the single light. As the ship moves forward, I update the location of the light so that the shadow remains the same relative to the ship's position. The problem is because I move the light, shadows for other objects move relative to the light, instead of also staying underneath their objects.

 

(I'm purposely darkening the shadows so that you can see them better.)

 

shadow1.png

The blue ship is moving forward and the gray ship is stationary. Note where the shadow is for the gray ship.

 

shadow2.png

The blue ship has moved forward. I've moved up the light so that the shadow stays under the blue ship, but I need the shadow under the other ship to stay under itself too. Instead, its shadow moved up since I moved up the light to chase the blue ship.

 

I feel like this should be easy to fix, but so far I can't figure it out. Thanks for your help.

 

Steve

Share this post


Link to post
Share on other sites
Advertisement

looks like whatever engine you're using is casting shadows for you (nice!).  but your light is way too close for it to seem like the sun. you can try moving the light farther away (like 93 million miles farther away) to get the correct effect. may not work though. it that case you fake it and draw the shadows yourself.   changing the light type may also work (directional vs point, etc).

Share this post


Link to post
Share on other sites

I'm using raw DirectX 11 with my own shaders for this game. I tried moving the light to be 93 millions miles up, but then I still need to give it a z component that matches up with the player's ship. This continues to give the effect of the shadow directly under the player's ship, but shadows for other objects not staying underneath themselves. I may have to find a way to fake it unless anyone has any better ideas.

Share this post


Link to post
Share on other sites

I ended up switching to volumetric stencil shadows to get a shadow directly under everything that has a shadow. Right now the perf is acceptable, and hopefully it stays that way as I add more objects that cast shadows in the game.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement