-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area: graphicsGraphics related issueGraphics related issue
Description
The main goal is to expose the ShaderMaterial that is used to render splats, and allow users to create and assign a custom material.
At the moment the material creation is internal, and without a public API to access it. To provide custom shader, this needs to take place:
entity.gsplat.materialOptions = {
fragment: '// shader source',
vertex: ''// shader source'
};
Suggested new API:
class GSplatInstance - make it a public class
GSplatInstance.material - make its material property public,
// allowing new materials to be assign and their properties modified
GsplatComponent.instance // make the getter public, returns GSplatInstance, allowing access to the material
example of custom shader, with custom material properties:
const material = new ShaderMaterial({
uniqueName: 'MySplatMaterial',
vertexCode: ` // custom code or shaderChunks.gsplatVS`,
fragmentCode: '// custom code or shaderChunks.gsplatVS',
attributes: {
vertex_position: SEMANTIC_POSITION,
vertex_id_attrib: SEMANTIC_ATTR13
}
});
// default settings (we could apply those internally, but perhaps better to leave control with the user)
material.cull = CULLFACE_NONE;
material.blendType = BLEND_PREMULTIPLIED;
// customisations
material.setDefine('MYDEFINE', 'VALUE');
material.setParameter('myparam', 3);
// assign material
entity.gsplat.instance.material = material;
Thoughts @slimbuck @willeastcott ?
Metadata
Metadata
Assignees
Labels
area: graphicsGraphics related issueGraphics related issue