UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

155 lines (149 loc) 5.24 kB
import { S as ShaderStore } from './index-MZPybX0H.esm.js'; // Do not edit. const name$3 = "morphTargetsVertexGlobalDeclaration"; const shader$3 = `#ifdef MORPHTARGETS uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS]; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex) { #if defined(WEBGL2) || defined(WEBGPU) int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0).xyz; #else float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz; #endif } vec4 readVector4FromRawSampler(int targetIndex,float vertexIndex) { #if defined(WEBGL2) || defined(WEBGPU) int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0); #else float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV); #endif } #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStore[name$3]) { ShaderStore.IncludesShadersStore[name$3] = shader$3; } /** @internal */ const morphTargetsVertexGlobalDeclaration = { name: name$3, shader: shader$3 }; // Do not edit. const name$2 = "morphTargetsVertexDeclaration"; const shader$2 = `#ifdef MORPHTARGETS #ifndef MORPHTARGETS_TEXTURE #ifdef MORPHTARGETS_POSITION attribute vec3 position{X}; #endif #ifdef MORPHTARGETS_NORMAL attribute vec3 normal{X}; #endif #ifdef MORPHTARGETS_TANGENT attribute vec3 tangent{X}; #endif #ifdef MORPHTARGETS_UV attribute vec2 uv_{X}; #endif #ifdef MORPHTARGETS_UV2 attribute vec2 uv2_{X}; #endif #ifdef MORPHTARGETS_COLOR attribute vec4 color{X}; #endif #elif {X}==0 uniform float morphTargetCount; #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStore[name$2]) { ShaderStore.IncludesShadersStore[name$2] = shader$2; } /** @internal */ const morphTargetsVertexDeclaration = { name: name$2, shader: shader$2 }; // Do not edit. const name$1 = "morphTargetsVertexGlobal"; const shader$1 = `#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE float vertexID; #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStore[name$1]) { ShaderStore.IncludesShadersStore[name$1] = shader$1; } /** @internal */ const morphTargetsVertexGlobal = { name: name$1, shader: shader$1 }; // Do not edit. const name = "morphTargetsVertex"; const shader = `#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE #if {X}==0 for (int i=0; i<NUM_MORPH_INFLUENCERS; i++) {if (float(i)>=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x; #ifdef MORPHTARGETS_POSITION positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASPOSITIONS vertexID+=1.0; #endif #ifdef MORPHTARGETS_NORMAL normalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASNORMALS vertexID+=1.0; #endif #ifdef MORPHTARGETS_UV uvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASUVS vertexID+=1.0; #endif #ifdef MORPHTARGETS_TANGENT tangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASTANGENTS vertexID+=1.0; #endif #ifdef MORPHTARGETS_UV2 uv2Updated+=(readVector3FromRawSampler(i,vertexID).xy-uv2)*morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASUV2S vertexID+=1.0; #endif #ifdef MORPHTARGETS_COLOR colorUpdated+=(readVector4FromRawSampler(i,vertexID)-color)*morphTargetInfluences[i]; #endif } #endif #else #ifdef MORPHTARGETS_POSITION positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_NORMAL normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_TANGENT tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_UV uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_UV2 uv2Updated+=(uv2_{X}-uv2)*morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_COLOR colorUpdated+=(color{X}-color)*morphTargetInfluences[{X}]; #endif #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStore[name]) { ShaderStore.IncludesShadersStore[name] = shader; } /** @internal */ const morphTargetsVertex = { name, shader }; export { morphTargetsVertexDeclaration as a, morphTargetsVertexGlobal as b, morphTargetsVertex as c, morphTargetsVertexGlobalDeclaration as m }; //# sourceMappingURL=morphTargetsVertex-BRsti3ha.esm.js.map