@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.
175 lines (169 loc) • 7.32 kB
JavaScript
import { S as ShaderStore } from './index-FzOfPXLV.esm.js';
// Do not edit.
const name$4 = "bonesDeclaration";
const shader$4 = `
attribute vec4 matricesIndices;attribute vec4 matricesWeights;
attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;
uniform highp sampler2D boneSampler;uniform float boneTextureWidth;
uniform mat4 mBones[BonesPerMesh];
uniform mat4 mPreviousBones[BonesPerMesh];
mat4 readMatrixFromRawSampler(sampler2D smp,float index)
{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);}
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name$4]) {
ShaderStore.IncludesShadersStore[name$4] = shader$4;
}
// Do not edit.
const name$3 = "bakedVertexAnimationDeclaration";
const shader$3 = `
uniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;
attribute vec4 bakedVertexAnimationSettingsInstanced;
mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);}
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name$3]) {
ShaderStore.IncludesShadersStore[name$3] = shader$3;
}
// Do not edit.
const name$2 = "instancesVertex";
const shader$2 = `
mat4 finalWorld=mat4(world0,world1,world2,world3);
mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,
previousWorld2,previousWorld3);
finalWorld=world*finalWorld;
finalPreviousWorld=previousWorld*finalPreviousWorld;
mat4 finalWorld=world;
mat4 finalPreviousWorld=previousWorld;
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name$2]) {
ShaderStore.IncludesShadersStore[name$2] = shader$2;
}
// Do not edit.
const name$1 = "bonesVertex";
const shader$1 = `
mat4 influence;
influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
finalWorld=finalWorld*influence;
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name$1]) {
ShaderStore.IncludesShadersStore[name$1] = shader$1;
}
// Do not edit.
const name = "bakedVertexAnimation";
const shader = `
{
float VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
finalWorld=finalWorld*VATInfluence;}
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name]) {
ShaderStore.IncludesShadersStore[name] = shader;
}
//# sourceMappingURL=bakedVertexAnimation-D5Wmzm8F.esm.js.map