UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

49 lines 3.02 kB
// Do not edit. import { ShaderStore } from "../Engines/shaderStore.js"; import { sceneUboDeclarationWGSL } from "./ShadersInclude/sceneUboDeclaration.js"; import { meshUboDeclarationWGSL } from "./ShadersInclude/meshUboDeclaration.js"; import { gaussianSplattingWGSL } from "./ShadersInclude/gaussianSplatting.js"; const name = "gaussianSplattingVoxelVertexShader"; const shader = `#include<sceneUboDeclaration> #include<meshUboDeclaration> attribute splatIndex0: vec4f;attribute splatIndex1: vec4f;attribute splatIndex2: vec4f;attribute splatIndex3: vec4f;attribute position: vec3f;uniform dataTextureSize: vec2f;uniform alpha: f32;uniform invWorldScale: mat4x4f;uniform viewMatrix: mat4x4f; #if IS_COMPOUND uniform partWorld: array<mat4x4<f32>,MAX_PART_COUNT>;uniform partVisibility: array<f32,MAX_PART_COUNT>; #endif var rotationsATexture: texture_2d<f32>;var rotationsBTexture: texture_2d<f32>;var rotationScaleTexture: texture_2d<f32>;var centersTexture: texture_2d<f32>;var colorsTexture: texture_2d<f32>; #if IS_COMPOUND var partIndicesTexture: texture_2d<f32>; #endif varying vNormalizedPosition: vec3f;varying vNormalizedCenterPosition: vec3f;varying vAlpha: f32;varying vPatchPosition: vec2f; #include<gaussianSplatting> @vertex fn main(input: VertexInputs)->FragmentInputs {let splatIndex: f32=getSplatIndex( i32(vertexInputs.position.z+0.5), vertexInputs.splatIndex0,vertexInputs.splatIndex1, vertexInputs.splatIndex2,vertexInputs.splatIndex3 );var splat: Splat=readSplat(splatIndex,uniforms.dataTextureSize); #if IS_COMPOUND if (uniforms.partVisibility[splat.partIndex]==0.0) {vertexOutputs.position=vec4f(2.0,2.0,2.0,1.0);return vertexOutputs;} let splatWorld: mat4x4f=getPartWorld(splat.partIndex); #else let splatWorld: mat4x4f=mesh.world; #endif let quadPos: vec2f=vertexInputs.position.xy;let worldPos: vec4f=computeVoxelSplatWorldPos(splat.rotationA,splat.rotationB,splat.rotationScale,splat.center.xyz,splatWorld,uniforms.viewMatrix,uniforms.invWorldScale,quadPos);vertexOutputs.vNormalizedPosition=(uniforms.invWorldScale*worldPos).xyz*0.5+0.5;let clipPos: vec4f=uniforms.viewMatrix*uniforms.invWorldScale*worldPos;vertexOutputs.position=vec4f(clipPos.x,clipPos.y,clipPos.z*0.5+0.5,1.0);vertexOutputs.vNormalizedCenterPosition=(uniforms.invWorldScale*splatWorld*vec4f(splat.center.xyz,1.0)).xyz*0.5+0.5;vertexOutputs.vAlpha=splat.color.w*uniforms.alpha; #if IS_COMPOUND vertexOutputs.vAlpha*=uniforms.partVisibility[splat.partIndex]; #endif vertexOutputs.vPatchPosition=quadPos;} `; // Sideeffect if (!ShaderStore.ShadersStoreWGSL[name]) { ShaderStore.ShadersStoreWGSL[name] = shader; } const includes = [sceneUboDeclarationWGSL, meshUboDeclarationWGSL, gaussianSplattingWGSL]; for (const inc of includes) { if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) { ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader; } } /** @internal */ export const gaussianSplattingVoxelVertexShaderWGSL = { name, shader }; //# sourceMappingURL=gaussianSplattingVoxel.vertex.js.map