Skip to content

fastExp implementation for gsplat rendering #7784

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

Merged
merged 3 commits into from
Jun 19, 2025

Conversation

slimbuck
Copy link
Member

This PR implements a fast approximation for the exp function and makes use of it in the gsplat shader for both WebGL and WebGPU.

Resulting images are unchanged, but we require more performance testing to determine the speed gain up on various devices. My macbook shows only a small speedup (< 1%), but the hope is larger speedups are found on lower end devices.

@slimbuck slimbuck requested review from a team and Copilot June 19, 2025 11:24
@slimbuck slimbuck self-assigned this Jun 19, 2025
Copy link
Contributor

@Copilot 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 a faster approximation of the exponential function (fastExp) and replaces the standard exp call in the gsplat fragment shaders for both WGSL and GLSL to improve rendering performance.

  • Introduces fastExp function with constants and bit-cast logic in WGSL and GLSL shader chunks.
  • Replaces exp(-A * 4.0) with fastExp(-A * 4.0) for alpha evaluation in both shader variants.

Reviewed Changes

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

File Description
src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplat.js Added fastExp implementation and replaced exp call.
src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplat.js Added fastExp implementation and replaced exp call.
Comments suppressed due to low confidence (2)

src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplat.js:22

  • [nitpick] Consider documenting the valid input range and expected approximation error of fastExp, and briefly explain how the bias constant is derived.
// Fast approximate e^x based on https://nic.schraudolph.org/pubs/Schraudolph99.pdf

src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplat.js:25

  • Add unit tests or shader benchmarks to validate fastExp accuracy against the standard exp over the intended input range.
fn fastExp(x: f32) -> f32 {

@slimbuck slimbuck merged commit 6b23191 into playcanvas:main Jun 19, 2025
7 checks passed
@slimbuck slimbuck deleted the fastexp-dev branch June 19, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants