[engine] Crossfade two materials?

Is there an example of cross fading two materials on a mesh? (With engine code)

Cross fading materials is not directly supported.

Ah ok. Basically like this demo but cross fading:

https://playcanvas.com/project/437442/overview/switching-materials-at-runtime

Requires merging the shader code into one?

It requires a new shader that samples both textures and mixes them based on some time/alpha value:

Going the path of merging shaders would be ideal, but hard, at least if you want to support many material properties. If you would only want to cross fade the diffuse texture for example, that’s a lot more doable.

Possibly x.com could help here, I think it supports PlayCanvas and shader blending.

Otherwise perhaps render the same mesh twice with alpha blending to implement fade? This would have other limitations, but might be enough in some cases.