Light updates not applied in a custom PBRMaterial?

I have a custom shader I’m creating, starting from a PBRMaterial, created essentially like:

const shaderMaterial = new BABYLON.PBRMaterial(`bpr`, scene);
shaderMaterial.forceIrradianceInFragment = true;

const brickTexture = new BABYLON.Texture('/brick-texture.jpeg', scene);
shaderMaterial.albedoTexture = brickTexture;

shaderMaterial.albedoColor = new BABYLON.Color3(1.0, 1.0, 1.0);
shaderMaterial.metallic = 0.1
shaderMaterial.roughness = 0.1

shaderMaterial.customShaderNameResolve = (
  shaderName, uniforms, uniformBuffers, samplers, defines, attributes, options
) => {
  uniforms.push('time');
  uniforms.push('myCustomUniform');
  if (options) {
    options.processFinalCode = (type, code) => {
      if (type === 'vertex') {
        return myCustomVertex;
      }
      return myCustomFragment;
    };
  }
  return shaderName;
};
mesh.material = shaderMaterial;

In my render loop, I move my pointlight around:

        (light as BABYLON.PointLight).position.x = 5.2 * Math.sin(time * 0.001);
        (light as BABYLON.PointLight).position.y = 5.2 * Math.cos(time * 0.001);

When I apply my custom PBRMaterial with the custom source code, and I run my render loop, the specular lighting on my mesh doesn’t update as the light is moved around the scene.

Only if I entirely re-create my babylon engine and scene, and re-run the above block, does the specular lighting update on the material.

When I create my custom material, do I need to do something like mark lights as dirty somewhere?

Hello! Can you provide us with a repro on playground? :slight_smile: