Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hi there, enjoying the light engine. Is it possible to block a shadow in one direction but show it in another. ie. I'm simulating a sudden drop in an overhead game I want shadows cast over the drop but not the other way. Thanks :)

I'm not sure what you mean by that.  The shadows cast according to light source position and light type determines how its lit.

Using the light depth and shadow depth you can affect some things like that, or another shadow caster blocking.

You'll have to explain in more detail, since there is no way to select a single shadow like that.  Its similar to a 3D game's shadows.

What I mean is, if the left half of the room was 100 metres lower than the right half and there was a cliff in the middle, how would I project a shadow over the drop if the sun was in the east but no shadow if in the west. Sorry, not good at explaining myself! 🤪

(1 edit)

I think I get it.

You will want to set the light depth and shadow depth: 

The value is normalized from 0 to 1 which lets you setup your own values based on whatever depth you use for your layers/objects.  A value of 1 is closest to the top and 0 is the bottom.  So, you could lerp() between your maximum and minimum layer depth values for your lights and shadow casters.

(2 edits)

I’ve had a fiddle but can’t seem to get one object to cancel the shadow of another. I’ve set the blocker object to a higher depth than the other and changed the shadow depth and light depth but can’t get the effect I want. Any ideas?


In this example I’m simulating the fact that the dark grey tile is a very tall tower block so should absorb the cars shadow. 

Well that blocker object would need to also be a shadow caster.  We don't have full 3D geometry to work with here.

If the thing blocking didn't also cast shadow it would be odd that it also is tall enough to block it.

(1 edit)

I set it up with a shadow caster initially. What setup would you suggest  I use on the blocker object?

sorry for awkward questions, just trying to figure in the game what’s in my imagination..

The blocker thing would also just be a shadow caster, then the car shadow would be covered by it.

is that the only way to do it? Using another example


the shadow from the track at the top would only cast onto the track below. If the sun came from the south it would not cast the other way. 

If it’s impossible to simulate just let me know and I’ll zip it!

Why would the shadow not cast "north" if the sun was in the "south"? 

The track that is above would be a shadow caster with a higher shadow depth than the track below it.  The sun would also have a depth, but light depth, which would be higher than the top (or equal since it uses >=).

Sun is light depth 1.0

Top track is shadow depth 0.9

Bottom track is shadow depth 0.8

The shadow would then cast correctly.  The only thing you can't really do is have it cast as if the track below has any slope to it since there is no 3D model to work with, i.e., it has a constant shadow depth in a plane.

The top track would be on a different layer than the bottom track, and cars would be on layers right above each.  At the right places on the track those cars would switch layers as well.  They should switch their shadow depth to match the part of track they are on.