Change the material of a primitive in a ModelMesh
See original GitHub issueIs there a way of changing the material linked to a primitive in a ModelMesh created from a glTF model?
The goal is to highlight the picked node by changing the material’s parameters but ModelMaterial.selValue
is applied over every primitive linked to that material. I think that the best solution is to temporary link the primitive to a special ‘highlight’ material but it does not have any effect over the rendered model. Maybe there is a better solution to solve the problem so I am open to suggestions!
Thanks!
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Change the material of a primitive in a ModelMesh · Issue #2387
The goal is to highlight the picked node by changing the material's parameters but ModelMaterial.selValue is applied over every primitive linked ...
Read more >can I change the b3dm model`s material or texture after it`s ...
Is there a way of changing the material linked to a primitive in a ModelMesh created from a glTF model? The goal.
Read more >Is it possible to modify materials of a loaded gltf model?
I need the ability to dynamically adjust the colors and/or opacity of components within a loaded gLTF model. I can do this without...
Read more >How to change a material of primitive gameobject C# - Unity ...
I like to change a material of the primitive gameobject (script below). The gameObject is made in C# I like to know how...
Read more >Using materials with libGDX - blog.xoppa.com
In this tutorial we will see how to use materials with libGDX. ... Luckily this is very easy to accomplish, so let's change...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, this should be more simple than changing the loading code.
Yes, if you use a custom fragment shader with an extra uniform that is the highlight color that is multiple with the computed color (default to white for no highlight). Note that you won’t be able to change a material from opaque to translucent or vice versa without more work since the render state also would need to change.
@pjcozzi Thanks for your reply. I’m on this these days. I modified the
parseNodes parsMeshes parsMaterials
function. But model loading went really slow because of so many for loops. There are some functions looping to read thetechnique
inmaterial
after theparse
func, which cost much. And gltf can’t find mesh’s parent nodes and material’s parent meshes, which leads to more loops.Is there anything I missed or better way I hadn’t found?
Or maybe modify the gltf file is a better choice.
What about shader level, can we change the material of nodes in runtime rather than modify it? Thus I can achieve highlighting or translucent.