Skip to content

WebGPUPathTracer: Add support for opacity during BVH traversal#751

Open
gkjohnson wants to merge 8 commits intowebgpu-pathtracerfrom
webgpu/transparency
Open

WebGPUPathTracer: Add support for opacity during BVH traversal#751
gkjohnson wants to merge 8 commits intowebgpu-pathtracerfrom
webgpu/transparency

Conversation

@gkjohnson
Copy link
Copy Markdown
Owner

@gkjohnson gkjohnson commented Mar 22, 2026

  • Add a 1D PCG random function
  • Merge the "hit" and "ray" queues to free up a storage buffer slot
  • Check the opacity of the object material on triangle intersection, continue traversal if transparent
  • Skip traversal of the object entirely if opacity is set to 0

This should reduce the number of raycasts required for transparent surfaces.

Future

  • Sample and include albedo and alpha map opacity
  • We could handle triangle sided-ness this way, as well?

cc @TheBlek

image

# Conflicts:
#	src/webgpu/lib/BVHComputeData.js
Comment on lines +89 to +93
let tMinHit = vec3f(
min( tMinPlane.x, tMaxPlane.x ),
min( tMinPlane.y, tMaxPlane.y ),
min( tMinPlane.z, tMaxPlane.z )
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

fyi: min supports vector operations so this can be written as let tMinHit = min( tMinPlane, tMaxPlane );

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Thanks! Fixed. I'll wait to merge this PR until #717 is done to avoid and potential conflicts

@gkjohnson gkjohnson mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants