Vertex shader per group of meshes(not per material)

Hello guys!

I have been exploring vertex shaders in Playcanvas and according to the docs a vertex shader has to be attached to a material.

What i would like to achieve is to displace the vertices of an entire model, this model can have different materials, does that mean that i have to attach my vertex shader to every single material?, what about if i want to distort all the vertices in the whole scene?

Is there a way to acomplish such thing? I have been looking into the shader chunks but I am still learning how to use them.

I don’t have much experience with shaders, but you could simply loop through all mesh instances of a model and apply a shader to each. For different appearances/behavior you could use shadermaterial.setParameter() dynamically to pass different variables into the shader.

This is what i have been trying, yet, no success.

I wonder if batching will still work since i am overriding the material.
Also, how do i “add” a shader on top of the shader that has been assigned to the material in the editor?, if i overwrite the shader, then the lighting and other shader properties doesn’t work anymore, it’s like everything resets to my custom shader.