It might be the same issue as Clear coat breaks shader in ios, but I don’t have a way to know for sure.
Either way: in certain situations we are getting a shader compilation error in the console and so far we could not figure out a reason for the error, nor a minimal playground reproduction, but since we’ve been extending shaders in quite a hacky way we assumed we are at fault here.
However, now that we’ve digged into Babylon’s shader code, we suspect it’s a Babylon issue. Since we don’t have a repro playground, we’d appreciate if you could follow along the logic in the following description. The code positions are linked to the 4.1.0-beta26, which is what we currently on.
The error we are dealing with is:
Error: FRAGMENT SHADER ERROR: 0:638: ‘absorption’ : undeclared identifier
ERROR: 0:638: ‘clearCoatNdotVRefract’ : undeclared identifier
ERROR: 0:638: ‘assign’ : l-value required (can’t modify a const)
ERROR: 0:638: ‘=’ : dimension mismatch
ERROR: 0:638: ‘assign’ : cannot convert from ‘highp 3-component vector of float’ to ‘const highp float’
ERROR: 0:639: ‘absorption’ : undeclared identifier
ERROR: 0:640: ‘absorption’ : undeclared identifier
The line in question is
absorption = computeClearCoatLightingAbsorption( clearCoatNdotVRefract, preInfo.L, clearCoatNormalW, clearCoatColor, clearCoatThickness, clearCoatIntensity);
This line appears in lightFragment.fx and is guarded by
However, the definition of
clearCoatNdotVRefract is in pbr.fragment.fx and is guarded by
CLEARCOAT and negative
While we probably can safely assume without looking that
pbr.fragment.fx is itself guarded by
PBR and probably
LIGHT, there is still a missing
REFLECTION, so that if there is no reflection texture but a clear coat tint,
absorption would be not defined, but referenced, just like the error message says.
We hope we haven’t missed anything obvious in describing the problem and would greately appreciate a fix