What is the shader variable name for IOR or indexOfRefraction in PBRCustomMaterial?

So I have been using PBRCustomMaterial and wanted to know where I could look to see all the shader variable names so I can override them.

For example I can access metallicRoughness via this variable name and update it:
metallicRoughness = vec2(metallic, roughness);

or I can also modify the albedo using surfaceAlbedo = texture2D(etc, uv);

I’m using Fragment_Custom_MetallicRoughness to update the iOR but that might be wrong.

I mostly see errors like this:

Engine.ts:703 BJS - [13:21:57]: Error: FRAGMENT SHADER ERROR: 0:703: 'indexOfRefraction' : undeclared identifier
ERROR: 0:703: 'assign' : l-value required (can't modify a const)
ERROR: 0:714: 'indexOfRefraction' : undeclared identifier
ERROR: 0:714: 'assign' : l-value required (can't modify a const)

I’ve tried ior, IOR, or indexOfrefraction but cant seem to find the exact name.

https://doc.babylonjs.com/typedoc/classes/BABYLON.PBRCustomMaterial

cc @Deltakosh

1 Like

Ok so here is the source code for the material:
Babylon.js/packages/dev/materials/src/custom/pbrCustomMaterial.ts at 03b37475e5a79833abc3a44e9333e057916fa143 · BabylonJS/Babylon.js (github.com)

The main shader is there;
Babylon.js/packages/dev/core/src/Shaders/pbr.fragment.fx at 03b37475e5a79833abc3a44e9333e057916fa143 · BabylonJS/Babylon.js (github.com)

For IOR:
Babylon.js/packages/dev/core/src/Shaders/pbr.fragment.fx at 03b37475e5a79833abc3a44e9333e057916fa143 · BabylonJS/Babylon.js (github.com)

You want to update the vMetallicReflectanceFactors
Computed here initially:
Babylon.js/packages/dev/core/src/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.ts at 03b37475e5a79833abc3a44e9333e057916fa143 · BabylonJS/Babylon.js (github.com)

1 Like