Babylon Projection Texture Support

Hey guys… I am trying to do something like Unity Projectors: Unity - Manual: Projector

Yo @Deltakosh … Or somebody… Can you point in the right direction on how this is done in babylon.

I thought i read somewhere about having to handle this with a special shader… Can someone please explain the details on how i can PROJECT a blob type shadow on to the ground mesh.

I saw the playground: https://www.babylonjs-playground.com/#J2FUPK#10

Looks like it uses a separate light and has a projectionTexture

When a light has a projectTexture so it behave differently than any other spot light ?
Is it still a resource intensive?
How many lights with projections textures can I have in a seen ?

I think would need one light with a projection texture per car sitting right above each car and projecting a blob type shadow on the ground… that is what i am going for.

I just need the details on what is way to handle this kind of thing in Babylon.

Please :slight_smile:

not resource intensive at all. It behaves like other spot lights but instead of having a solid color it uses the texture to get the light color:
https://doc.babylonjs.com/babylon101/lights#projection-texture

Would the separate light for each car in my scene with a projection texture be the way to go to accomplish the same type of thing Unity does with its Unity Projectors

I am trying to place a blob shadow on the ground of my … kinda like how unity is doing with the project and projecting a blob shadow on the ground here:

I think so :slight_smile:

Yo @Deltakosh … I am trying to use a light with projection texture. But you can barely see the projected texture. And it has a big spotlight around the projection. Can you control how dark the projected texture is ?

Or is there a better way to project a shadow texture on the ground. Because realtime shadows do not work that well when the ground plane is very large… Like a race track… even with 8192 shadow map size they still look horrible (unless i am doing shadows wrong). So i thought i can get by with PROJECTING a shadow on the ground for each car on the track. I would put a spotlight (or whatever else i can use) above each car and project a fake shadow on the ground that follows the car around.

FYI: This is what i got so far. But can control how dark the shadow is:

Any thoughts on making better looking projected textures ?

@MackeyK24

Maybe this will help?

I think we could have a new light model where there will be no actual lighting but only the decal itself. Pinging @sebavan for more thoughts

I guess this could be done and would make sense :slight_smile:

That would be great… I tried a regular spot light with lightmap mode set to shadows only… but didn’t quite work. Still a little light was coming from light when increased intensity enough to see shadow

I hope a projection texture light with no light works a bit better

Do you want to add it and make a PR so that it perfectly fits with your needs, I guess it might be easier ?

I don’t know what or how to make the a projector

Could we not tweak the projection texture to also be impacting ambient ? Cause currently what you see is all the diffuse from the environment I guess.

I down for whatever… I just need to be able to project as shadow texture to help give depth like this:

If you can do whatever you need to be able to produce that shadow blob above… That would be freaking sweet :slight_smile:

At least we should capture the need with an issue on our repo

What do you think @Deltakosh … do you think we can implement this feature… When using a ProjectionTexture … ONLY emit the texture taking into account the texture alpha … and NOT emitting the light… I need to PROJECT a texture on the ground to simulate a fake shadow.

Here is a playground where i need to project this shadow texture on the ground surface (imagine this is the fake shadow i want to project under my cars driving around a race track)

When trying to use the SpotLight ProjectionTexture the light of the actual light (plus other lights like a directional light also in the scene) wash out the shadow texture. So you can barley see the rectangle outline of the car shadow on the ground.

@Deltakosh once mentioned make the light ONLY emit the projectTexture when one is assigned and not the light… Can you please add that… I do not know how.

this is effect i am going for… Notice the shadow blob under the character

Here is a playground with the projection shadow texture (using low intensity so you can at least see something): https://playground.babylonjs.com/#CQNGRK#490

Would a decal not be a good fit for this ?

Cause a light just for the projection sounds like overkill ?

Can you please show me small example of using a decal to project a shadow on the ground

actually is your ground fully flat else it would not work and we would need the projected texture ?

You can try a hack:

Instead of modulating the final spot light color by the projection texture color it is using the projection texture color only. It works by replacing in the shader code a diffuse *= color_from_proj_texture by diffuse = color_from_proj_texture.

The plane outside the shadow looks bright because you have some white color in your projection texture, you should use black color instead and raise the directional light intensity to compensate.

You also need to set the wrapU/wrapV properties of the projection texture to CLAMP, else it will repeat on the ground.

1 Like