Darken texture with spotlight

I’m trying to add a simple shadow effect (a simple gray-ish circle) under some moving sprites to give them some depth in the scene.

Is it possible to achieve this using a spotlight somehow, so getting the opposite effect out of one?

Here’s a playground example: https://playground.babylonjs.com/#20OAV9#3620

So instead of making things lighter around the sprite, I’d like the spotlight to make things darker, like a shadow.
Since I only need a simple shadow effect, I thought something like this might be an inexpensive way to achieve this.

Hi Censor,

This is a really cool idea! I’d never thought about it before, but apparently you can give spotlights a negative intensity. Check it out!

https://playground.babylonjs.com/#20OAV9#3621

Will that work for what you’re going for?

3 Likes

Awesome, thanks! That’s what I needed.

@syntheticmagus Quite clever! But I wonder if it’s really something intended and not a side-effect of the current shader code… Meaning, it’s not a feature we officially support and could break in future releases.

Another possibility would be to use something like a projector, see this thread: Babylon Projection Texture Support

1 Like