How to rotate environment map at runtime?

There seems to be an open issue about this here:

Is there a way to apply a shader modification to achieve this in the mean-time? It’s possible to add custom uniforms using onBeforeCompile so I can add a vec3 for the rotation and I can insert a transform somewhere in the shader but I can’t see where to add the transform.

The env map direction is controlled by envmap_fragment. This is included in some of the main material shader types. For some reason that include isn’t in meshphysical_frag though so I’m not sure where the envmap chunk is being used there. But I could modify the reflectVec in envmap_fragment with the custom uniform.

How do I modify those chunks? onBeforeCompile shows the main shader so I could paste the whole modified shader in but where is meshphysical_frag processing the environment map?

Found it, the envmap code for the standard material shader is in:
#include <envmap_physical_pars_fragment>

so with an onBeforeCompile, it’s possible to do shader.fragmentShader.replace on that line and paste the contents of that file in with the new uniform. That should let me rotate the environment map at runtime.

@adevart I’m running into this same issue, could you point me to where in that ShaderChunk you need to modify? I tried it on the queryVec but that didn’t change anything for me

Edit: Nvm found I was modifying the wrong variable, it should’ve been the reflectVec

I’m trying to figure out why my light reflections dont change when I change a skybox. Nothing in my scene is static, I’ve disabled baked lights and everything is set to realtime. Deffered rendering. But I have a script that replaces the skybox and runs DynamicGI.UpdateEnvironment but still reflections of the old map are present. I do get some light from the new box though as well. Any ideas krogerfeedback

Are you modifying scene.background or scene.environment (former one does not create reflections) ?