@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.
243 lines (240 loc) • 10.4 kB
JavaScript
import { S as ShaderStore } from './index-MZPybX0H.esm.js';
import { b as bonesDeclarationWGSL } from './bonesDeclaration-PMvyqkeE.esm.js';
import { b as bakedVertexAnimationDeclarationWGSL, i as instancesVertexWGSL } from './instancesVertex-DMZ4QPzF.esm.js';
import { m as morphTargetsVertexGlobalDeclarationWGSL, a as morphTargetsVertexDeclarationWGSL } from './morphTargetsVertexDeclaration-BiDnarww.esm.js';
import { i as instancesDeclarationWGSL } from './instancesDeclaration-BNVwxGTw.esm.js';
import { s as sceneUboDeclarationWGSL } from './sceneUboDeclaration-F06dki1D.esm.js';
import { c as clipPlaneVertexDeclarationWGSL, a as clipPlaneVertexWGSL } from './clipPlaneVertex-DrcLG8k3.esm.js';
import { h as harmonicsFunctionsWGSL } from './harmonicsFunctions-1JywfDMC.esm.js';
import { m as morphTargetsVertexGlobalWGSL, a as morphTargetsVertexWGSL } from './morphTargetsVertex-Cv-n_1Be.esm.js';
import { b as bonesVertexWGSL } from './bonesVertex-CJuJ5VLw.esm.js';
import { b as bakedVertexAnimationWGSL } from './bakedVertexAnimation-v7FGdAXH.esm.js';
import { b as bumpVertexWGSL } from './bumpVertex-CMrLLhgy.esm.js';
// Do not edit.
const name = "geometryVertexShader";
const shader = `
uniform reflectionMatrix: mat4x4f;uniform vReflectionInfos: vec2f;uniform vReflectionColor: vec3f;
varying vEnvironmentIrradiance: vec3f;
uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;
uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f;
attribute position : vec3<f32>;
attribute normal: vec3f;
varying vUV: vec2f;
uniform diffuseMatrix: mat4x4f;
uniform bumpMatrix: mat4x4f;varying vBumpUV: vec2f;
uniform reflectivityMatrix: mat4x4f;uniform albedoMatrix: mat4x4f;varying vReflectivityUV: vec2f;varying vAlbedoUV: vec2f;
varying vMetallicUV: vec2f;uniform metallicMatrix: mat4x4f;
varying vRoughnessUV: vec2f;uniform roughnessMatrix: mat4x4f;
varying vSubsurfaceWeightUV: vec2f;uniform subsurfaceWeightMatrix: mat4x4f;
varying vTransmissionWeightUV: vec2f;uniform transmissionWeightMatrix: mat4x4f;
attribute uv: vec2f;
attribute uv2: vec2f;
varying vWorldView0: vec4f;varying vWorldView1: vec4f;varying vWorldView2: vec4f;varying vWorldView3: vec4f;
varying vNormalW: vec3f;
varying vNormalV: vec3f;
varying vViewPos: vec4f;
varying vPositionW: vec3f;
uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
@vertex
fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position;
var normalUpdated: vec3f=vertexInputs.normal;
var normalUpdated: vec3f=vec3f(0.0,0.0,0.0);
var uvUpdated: vec2f=vertexInputs.uv;
var uv2Updated: vec2f=vertexInputs.uv2;
vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
var worldPos: vec4f= vec4f(finalWorld* vec4f(positionUpdated,1.0));
let vWorldView=scene.view*finalWorld;vertexOutputs.vWorldView0=vWorldView[0];vertexOutputs.vWorldView1=vWorldView[1];vertexOutputs.vWorldView2=vWorldView[2];vertexOutputs.vWorldView3=vWorldView[3];let normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated);
vertexOutputs.vNormalV=normalize((finalWorld* vec4f(normalUpdated,0.0)).xyz);
vertexOutputs.vNormalV=normalize(((scene.view*finalWorld)* vec4f(normalUpdated,0.0)).xyz);
vertexOutputs.vViewPos=scene.view*worldPos;
vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0);
var previousInfluence: mat4x4f;previousInfluence=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2];
previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3];
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*previousInfluence* vec4f(positionUpdated,1.0);
vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0);
vertexOutputs.vPositionW=worldPos.xyz/worldPos.w;
vertexOutputs.position=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0);
vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vUV=uvUpdated;
vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vMetallicUV=(uniforms.metallicMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vRoughnessUV=(uniforms.roughnessMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vSubsurfaceWeightUV=(uniforms.subsurfaceWeightMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vTransmissionWeightUV=(uniforms.transmissionWeightMatrix* vec4f(uvUpdated,1.0,0.0)).xy;
vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vUV=uv2Updated;
vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vMetallicUV=(uniforms.metallicMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vRoughnessUV=(uniforms.roughnessMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vSubsurfaceWeightUV=(uniforms.subsurfaceWeightMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
vertexOutputs.vTransmissionWeightUV=(uniforms.transmissionWeightMatrix* vec4f(uv2Updated,1.0,0.0)).xy;
var reflectionVector: vec3f=(uniforms.reflectionMatrix*vec4f(normalUpdated,0.0)).xyz;
reflectionVector.z*=-1.0f;
vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*uniforms.vReflectionInfos.x;
}
`;
// Sideeffect
if (!ShaderStore.ShadersStoreWGSL[name]) {
ShaderStore.ShadersStoreWGSL[name] = shader;
}
const includes = [bonesDeclarationWGSL, bakedVertexAnimationDeclarationWGSL, morphTargetsVertexGlobalDeclarationWGSL, morphTargetsVertexDeclarationWGSL, instancesDeclarationWGSL, sceneUboDeclarationWGSL, clipPlaneVertexDeclarationWGSL, harmonicsFunctionsWGSL, morphTargetsVertexGlobalWGSL, morphTargetsVertexWGSL, instancesVertexWGSL, bonesVertexWGSL, bakedVertexAnimationWGSL, clipPlaneVertexWGSL, bumpVertexWGSL];
for (const inc of includes) {
if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) {
ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader;
}
}
/** @internal */
const geometryVertexShaderWGSL = { name, shader };
export { geometryVertexShaderWGSL };
//# sourceMappingURL=geometry.vertex-UO0GJarf.esm.js.map