Standard Material compilation error since 5.6.0

HI all!

I’m focusing on releasing the editor using Babylon.JS v5 but I’m facing an issue since version 5.6.0 that I can’t figure out.

The problem is also that I fail to reproduce it in the playground and that’s a problem! :scream:

I reproduced only using the Standard Material and it looks like it is related to prepass and available uniforms.

Error: FRAGMENT SHADER ERROR: 0:237: 'view' : undeclared identifier

    at Engine.ThinEngine._finalizePipelineContext (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:61234)
    at Engine._createShaderProgram (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:53573)
    at Engine.ThinEngine.createShaderProgram (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:61157)
    at Engine.createShaderProgram (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:53546)
    at Engine.ThinEngine._preparePipelineContext (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:61282)
    at Effect._prepareEffect (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:128047)
    at Effect._useFinalCode (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:127743)
    at /Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:127685
    at /Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:42043
    at Function.ShaderProcessor._ProcessIncludes (/Users/julienmoreau-mathis/Desktop/Babylon/Editor/node_modules/babylonjs/babylon.max.js:42387)

With more details, it looks like prepass normal computation uses “view” which is not declared:

Offending line [268] in fragment code: glFragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo)
Error: FRAGMENT SHADER ERROR: 0:268: 'view' : undeclared identifier

The only file related to standard material / prepass I see declaring view uniform is: Babylon.js/defaultFragmentDeclaration.fx at master · BabylonJS/Babylon.js · GitHub but the file history doesn’t explain why the problem appears only since 5.6.0

I have checked and the editor performs 0 override/strange thing on the engine

Any help would be awesome :slight_smile:

Thanks a lot !

As you are doing stuff on a Sunday, no one who could really help will see this for another day.

You could just remove the prepass, if you had not already done so, and see if it now compiles. That would prove your diagnosis.

As far as to why you see no shader change is probably because it was forgotten to. Changes could have been made in the PBR shaders, but not here. You could also do another test by changing PBR, ignoring what it looks like, but does it compile?

@sebavan - has anything changed that you can point at?

What did you do with your StandardMaterial when the error occurred? Did you just create it or did you set some specific property?

Do you have a reflection or refraction texture setup ?

This could fix it Fix prepass view uniform by sebavan · Pull Request #12562 · BabylonJS/Babylon.js · GitHub

2 Likes

I have no reflection and no refraction
I tried to set refraction to unlock view uniform but still got and error if I’m not wrong.

Let me do the test again

1 Like

Hey there @julien-moreau just checking in, did you manage to reproduce the error?

1 Like

Ouch! I forgot to resolve the thread! @sebavan 's fix works perfectly!

2 Likes