Any way to rotate the environment map in a shader

I would like to add a kind of moving sheen effect to a shader. One way I thought of doing it would be to use the clear coat layer reflecting a rotating environment map.
The material in the Playcanvas editor has no controls to rotate the environment, so I’m wondering whether there is any way to control that in a custom shader? Perhaps by rotating the normals in the environment lookup (although I haven’t found the code for that part of the standard material yet, so not sure if that would work.)

In other words: which shader chunk can I modify to play with the way the environment reflection happens in the clear coat section?

We do have skybox rotation:


Do you need it to be specifically in the shader?

Yes, I want to do this at the shader level, for the cubemap added to the environment section of the material. Not at the global scene level.

Looking through the engine code, you might be able to use the following parameter in the standard material:

            if (!scene.skyboxRotation.equals(Quat.IDENTITY) && scene._skyboxRotationMat3) {

@Leonidas , any input on this?

Right, I haven’t tried it before, but studying the engine source code what Yaustar proposes will work.

I think if the cubeMapRotationMatrix uniform is provided in your material as soon as material.update() is called the relevant shader chunk will be updated to use that rotation.

You can check here how to calculate the rotation matrix in your own script:

1 Like