Error on defining uniform for PBRCustomMaterial

It seems that after the refactoring of PBR fragment shader code the order of #define CUSTOM_FRAGMENT_... blocks inside of it got broken.
For example, now this block:


comes before that block:


So since custom uniforms have to be defined in the latter block, while being used in the first block, shader fails to compile with FRAGMENT SHADER ERROR: undeclared identifier error.

Please check Babylon.js Playground for the reference. There’s an error with the latest version of BJS, while with v.4.1.0 everything works fine.

1 Like

At first glance possible fix could be to move the


block to the next line after

precision highp float;

but I might be missing something.

pinging @Evgeni_Popov

Thanks for the report, fixed by:


i can confirm that it was fixed in 4.2.0-alpha.19, thanks a lot!