Possibility of "hard coding" in shadows to increase sharpness/perfomance?

Hey everyone,

I’m making a 90s FPS style game and using the shadowGenerator doesn’t produce sharp shadows (well it does but I have to increase the size of the shadow map and it kills performance for me with lots of shadows)

My question is would it be possible to do something like the BUILD engine (Duke Nukem, Blood etc), that is manually placing all of the shadows?

I had the idea of doing something like this -

Where I create a “shadow mesh” - that is if it mesh overlaps with another mesh it changes the color to its color (e.g. so you would set the shadow mesh to black with a transparency of 0.5) - this would give me the sharp angles for shadows I believe.

I’ve seen shaders written in Unity to do this, but before I start trying to figure how to do it in Babylon - I was wondering if anyone could give me feedback in terms of this being a good idea for performance?

(another example in blender)

Hi @kestrelpi and welcome to the Babylon community! Pinging @Evgeni_Popov a.k.a (amongst other things) Shadow Expert!

1 Like

Hi, I was creating a force field these days and it seems similar like your blender generated image. So maybe you can place spheres in the corners where you want the desired shadow effect and create a node material for that sphere to achieve the effect quite easily.


1 Like

I’m not sure I understand fully your question, but in those old days we used the vertex colors to add some shadowing to meshes. Shadow generators are for dynamic shadows, if you only want static shadows, vertex colors or lightmaps may be what you need. A minimal repro in the Playground may also help to better understand your needs.


Using vertex colors was exactly what I was looking for! thankyou!

Did a quick test and the shadows came out exactly how I wanted :slight_smile:

1 Like

This is not what I have imagined what you would like to achieve :sunglasses: :joy: would you mind to share a PG so we can see what you did? :vulcan_salute:
Thank you!

I would also second a request to see a PG. Really interested to see how this was achieved with vertex colors.


1 Like

Hey guys,

Was nothing special just done in Blender - first used a light to get the right angle

Then just cut out the geometry and painted the shadow with the vertex paint tool

@roland it’s not what I originally thought of but in terms of performance it’s heaps faster and it’s the kind of look I’m going for

I get it, so you have the geometry adapted to your needs and your lights are static I suppose, so this is working and I think it’s a quite good and optimized solution, if you have time to modify your meshes. I like this approach, for a small level it might work. However I was confused by the term vertex colors.
Thanks for sharing!

1 Like

And keep us posted on your game :+1: