提交 203a7258 编写于 作者: A Arseny Kapoulkine

Implement support for texture matrix for uv2

Before this change, we only supported one texture matrix for the
material that was applied to uv data based on the first texture, in
priority order, that needed it.

This change adds equivalent support for uv2 - we now transform second UV
channel with a second UV transform that is grabbed from aoMap or
lightMap (that are the only two textures using it atm).

This fixes glTF rendering for files that use KHR_texture_transform on
the occlusion texture, including ones produced by gltfpack.
上级 3be67bd5
......@@ -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.
先完成此消息的编辑!
想要评论请 注册