Change UVs in the shader, three.js v151+

Hello everyone,

I’m currently working with three.js version v156 and I’m facing a challenge in changing UVs for a given image from within the shader.

In previous versions, such as before v151, the aoMap utilized the second UV set, but now it’s using the first one. In the Shader Chunk “aomap_fragment.glsl.js”, the reference to vUv2 has been replaced with vAoMapUv, thus requiring the material property channel to be set to 1 instead of 0.

What I’m attempting to achieve is to blend two maps, where one uses the first UV set and the other uses the second UV set. Previously, I was able to accomplish this using vUv and vUv2. Could someone assist in how to achieve this with the updated changes?

Thank you!

1 Like

You can use:

To see the unrolled source code for the built in materials to determine which chunks / where you need to inject your changes to achieve the effect you want.

once you’ve identified what you need to change, you can use material.onBeforeCompile to hack the shader for a given material before it’s compiled, and inject your own functionality.