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.

133 lines (128 loc) 5.08 kB
import { S as ShaderStore } from './index-FzOfPXLV.esm.js'; // Do not edit. const name$3 = "morphTargetsVertexGlobalDeclaration"; const shader$3 = `#ifdef MORPHTARGETS uniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>; #ifdef MORPHTARGETS_TEXTURE uniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;uniform morphTargetTextureInfo : vec3<f32>;var morphTargets : texture_2d_array<f32>;var morphTargetsSampler : sampler;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3<f32> { let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;} fn readVector4FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec4<f32> { let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0);} #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$3]) { ShaderStore.IncludesShadersStoreWGSL[name$3] = shader$3; } // Do not edit. const name$2 = "morphTargetsVertexDeclaration"; const shader$2 = `#ifdef MORPHTARGETS #ifndef MORPHTARGETS_TEXTURE #ifdef MORPHTARGETS_POSITION attribute position{X} : vec3<f32>; #endif #ifdef MORPHTARGETS_NORMAL attribute normal{X} : vec3<f32>; #endif #ifdef MORPHTARGETS_TANGENT attribute tangent{X} : vec3<f32>; #endif #ifdef MORPHTARGETS_UV attribute uv_{X} : vec2<f32>; #endif #ifdef MORPHTARGETS_UV2 attribute uv2_{X} : vec2<f32>; #endif #ifdef MORPHTARGETS_COLOR attribute color{X} : vec4<f32>; #endif #elif {X}==0 uniform morphTargetCount: i32; #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$2]) { ShaderStore.IncludesShadersStoreWGSL[name$2] = shader$2; } // Do not edit. const name$1 = "morphTargetsVertexGlobal"; const shader$1 = `#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE var vertexID : f32; #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$1]) { ShaderStore.IncludesShadersStoreWGSL[name$1] = shader$1; } // Do not edit. const name = "morphTargetsVertex"; const shader = `#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE #if {X}==0 for (var i=0; i<NUM_MORPH_INFLUENCERS; i=i+1) {if (i>=uniforms.morphTargetCount) {break;} vertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x; #ifdef MORPHTARGETS_POSITION positionUpdated=positionUpdated+(readVector3FromRawSampler(i,vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASPOSITIONS vertexID=vertexID+1.0; #endif #ifdef MORPHTARGETS_NORMAL normalUpdated=normalUpdated+(readVector3FromRawSampler(i,vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASNORMALS vertexID=vertexID+1.0; #endif #ifdef MORPHTARGETS_UV uvUpdated=uvUpdated+(readVector3FromRawSampler(i,vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[i]; #endif #ifdef MORPHTARGETTEXTURE_HASUVS vertexID=vertexID+1.0; #endif #ifdef MORPHTARGETS_TANGENT tangentUpdated=vec4f(tangentUpdated.xyz+(readVector3FromRawSampler(i,vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[i],tangentUpdated.a); #endif #ifdef MORPHTARGETTEXTURE_HASTANGENTS vertexID=vertexID+1.0; #endif #ifdef MORPHTARGETS_UV2 uv2Updated=uv2Updated+(readVector3FromRawSampler(i,vertexID).xy-vertexInputs.uv2)*uniforms.morphTargetInfluences[i]; #endif #ifdef MORPHTARGETS_COLOR colorUpdated=colorUpdated+(readVector4FromRawSampler(i,vertexID)-vertexInputs.color)*uniforms.morphTargetInfluences[i]; #endif } #endif #else #ifdef MORPHTARGETS_POSITION positionUpdated=positionUpdated+(vertexInputs.position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_NORMAL normalUpdated=normalUpdated+(vertexInputs.normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_TANGENT tangentUpdated=vec4f(tangentUpdated.xyz+(vertexInputs.tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}],tangentUpdated.a); #endif #ifdef MORPHTARGETS_UV uvUpdated=uvUpdated+(vertexInputs.uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_UV2 uv2Updated=uv2Updated+(vertexInputs.uv2_{X}-vertexInputs.uv2)*uniforms.morphTargetInfluences[{X}]; #endif #ifdef MORPHTARGETS_COLOR colorUpdated=colorUpdated+(vertexInputs.color{X}-vertexInputs.color)*uniforms.morphTargetInfluences[{X}]; #endif #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name]) { ShaderStore.IncludesShadersStoreWGSL[name] = shader; } //# sourceMappingURL=morphTargetsVertex-C_o673bp.esm.js.map