Can't set uniform for PBRCustomMaterial

Please check the PG#1.

I assign a new PBRCustomMaterial for the green sphere with a custom float uniform myWhiteness. But when I try to set it inside a setTimeout, I get the WebGL: INVALID_OPERATION: uniform1f: location not for current program warning, and the float value is not set.

If I remove the second sphere from the scene (comment out sphere2), the warning is gone and the float uniform is set as expected.

Is this a bug or should I use AddUniform method instead of getEffect().setFloat every time I want to change a uniform’s value (like in PG#2)? This kind of fixes the issue, but seems counter intuitive to me :thinking:

I’m using Chrome 75.0.3770.142 on Mac.

I did some further research and found that if I set uniforms inside onBindObservable material callback with setFloat, they work fine. Is this the correct approach (please check the PG#3)?

Pinging @nasimiasl who is the PBRCustomMaterial author


hi :slight_smile: i like people ping Me :))))
but i just make CustomMaterial
let me see what is the error …

dear @alvov
wish that can help :slight_smile:

1 Like

@nasimiasl yeah ok cool, so it should indeed be set inside onBindObservable