Switch Material with Fade Effect

How can I change the complete material of a mesh with a new material and have a fade effect?

Similar in this video: YouTube

Except I don’t want to just replace the diffuse texture.

Babylon.js Playground :yum:

1 Like

Nice. Thank you.
And how can i change a complete material (PBRMaterial) and not just a diffuse texture? =)

In the example above I’m using a custom material not pbr.
I think for pbr it depends how many properties need to be changed.

If the materials have same textures then for the other properties I think we can do almost same like in the previous example. https://www.babylonjs-playground.com/#410HFB#1

If the materials are totally different then I’m not sure that it is so simple.
A solution can be to clone the mesh, hide the clone and aply the second material on it. And apply a fade effect on both meshes, hide the original and show the clone in the same time.
It is not tested, but at this hour I have no ideea.

But let’s wait a little bit, I think that better ideas will come :slight_smile:

2 Likes

I love your shader!! is it possible to apply the same fading result to a Skybox_MODE material with cubemap ?? it would be AMAZING !!

Hello all

Been playing around with how to get this working for some time now - especially in PBR on imported models.

After watching the You Tube playlists on the NME: PBR Nodes in Node Materials Part 1 - YouTube

I got this technique working on a project really wanted to clean this up and release it to anyone else dealing with this issue. Please check out:

The PBR pipes in two textures into the base colour, ORM and normal map and uses a float called Blend Node to blend all the textures propely. It will also support fog if theres fog in the scene. Feel free to reuse, hack and improve the shader.

7 Likes

Hey @Gerard_Baldsing!
Welcome and many thanks for sharing your solution!

1 Like