Skip to content
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

Convert gsplat material to be chunk-based #7164

Merged
merged 19 commits into from
Dec 3, 2024

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented Dec 3, 2024

This PR:

  • unifies the compressed and uncompressed gaussian splat material
  • shaders leverage preprocessor #include and #if to organise shader code
  • supports custom chunk overrides

Chunk breakdown as follows:

  • Vertex shader:
    • gsplat: implements main(), common to compressed and uncompressed
    • gsplatCommon: common functionality like transforming gaussians 3d->2d and evaluating SH
    • gsplatData, gsplatSH, gsplatColor: uncompressed data access
    • gsplatCompressedData, gsplatCompressedSH: compressed data access
    • gsplatOutput: helper function for converting to target gamma space efficiently
  • Fragment shader:
    • gsplat: common to compressed and uncompressed

#endif

// prepare the output color for the given gamma-space color
vec3 prepareOutputFromGamma(vec3 gammaColor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this play with render passes? Don't render passes apply a tonemap as a post effect? Also, any reason not to apply fog?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently only standard-material supports fog, but I could add this to gsplat shader.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to support it. But I'm happy for that to be a follow up PR. We're still calling it out as a limitation in the docs after all: https://developer.playcanvas.com/user-manual/graphics/gaussian-splatting/#limitations

Copy link
Contributor

Choose a reason for hiding this comment

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

as long as the generator respects the related generation options (which it seems it is), it should work .. render passes pass the options they need

@@ -71,7 +71,6 @@ assetListLoader.load(() => {

// instantiate guitar with a custom shader
const guitar = assets.guitar.resource.instantiate({
fragment: files['shader.frag'],
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to do the color animation in fragment shader as an example on how to do it .. it handles long splats better than per vertex.

@willeastcott
Copy link
Contributor

willeastcott commented Dec 3, 2024

With StandardMaterial, you would override a chunk via:

material.chunks.emissivePS = <shader_chunk_string>;

Does this PR make splat shader chunk overrides more consistent with this?

@slimbuck
Copy link
Member Author

slimbuck commented Dec 3, 2024

Does this PR make splat shader chunk overrides more consistent with this?

No. This PR primarily changes shader chunk layout and the way they're handled.

The material is a ShaderMaterial instance which does not support chunks. It might be worth implementing the material it as a GSplatMaterial instance instead, which would inherit from ShaderMaterial (presumably), with the additional chunk API.

However this also touches on GSplatComponent management, which I'm less sure of. @mvaligursky would have to comment, I think.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

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

fantastic improvement!

@slimbuck slimbuck merged commit 8d9bb46 into playcanvas:main Dec 3, 2024
7 of 8 checks passed
@slimbuck slimbuck deleted the gsplat-shader-dev branch December 3, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants