From 68b5ef3495de3389f722d086ab19dca912f8b3db Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Thu, 1 Feb 2024 12:47:40 +0000 Subject: [PATCH] GSplat mateirlal can create a PICK shader pass version of the shader --- src/scene/gsplat/shader-generator-gsplat.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/scene/gsplat/shader-generator-gsplat.js b/src/scene/gsplat/shader-generator-gsplat.js index b9883ace9b5..4dd882bc522 100644 --- a/src/scene/gsplat/shader-generator-gsplat.js +++ b/src/scene/gsplat/shader-generator-gsplat.js @@ -4,6 +4,7 @@ import { ShaderUtils } from "../../platform/graphics/shader-utils.js"; import { DITHER_NONE } from "../constants.js"; import { shaderChunks } from "../shader-lib/chunks/chunks.js"; import { ShaderGenerator } from "../shader-lib/programs/shader-generator.js"; +import { ShaderPass } from "../shader-pass.js"; const splatCoreVS = ` attribute vec3 vertex_position; @@ -233,6 +234,10 @@ const splatCoreFS = /* glsl_ */ ` varying vec4 color; varying float id; + #ifdef PICK_PASS + uniform vec4 uColor; + #endif + vec4 evalSplat() { #ifdef DEBUG_RENDER @@ -246,6 +251,11 @@ const splatCoreFS = /* glsl_ */ ` if (A < -4.0) discard; float B = exp(A) * color.a; + #ifdef PICK_PASS + if (B < 0.3) discard; + return(uColor); + #endif + #ifndef DITHER_NONE opacityDither(B, id * 0.013); #endif @@ -272,7 +282,11 @@ class GShaderGeneratorSplat { createShaderDefinition(device, options) { + const shaderPassInfo = ShaderPass.get(device).getByIndex(options.pass); + const shaderPassDefines = shaderPassInfo.shaderDefines; + const defines = + shaderPassDefines + (options.debugRender ? '#define DEBUG_RENDER\n' : '') + (device.isWebGL1 ? '' : '#define INT_INDICES\n') + `#define DITHER_${options.dither.toUpperCase()}\n`;