Help With Projection Textures

Yeah i originally tried the spotlight method but my issue I wanted the projected texture to be more opaque since i often have really complicated models with odd meshes and decals werent working out for me too well.

what about a post effect to ramp things?

could even use the standard material, then do a separate rtt that when applied does your custom material which would be just the spotlight texture and like a transparent model, then combine the two passes?

You lost me there? So I would load two models (one normal textured, one transparent), use light projection onto the transparent one?

You would do your normal pass, of just the model lit however you want it to be minus the spotlight.

Then do a secondary pass where all the light is turned off but your spotlight.
Once the secondary pass is done take both of the results and combine them in a postproccess where now you have control of the color values.

https://playground.babylonjs.com/#QFGSM3#1
There are a few steps missing but this should get you there at least with the postproccess way.

I can think of a half-dozen different ways to solve this so if you run into a road block let me know.

I’ve got something working using a combination of yours and Pryme8’s examples but i was running into issues with multi-material objects. Would this method work with multi-material objects? I was looking at the mix method to try and blend the materials but it doesnt look like what i need. Or would it make more sense for me to bake the texture into a single material in blender? I’d prefer to do it in code if possible but if not i can do it for each of my models in blender?

multimaterial is just a container of materials. So it should not be a problem

Can you share a repro of the issue you face with multi materials?

this was a bit of mis-communications, i didnt realize multi-material was a library thing. What i meant was when the model loads with multiple materials. Would i be able to use a multi-material as the material to put an emissive texture onto? Or even would i be able to set each material to a new multi-material and use merge mesh as that would allow me to use an alternative method.

This is why we need repro :slight_smile: Code is obvious.

Anyway, if you have several materials, you just need to apply your emissive texture to all of them.

1 Like

Sorry its been a while and i dont know if this should be a separate question or not, but is there any way to change the size of the texture being projected into the spotlight so that the rectangular texture fits within the circle? I’ve tried running a scaling function on the projection texture matrix but that doesnt seem to do anything?
https://www.babylonjs-playground.com/#J2FUPK#34