• FEATURED

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.

## Inconsistent shadows from a directional light

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1sotteson  Members

Posted 22 August 2013 - 11:56 PM

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.)

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

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

### #2Norman Barrows  Members

Posted 23 August 2013 - 05:51 AM

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).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

### #3sotteson  Members

Posted 23 August 2013 - 10:33 AM

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.

### #4sotteson  Members

Posted 07 September 2013 - 08:47 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.