未验证 提交 f8f62656 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #18099 from zeux/uv2-matrix

Implement support for texture matrix for uv2
......@@ -2161,6 +2161,40 @@ function WebGLRenderer( parameters ) {
}
// uv repeat and offset setting priorities for uv2
// 1. ao map
// 2. light map
var uv2ScaleMap;
if ( material.aoMap ) {
uv2ScaleMap = material.aoMap;
} else if ( material.lightMap ) {
uv2ScaleMap = material.lightMap;
}
if ( uvScaleMap !== undefined ) {
// backwards compatibility
if ( uv2ScaleMap.isWebGLRenderTarget ) {
uv2ScaleMap = uv2ScaleMap.texture;
}
if ( uv2ScaleMap.matrixAutoUpdate === true ) {
uv2ScaleMap.updateMatrix();
}
uniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );
}
}
function refreshUniformsLine( uniforms, material ) {
......
......@@ -4,5 +4,7 @@ export default /* glsl */`
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
#endif
`;
export default /* glsl */`
#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
vUv2 = uv2;
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif
`;
......@@ -8,6 +8,7 @@ export let UniformsLib: {
opacity: IUniform;
map: IUniform;
uvTransform: IUniform;
uv2Transform: IUniform;
alphaMap: IUniform;
};
specularmap: {
......
......@@ -15,6 +15,7 @@ var UniformsLib = {
map: { value: null },
uvTransform: { value: new Matrix3() },
uv2Transform: { value: new Matrix3() },
alphaMap: { value: null },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册