ThreeJS UV先偏移再旋转缩放 矩阵

353 阅读1分钟
  • 4x4矩阵默认是旋转,缩放再偏移
  • 要改成先偏移再旋转,需要修改
  • 这个是顶点着色器的UV修改
#ifdef USE_UV
    #ifdef PHYSICAL //只是物理材质用先偏移的方式
        vUv = vec2( uv.x - uvScale.x, uv.y - uvScale.y );  //uvScale是偏移
        vUv = (uvTransform * vec3(vUv, 1.)).xy;
    #else
        vUv = ( uvTransform * vec3( uv.x * uvScale.x, uv.y * uvScale.y, 1.0 ) ).xy; //uvScale是缩放
    #endif
#endif