Browse Source

WebGLRenderer: Use texelFetch() to sample morph target texture. (#23727)

* WebGLRenderer: Use texelFetch() to sample morph target texture.

* Simplify shader.
Michael Herzog 3 years ago
parent
commit
3fcefcc232
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js

+ 6 - 6
src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js

@@ -7,16 +7,16 @@ export default /* glsl */`
 
 		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
 		uniform sampler2DArray morphTargetsTexture;
-		uniform vec2 morphTargetsTextureSize;
+		uniform ivec2 morphTargetsTextureSize;
 
 		vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
 
-			float texelIndex = float( vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset );
-			float y = floor( texelIndex / morphTargetsTextureSize.x );
-			float x = texelIndex - y * morphTargetsTextureSize.x;
+			int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
+			int y = texelIndex / morphTargetsTextureSize.x;
+			int x = texelIndex - y * morphTargetsTextureSize.x;
 
-			vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );
-			return texture( morphTargetsTexture, morphUV );
+			ivec3 morphUV = ivec3( x, y, morphTargetIndex );
+			return texelFetch( morphTargetsTexture, morphUV, 0 );
 
 		}