NodeMaterial crash when using Front facing block

Hey there,

I am trying to get double sided lighting working using a NodeMaterial by inverting the normal using a FrontFacingBlock:

https://playground.babylonjs.com/#D8AK3Z#157

However the shader does not compile because a glsl variable is not defined :thinking: Any idea what’s going on?

Because the FrontFacing block uses a shader instruction that only works in fragment code, you should check the “Generate only fragment code” option on the PBRMetallicRoughness block:

Note that you can change this switch only if the worldPosition and worldNormal are not connected. Else you will get an error message in the console:

image

Fixed PG:

https://playground.babylonjs.com/#D8AK3Z#158

Thanks for the answer! That’s a bit tricky, but it works haha

I also forgot to remap front facing (either 0 or 1) to the [-1, 1] range:

https://playground.babylonjs.com/#D8AK3Z#159

1 Like