SpotLight WebGL warning: there is no texture bound to the unit 0

This error shows on Chrome, and it seems to happen while the spotlight’s projectionTexture hasn’t yet finished loading, and there is a mesh without a texture:

Here it works OK; the ground has a texture (diffuse in this case, but can also be emissive, opacity, bump, …?)
https://www.babylonjs-playground.com/#N4PQLZ

Here it throws warnings; the ground does not have a texture:
https://www.babylonjs-playground.com/#N4PQLZ#1

Hiya Gijs!

ProjectionTexture? Cooooool. I didn’t know there WAS such a thing. Ok, everyone sit down on the couch… and I’ll show slides from my vacation in North Dakota. Do we need a square-shaped spotlight?

I don’t have Chrome installed on anything… but… just out of curiosity… https://www.babylonjs-playground.com/#N4PQLZ#2

I wrapped reg-b4-render in a scene.onReadyObs (lines 32/38). Any change in issue on your end?

Possibly improper texture isReady stuff in the projectionTexture? hmm. One would suspect that it uses the same loader as everything else… but perhaps not. (I’m not much help, am I? Sorry)

1 Like

Hi Wingnut!

The projection playground can be found under “examples” > “Lights” on the playground as “Light projected texture”, and there’s more where that came from!

The wrapper doesn’t solve it, because the registerBeforeRender stuff is actually irrelevant code left in from the original playground (my bad, I should have made a minimum repro). It does work when the spotlight is added after the projection texture has done a onReady though.

You’re probably right about it being an isReady problem, but I don’t think it’s with the projection texture, since it works just fine if the meshes in the scene have a texture.

1 Like

Good catch! Let me try to fix that :slight_smile:

Here we are:

1 Like

That was fast! Great work!