Skip to content

[BREAKING] Update gsplat component material API #7749

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 18 commits into from
Jun 10, 2025

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented Jun 10, 2025

Further to #7734, this PR updates the gsplat component material API.

We drop materialOptions property (which indirectly reconfigured the material) in favour of exposing the material instance directly. This matches the render and model components.

The gsplat component will create a default material if none is provided at construction, but this can then be overridden at will.

Notes

  • the internal function GSplatInstance.configureMaterial accepts a ShaderMaterial instance and configures it with the gsplat data. This function could be useful as public API, but we must still decide how to expose it.
  • cloning a gsplat component doesn't clone the material. if it did, then the sort texture would be shared.

@slimbuck slimbuck requested review from a team and Copilot June 10, 2025 10:53
@slimbuck slimbuck self-assigned this Jun 10, 2025
@slimbuck slimbuck added the area: graphics Graphics related issue label Jun 10, 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 refactors the GSplat material API to expose and configure material instances directly, replacing the old materialOptions pattern and unifying behavior across resource, instance, and component layers.

  • Replace createMaterial methods with a configureMaterial(material) API on resource classes
  • Update GSplatInstance to accept a provided ShaderMaterial (or build a default one), add a getter/setter for material, and centralize material configuration
  • Refactor GSplatComponent to use a material property (stored in _materialStore) instead of materialOptions, and apply overrides at instance creation

Reviewed Changes

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

Show a summary per file
File Description
src/scene/gsplat/gsplat-sogs-resource.js Renamed createMaterial to configureMaterial
src/scene/gsplat/gsplat-resource.js Renamed createMaterial to configureMaterial
src/scene/gsplat/gsplat-compressed-resource.js Renamed createMaterial to configureMaterial
src/scene/gsplat/gsplat-resource-base.js Added empty base stubs for configureMaterial and evalTextureSize
src/scene/gsplat/gsplat-instance.js Overhauled to use provided ShaderMaterial, added material getter/setter and configureMaterial
src/framework/components/gsplat/component.js Switched from materialOptions to storing/applying ShaderMaterial directly
src/platform/graphics/webgpu/... Guarded WebGPU calls on window.navigator and added optional chaining
Comments suppressed due to low confidence (1)

src/scene/gsplat/gsplat-instance.js:127

  • [nitpick] There’s no existing unit test covering the new material setter or the path where an external ShaderMaterial is provided. Adding tests would ensure correct assignment, mesh update, and avoid regressions.
set material(value) {

@mvaligursky
Copy link
Contributor

The PR should probably be maked as [BREAKING]?

@slimbuck slimbuck changed the title Update gsplat component material API [BREAKING] Update gsplat component material API Jun 10, 2025
@mvaligursky
Copy link
Contributor

Also please update the examples to work, I suspect some do not.

@slimbuck slimbuck merged commit 9652b7b into playcanvas:main Jun 10, 2025
7 checks passed
@slimbuck slimbuck deleted the gsplat-dev-2 branch June 11, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants