question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the material of a primitive in a ModelMesh

See original GitHub issue

Is 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:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
pjcozzicommented, Jul 31, 2016

Or maybe modify the gltf file is a better choice.

Yes, this should be more simple than changing the loading code.

What about shader level, can we change the material of nodes in runtime rather than modify it?

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.

1reaction
yqrashawncommented, Jul 21, 2016

@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 the technique in material after the parse 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found