Skip to content

Conversation

@slimbuck
Copy link
Member

Add 2D Gaussian Splatting (2DGS) Rendering Support

This PR adds support for rendering 2D Gaussian Splats using a new GSPLAT_2DGS shader define, similar to the existing GSPLAT_AA define.

Summary

  • Add GSPLAT_2DGS conditional rendering path for 2D Gaussian Splatting
  • Implement oriented quad corner calculation in model space using direct quaternion-vector rotation
  • Change SplatCorner.offset from vec2 to vec3 to support both 3DGS (clip-space XY) and 2DGS (model-space XYZ)
  • Extract 2DGS corner calculation into dedicated initCorner2DGS function

Technical Details

2DGS Rendering Approach:

  • 2DGS splats are rendered as oriented 3D quads in model space
  • Corner positions are computed by scaling the quad by 3σ (3-sigma coverage) and rotating using the splat's quaternion
  • The GPU's hardware rasterizer handles perspective projection, eliminating the need for covariance-based screen-space projection

Quaternion Rotation:
Uses direct quaternion-vector rotation formula (faster than matrix conversion):

vec3 t = 2.0 * cross(rotation.xyz, v);
corner.offset = v + rotation.w * t + cross(rotation.xyz, t);

Public API Changes

New Shader Define:

  • GSPLAT_2DGS - When enabled, uses the 2DGS oriented quad rendering path instead of the 3DGS covariance-based path

Struct Change:

  • SplatCorner.offset: Changed from vec2/vec2f to vec3/vec3f
    • 3DGS: Uses XY for clip-space offset, Z is 0
    • 2DGS: Uses XYZ for model-space offset

Files Changed

  • src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatStructs.js
  • src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatCorner.js
  • src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplat.js
  • src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatStructs.js
  • src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatCorner.js
  • src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplat.js

Test Plan

  • Verify 3DGS rendering is unchanged (no regressions)
  • Enable GSPLAT_2DGS define and verify 2DGS splats render correctly
  • Test rotation correctness with various quaternion orientations
  • Verify WebGL2 and WebGPU backends both work correctly

@slimbuck slimbuck requested review from a team and Copilot January 28, 2026 15:33
@slimbuck slimbuck self-assigned this Jan 28, 2026
@slimbuck slimbuck added the enhancement Request for a new feature label Jan 28, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for 2D Gaussian Splatting (2DGS) rendering by introducing a new GSPLAT_2DGS shader define. The implementation renders splats as oriented 3D quads in model space using quaternion rotation, contrasting with the existing 3DGS approach which uses covariance-based screen-space projection.

Changes:

  • Added GSPLAT_2DGS conditional compilation path for 2D Gaussian Splatting
  • Changed SplatCorner.offset from vec2/vec2f to vec3/vec3f to accommodate both clip-space (3DGS) and model-space (2DGS) offsets
  • Implemented initCorner2DGS function for computing oriented quad corners using direct quaternion-vector rotation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatStructs.js Updated SplatCorner.offset type from vec2f to vec3f with updated comment
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplatCorner.js Added initCorner2DGS function and updated initCornerCov to use vec3f offset
src/scene/shader-lib/wgsl/chunks/gsplat/vert/gsplat.js Added conditional 2DGS rendering path with model-space corner projection
src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatStructs.js Updated SplatCorner.offset type from vec2 to vec3 with updated comment
src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplatCorner.js Added initCorner2DGS function and updated initCornerCov to use vec3 offset
src/scene/shader-lib/glsl/chunks/gsplat/vert/gsplat.js Added conditional 2DGS rendering path with model-space corner projection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slimbuck slimbuck merged commit 82dbbad into playcanvas:main Jan 28, 2026
12 of 13 checks passed
@slimbuck slimbuck deleted the 2dgs-dev branch January 28, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants