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.

169 lines (163 loc) 6.7 kB
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 { h as helperFunctionsWGSL } from './helperFunctions-CiGzvr6_.esm.js'; import { s as sceneUboDeclarationWGSL } from './sceneUboDeclaration-F06dki1D.esm.js'; import { m as meshUboDeclarationWGSL } from './meshUboDeclaration-CCr-qXSL.esm.js'; import { c as clipPlaneVertexDeclarationWGSL, a as clipPlaneVertexWGSL } from './clipPlaneVertex-DrcLG8k3.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'; // Do not edit. const name$3 = "shadowMapVertexExtraDeclaration"; const shader$3 = `#if SM_NORMALBIAS==1 uniform lightDataSM: vec3f; #endif uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f;varying vDepthMetricSM: f32; #if SM_USEDISTANCE==1 varying vPositionWSM: vec3f; #endif #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 varying zSM: f32; #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$3]) { ShaderStore.IncludesShadersStoreWGSL[name$3] = shader$3; } /** @internal */ const shadowMapVertexExtraDeclarationWGSL = { name: name$3, shader: shader$3 }; // Do not edit. const name$2 = "shadowMapVertexNormalBias"; const shader$2 = `#if SM_NORMALBIAS==1 #if SM_DIRECTIONINLIGHTDATA==1 var worldLightDirSM: vec3f=normalize(-uniforms.lightDataSM.xyz); #else var directionToLightSM: vec3f=uniforms.lightDataSM.xyz-worldPos.xyz;var worldLightDirSM: vec3f=normalize(directionToLightSM); #endif var ndlSM: f32=dot(vNormalW,worldLightDirSM);var sinNLSM: f32=sqrt(1.0-ndlSM*ndlSM);var normalBiasSM: f32=uniforms.biasAndScaleSM.y*sinNLSM;worldPos=vec4f(worldPos.xyz-vNormalW*normalBiasSM,worldPos.w); #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$2]) { ShaderStore.IncludesShadersStoreWGSL[name$2] = shader$2; } /** @internal */ const shadowMapVertexNormalBiasWGSL = { name: name$2, shader: shader$2 }; // Do not edit. const name$1 = "shadowMapVertexMetric"; const shader$1 = `#if SM_USEDISTANCE==1 vertexOutputs.vPositionWSM=worldPos.xyz; #endif #if SM_DEPTHTEXTURE==1 #ifdef IS_NDC_HALF_ZRANGE #define BIASFACTOR 0.5 #else #define BIASFACTOR 1.0 #endif #ifdef USE_REVERSE_DEPTHBUFFER vertexOutputs.position.z-=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR; #else vertexOutputs.position.z+=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR; #endif #endif #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 vertexOutputs.zSM=vertexOutputs.position.z;vertexOutputs.position.z=0.0; #elif SM_USEDISTANCE==0 #ifdef USE_REVERSE_DEPTHBUFFER vertexOutputs.vDepthMetricSM=(-vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; #else vertexOutputs.vDepthMetricSM=(vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; #endif #endif `; // Sideeffect if (!ShaderStore.IncludesShadersStoreWGSL[name$1]) { ShaderStore.IncludesShadersStoreWGSL[name$1] = shader$1; } /** @internal */ const shadowMapVertexMetricWGSL = { name: name$1, shader: shader$1 }; // Do not edit. const name = "shadowMapVertexShader"; const shader = `attribute position: vec3f; #ifdef NORMAL attribute normal: vec3f; #endif #include<bonesDeclaration> #include<bakedVertexAnimationDeclaration> #include<morphTargetsVertexGlobalDeclaration> #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets] #ifdef INSTANCES attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f; #endif #include<helperFunctions> #include<sceneUboDeclaration> #include<meshUboDeclaration> #ifdef ALPHATEXTURE varying vUV: vec2f;uniform diffuseMatrix: mat4x4f; #ifdef UV1 attribute uv: vec2f; #endif #ifdef UV2 attribute uv2: vec2f; #endif #endif #include<shadowMapVertexExtraDeclaration> #include<clipPlaneVertexDeclaration> #define CUSTOM_VERTEX_DEFINITIONS @vertex fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position; #ifdef UV1 var uvUpdated: vec2f=vertexInputs.uv; #endif #ifdef UV2 var uv2Updated: vec2f=vertexInputs.uv2; #endif #ifdef NORMAL var normalUpdated: vec3f=vertexInputs.normal; #endif #include<morphTargetsVertexGlobal> #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets] #include<instancesVertex> #include<bonesVertex> #include<bakedVertexAnimation> var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0); #ifdef NORMAL var normWorldSM: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz); #if defined(INSTANCES) && defined(THIN_INSTANCES) var vNormalW: vec3f=normalUpdated/ vec3f(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW); #else #ifdef NONUNIFORMSCALING normWorldSM=transposeMat3(inverseMat3(normWorldSM)); #endif var vNormalW: vec3f=normalize(normWorldSM*normalUpdated); #endif #endif #include<shadowMapVertexNormalBias> vertexOutputs.position=scene.viewProjection*worldPos; #include<shadowMapVertexMetric> #ifdef ALPHATEXTURE #ifdef UV1 vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy; #endif #ifdef UV2 vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; #endif #endif #include<clipPlaneVertex> }`; // Sideeffect if (!ShaderStore.ShadersStoreWGSL[name]) { ShaderStore.ShadersStoreWGSL[name] = shader; } const includes = [bonesDeclarationWGSL, bakedVertexAnimationDeclarationWGSL, morphTargetsVertexGlobalDeclarationWGSL, morphTargetsVertexDeclarationWGSL, helperFunctionsWGSL, sceneUboDeclarationWGSL, meshUboDeclarationWGSL, shadowMapVertexExtraDeclarationWGSL, clipPlaneVertexDeclarationWGSL, morphTargetsVertexGlobalWGSL, morphTargetsVertexWGSL, instancesVertexWGSL, bonesVertexWGSL, bakedVertexAnimationWGSL, shadowMapVertexNormalBiasWGSL, shadowMapVertexMetricWGSL, clipPlaneVertexWGSL]; for (const inc of includes) { if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) { ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader; } } /** @internal */ const shadowMapVertexShaderWGSL = { name, shader }; export { shadowMapVertexShaderWGSL }; //# sourceMappingURL=shadowMap.vertex-DTe0T4wb.esm.js.map