Animating a mesh with MaterialShader without losing base colors?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GlaceGwyneth

I’m using Godot v3.1

I’m trying to follow the “Animating thousands of fish” tutorial but run into trouble right away.

The tutorial states: “Load your fish model into a MeshInstance and add a new ShaderMaterial.”

The site the tutorial links to where the model is located has an .obj version, but it has no coloring when imported into Godot, so instead I downloaded the .blend file and used the better collada exporter to get a .dae instead. I imported it, saved the Mesh as a resource and discarded the rest of the scene.
Then I load this mesh into a MeshInstance.

This mesh has 3 surface material slots to color the fish, but no matter where I put the ShaderMaterial, for example in the GeometryInstance’s “material override”, the color is partially or completely lost.

The only workaround I can find is by converting each surface slot’s SpatialMaterial into a ShaderMaterial, then putting the tutorial’s shader code inside, but this requires copying the shader into all 3 surfaces!

The tutorial doesn’t mention anything like this and seems to have no problems keeping the full color while also animating the fish.

How can I add this ShaderMaterial to animate the whole model without losing the surface materials’ colors?