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

add gaussianSplat mat file for shader #7192

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

WeiguangHan
Copy link

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Copy link

update-docs bot commented Mar 8, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

requires : [
color, // f_dc and opacity
tangents, // rot
custom0, // scale
Copy link
Member

Choose a reason for hiding this comment

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

custom1-custom6 are optional, since SH order may be 0, 1 or 2:
0: only CUSTOM0
1: + CUSTOM1-3 (9 floats)
2: + CUSTOM4-6 (24 floats)

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, our current encodings are as follows:

  • POSITION: Vertex positions (FLOAT3)
  • COLOR: DC component and opacity (FLOAT4)
  • TANGENTS: Rotation quaternion (FLOAT4)
  • CUSTOM0: Scale (FLOAT4)
  • CUSTOM1 to CUSTOM6: SH coefficients (FLOAT4)

Copy link
Member

Choose a reason for hiding this comment

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

Got it. So if input splat does not have f_rest, CUSTOM1-6 will not be needed. So we should not have them as requires.

Copy link

@zhangyang-intel zhangyang-intel Mar 12, 2025

Choose a reason for hiding this comment

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

Update our current encodings as follows:

POSITION: Vertex positions (FLOAT3)
COLOR: Scale (FLOAT4)
TANGENTS: Rotation quaternion (FLOAT4)
CUSTOM0: DC component and opacity (FLOAT4)
CUSTOM1 to CUSTOM6: SH coefficients (FLOAT4)

The difference is that we use CUSTOM0 for f_dc and opacity, COLOR for scale.
The reason for this change is as following:

In the latest commit, we calculate color from f_dc and f_rest in vertex shader. But function getColor() is fragment shader only and we can not use it in vertex shader. So in order to get f_dc in vertex shader, we save f_dc in CUSTOM0 buffer rather than COLOR buffer.

After we calculate color results from f_dc and f_rest, we pass it into fragment shader by variables.
You can go to here for more details about variables. And for now, we calculate color results by calling function defined in glsl function.

If input splat does not have f_rest, the corresponding buffers will be filled with default vaule. So i think we have them as requires is ok.

// material.baseColor.rgb = getWorldPosition();

// Wrong Case3: Calculate RGB value using user world position.
// material.baseColor.rgb = getUserWorldPosition();
Copy link
Member

Choose a reason for hiding this comment

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

Can you add here directly setting the color based on:

  • scale
  • rot1-3
  • f_rest - any 3 values from SH order 1
  • f_rest - any 3 values from SH order 2

Also, paste the resulting images in the PR - this will validate that the shader is able to receive the GaussianSplat data and display it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, we are working on this.

Choose a reason for hiding this comment

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

We have verified we can the shader can get data scale, f_rest of order 1, f_rest of order 2.
Please check the latest commit for gaussianSplat.mat.
Overall, if we can not get data, the resulting image is all black as following:
pic2
If we can get data, the resulting image has colors like following:
pic1

Choose a reason for hiding this comment

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

And we are working on how to get rot.

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Choose a reason for hiding this comment

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

For now, we save rot in buffer Custom7.

@billamiable billamiable mentioned this pull request Mar 11, 2025
9 tasks
Copy link
Member

Choose a reason for hiding this comment

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

[nit] separate into per SH order functions (see comment above).
Add docs (details of input, ie.. coeffs, and also link to original / reference cuda code.)

// material.baseColor.rgb = getWorldPosition();

// Wrong Case3: Calculate RGB value using user world position.
// material.baseColor.rgb = getUserWorldPosition();
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

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

Code looks great! I think we just need the renderings for various 3DGS properties as test case results to go ahead and merge this PR.

@zhangyang-intel
Copy link

Code looks great! I think we just need the renderings for various 3DGS properties as test case results to go ahead and merge this PR.

Test case results are as following:

  1. scale in COLOR buffer:
    scale
  2. sh coeffs of degree 1 in CUSTOM0 buffer:
    sh1
  3. sh coeffs of degree 2 in CUSTOM6 buffer:
    sh2
  4. rot in CUSTOM7 buffer:
    rot

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

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

Thanks @WeiguangHan looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants