|
@@ -5,27 +5,19 @@ export default /* glsl */`
|
|
|
uniform mat4 bindMatrixInverse;
|
|
|
|
|
|
uniform highp sampler2D boneTexture;
|
|
|
- uniform int boneTextureSize;
|
|
|
|
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
|
|
|
|
- float j = i * 4.0;
|
|
|
- float x = mod( j, float( boneTextureSize ) );
|
|
|
- float y = floor( j / float( boneTextureSize ) );
|
|
|
+ int size = textureSize( boneTexture, 0 ).x;
|
|
|
+ int j = int( i ) * 4;
|
|
|
+ int x = j % size;
|
|
|
+ int y = j / size;
|
|
|
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
|
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
|
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
|
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
|
|
|
|
- float dx = 1.0 / float( boneTextureSize );
|
|
|
- float dy = 1.0 / float( boneTextureSize );
|
|
|
-
|
|
|
- y = dy * ( y + 0.5 );
|
|
|
-
|
|
|
- vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
|
|
- vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
|
|
- vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
|
|
- vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
|
|
-
|
|
|
- mat4 bone = mat4( v1, v2, v3, v4 );
|
|
|
-
|
|
|
- return bone;
|
|
|
+ return mat4( v1, v2, v3, v4 );
|
|
|
|
|
|
}
|
|
|
|