Skip to content

Clean up Custom Shader inputs for voxel rendering #12636

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 14 commits into from
Jun 2, 2025
Merged

Clean up Custom Shader inputs for voxel rendering #12636

merged 14 commits into from
Jun 2, 2025

Conversation

Image for: Conversation
Copy link
Contributor

jjhembd commented May 27, 2025

Description

This PR cleans up the FragmentInput struct for voxel custom shaders, to be more consistent with other uses of CustomShader and the Custom Shader Guide.

Key changes include:

  • Moved metadata statistics to a higher-level fragmentInput.metadataStatistics sub-struct, instead of appending them to each metadata property in the fragmentInput.metadata struct. This brings voxel metadata up to date with the changes to Model metadata in Add shader struct with metadata statistics #10683.
  • Added the fragmentInput.attributes sub-struct. It currently only contains positionEC and normalEC.
  • Removed several unused properties from the fragmentInput.voxel sub-struct.
  • Added the property fragmentInput.voxel.distanceToDepthBuffer as a first step toward resolving Access both voxels and mesh surfaces from a custom shader #12599
  • Cleaned up obsolete uniforms and transforms in VoxelPrimitive

Issue number and link

Image for: Issue number and link

Resolves #11832.

Testing plan

Image for: Testing plan

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code
Copy link

Thank you for the pull request, @jjhembd!

✅ We can confirm we have a CLA on file for you.

jjhembd marked this pull request as ready for review May 29, 2025 22:52
Copy link
Contributor Author

jjhembd commented May 29, 2025

As part of addressing #12599, FragmentInput.voxel now includes a distanceToDepthBuffer property, indicating the distance from the current raymarching position to the currently loaded depth buffer. The depth value will represent the distance to the nearest rendered pixel from the terrain and any Cesium3DTilesets in the Scene.

Here is a basic local Sandcastle rendering the value of the new depth property.

Copy link
Contributor

ggetz left a comment

Choose a reason for hiding this comment

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

Overall this is looking great @jjhembd. I left one comment to make sure we are providing any existing users with the info they need to update.

I also pushed a small update which linked to the custom shader guide from the inline ref doc, just to make sure the dots are connected.

CHANGES.md Outdated
@@ -4,6 +4,10 @@

### @cesium/engine

#### Breaking Changes :mega:

- The `FragmentInput` struct for voxel shaders has been updated to be more consistent with the `CustomShader` documentation. Remaining differences in `CustomShader` usage between `VoxelPrimitive` and `Cesium3DTileset` or `Model` are now documented in the Custom Shader Guide. [#12636](https://github.com/CesiumGS/cesium/pull/12636)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we document a list (or if too long, an example or two) of what attributes changed so that users have a place to start when updating?

Copy link
Contributor Author

jjhembd commented Jun 2, 2025

@ggetz thanks for the feedback! I added info and an example to the CHANGES.md. This should be ready for another look.

Copy link
Contributor

ggetz commented Jun 2, 2025

Looks great! Thanks @jjhembd!

ggetz added this pull request to the merge queue Jun 2, 2025
Merged via the queue into main with commit 93bff98 Jun 2, 2025
9 checks passed
ggetz deleted the voxel-surfaces branch June 2, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants