UNPKG

@three.ez/instanced-mesh

Version:

Enhanced InstancedMesh with frustum culling, fast raycasting (using BVH), sorting, visibility management and more.

19 lines (18 loc) 685 B
export default /* glsl */ ` #ifdef USE_INSTANCING_INDIRECT attribute uint instanceIndex; uniform highp sampler2D matricesTexture; mat4 getInstancedMatrix() { int size = textureSize( matricesTexture, 0 ).x; int j = int( instanceIndex ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( matricesTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( matricesTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( matricesTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( matricesTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif `; //# sourceMappingURL=instanced_pars_vertex.glsl.js.map