@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.
205 lines (198 loc) • 8.7 kB
JavaScript
import { S as ShaderStore } from './index-MZPybX0H.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 vec2 boneTextureInfo;
uniform mat4 mBones[BonesPerMesh];
uniform mat4 mPreviousBones[BonesPerMesh];
mat4 readMatrixFromRawSampler(sampler2D smp,float index)
{
int offset=int(index)*4;
int textureWidth=int(boneTextureInfo.x);int y=int(offset)/textureWidth;int x=int(offset) % textureWidth;vec4 m0=texelFetch(smp,ivec2(x+0,y),0);vec4 m1=texelFetch(smp,ivec2(x+1,y),0);vec4 m2=texelFetch(smp,ivec2(x+2,y),0);vec4 m3=texelFetch(smp,ivec2(x+3,y),0);return mat4(m0,m1,m2,m3);
float offset=index*4.0;float y=floor(offset/boneTextureInfo.x);float x=offset-y*boneTextureInfo.x;float dy=1.0/boneTextureInfo.y;float dx=1.0/boneTextureInfo.x;vec4 m0=texture2D(smp,vec2(dx*(x+0.5),dy*(y+0.5)));vec4 m1=texture2D(smp,vec2(dx*(x+1.5),dy*(y+0.5)));vec4 m2=texture2D(smp,vec2(dx*(x+2.5),dy*(y+0.5)));vec4 m3=texture2D(smp,vec2(dx*(x+3.5),dy*(y+0.5)));
return mat4(m0,m1,m2,m3);
}
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStore[name$4]) {
ShaderStore.IncludesShadersStore[name$4] = shader$4;
}
/** @internal */
const bonesDeclaration = { name: name$4, shader: 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)
{
int offset=int(index)*4;int frameUV=int(frame);vec4 m0=texelFetch(smp,ivec2(offset+0,frameUV),0);vec4 m1=texelFetch(smp,ivec2(offset+1,frameUV),0);vec4 m2=texelFetch(smp,ivec2(offset+2,frameUV),0);vec4 m3=texelFetch(smp,ivec2(offset+3,frameUV),0);return mat4(m0,m1,m2,m3);
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;
}
/** @internal */
const bakedVertexAnimationDeclaration = { name: name$3, shader: 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;
}
/** @internal */
const instancesVertex = { name: name$2, shader: 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;
}
/** @internal */
const bonesVertex = { name: name$1, shader: 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;
}
/** @internal */
const bakedVertexAnimation = { name, shader };
export { bakedVertexAnimationDeclaration as a, bonesDeclaration as b, bonesVertex as c, bakedVertexAnimation as d, instancesVertex as i };
//# sourceMappingURL=bakedVertexAnimation-wpiWOSwD.esm.js.map