Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSplat mateirlal can create a PICK shader pass version of the shader #6033

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/scene/gsplat/shader-generator-gsplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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`;
Expand Down