-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to assign custom shader to Gsplat Entity #29
Comments
What does your vertex shader look like? You may want to check the latest shader in the engine and base yours off this. |
@marklundin Thank you for the assistance. I simplified the problem by adapting and applying the Shader script from this sample: Same error..
I also modified the Shader application method as follows: import { Mat4, Script as PcScript, Entity as PcEntity } from "playcanvas";
import type { SplatMaterialOptions } from "playcanvas/build/playcanvas/src/scene/gsplat/gsplat-material.js";
import { Script } from "@playcanvas/react/components";
import vertexShader from "../../playcanvas/shaders/gsplat.vert";
class GsplatShaderScript extends PcScript {
timer = 0;
materialOptions: SplatMaterialOptions = {
vertex: vertexShader,
};
private getGsplatComponents() {
return (this.entity.parent as PcEntity)
.findComponents("gsplat")
.map((component) => component.entity.gsplat)
.filter((gsplat): gsplat is NonNullable<typeof gsplat> => gsplat !== null);
}
initialize() {
for (const gsplat of this.getGsplatComponents()) {
gsplat.materialOptions = this.materialOptions;
}
}
update(dt: number) {
for (const gsplat of this.getGsplatComponents()) {
const material = gsplat.instance?.material;
if (material) {
material.setParameter("uTime", this.timer);
}
}
this.timer += dt;
}
}
export const GsplatShader = () => <Script script={GsplatShaderScript as PcScript} />; Are there any specific configuration requirements needed to apply this Shader? |
@marklundin It works perfectly!! Thank you for your thorough support. Also, I've been receiving so many benefits thanks to this repository (playcanvas/react). Thank you very much! |
Brilliant, glad it's helpful! Pls hit the repo star button @KEMSHlM Closing this |
@marklundin Nice! I'm impressed by how quickly the updates are being made. |
Yep you'll need to expose uniforms that you want to control via JS, and set them via the material as per the demo. Let me know if that works for you |
How to assign custom shader to Gsplat Entity using @playcanvas/react
Issue Description
Vertex shader compilation fails when implementing Gaussian Splatting with PlayCanvas custom shaders using raw-loader for GLSL files.
Note: This issue spans both
@playcanvas/react
and@playcanvas/engine
. As I'm primarily working with@playcanvas/react
and have limited experience with@playcanvas/engine
internals, the shader implementation details may need review from those familiar with the engine's shader system.Steps to Reproduce
Error Details
Main vertex shader errors:
calcSplatUV
,getCenter
,getCovariance
,calcV1V2
matrix_view
,matrix_model
,matrix_projection
vertex_position
,viewport
Expected Behavior
Current Behavior
Shader compilation fails with multiple undefined reference errors and type mismatches.
Additional Context
@playcanvas/engine
team regarding proper shader implementationEnvironment
This is code ...
The text was updated successfully, but these errors were encountered: