Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/scene/gsplat-unified/gsplat-work-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Frustum } from '../../core/shape/frustum.js';
import { Mat4 } from '../../core/math/mat4.js';
import { Vec2 } from '../../core/math/vec2.js';
import {
ADDRESS_CLAMP_TO_EDGE, PIXELFORMAT_R32U, PIXELFORMAT_RGBA16U, PIXELFORMAT_RGBA32F,
ADDRESS_CLAMP_TO_EDGE, PIXELFORMAT_R32U, PIXELFORMAT_RGBA8, PIXELFORMAT_RGBA16U, PIXELFORMAT_RGBA32F,
BUFFERUSAGE_COPY_DST, SEMANTIC_POSITION, getGlslShaderType
} from '../../platform/graphics/constants.js';
import { RenderTarget } from '../../platform/graphics/render-target.js';
Expand Down Expand Up @@ -262,7 +262,7 @@ class GSplatWorkBuffer {
name: 'SplatGlobalOrder',
width: 1,
height: 1,
format: PIXELFORMAT_R32U,
format: PIXELFORMAT_RGBA8,
mipmaps: false,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE
Expand Down
10 changes: 7 additions & 3 deletions src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ attribute vec3 vertex_position; // xy: cornerUV, z: render order offset
attribute uint vertex_id_attrib; // render order base

uniform uint numSplats; // total number of splats
uniform highp usampler2D splatOrder; // per-splat index to source gaussian
uniform highp sampler2D splatOrder; // per-splat index to source gaussian (RGBA8)

// initialize the splat source structure and global splat
bool initSource(out SplatSource source) {
Expand All @@ -17,8 +17,12 @@ bool initSource(out SplatSource source) {

ivec2 orderUV = ivec2(source.order % splatTextureSize, source.order / splatTextureSize);

// read splat id and initialize global splat for format read functions
uint splatId = texelFetch(splatOrder, orderUV, 0).r;
// read splat id: decode uint from RGBA8 normalized texel
vec4 orderBytes = texelFetch(splatOrder, orderUV, 0);
uint splatId = uint(orderBytes.r * 255.0 + 0.5) |
(uint(orderBytes.g * 255.0 + 0.5) << 8u) |
(uint(orderBytes.b * 255.0 + 0.5) << 16u) |
(uint(orderBytes.a * 255.0 + 0.5) << 24u);
setSplat(splatId);

// get the corner
Expand Down