I have a tree from an asset pack.
https://github.com/KayKit-Game-Assets/KayKit-Halloween-Bits-1.0

It is imported it as gltf.

Now I want to add a vertex shader to move the upper part of the mesh with the "wind"

The problem is:
the way I have it imported I cannot add a (vertex-)shader material without removing the old one. It's using some sort of a texture map with different colors, to color the mesh.

Is there a way I can keep the old texture with its UV coloring and still get some movement in the upper verteces for the tree?
Maybe some import kung fu?

Rather than using a texture, using the vertex coordinates themselves in object or world space with the right scalar multiplier would give you a gradient to use as the influence mask, separate the components and you get the gradient along a specific axis and use a vector value with a sine operation and the time property to make the vertices move. Makes sense?

Article linked by @Tomcat shows the idea, though it uses vertex colors baked into the model.

The UV data and vertex colors should be attached to the model mesh itself and not the material, btw.

um,

so in order to animate the UVs in a godot shader I have to go to blender, delete the old texture and create a new one to..

  • map the movement intensity of certain areas via another texture, or some function (for the shader)
  • somehow keep the colors.. but how?

With multiple "color attributes"?

Just found this video on vertex painting, never heard of it before:

I did sth like that in three-js a while ago (the green underwater plants) where I do a bunch of sin offsets over time to the upper parts of the plant.
https://redroostermobile.com/underwater/ but it's a very different architecture there in general

So whatever I do, I will have to paint things in blender, right? I can't use the old texture that came with the model, because somehow it maps geometry to that texture and I have no way of editing that?

I may sound strange but the shader stuff I understand, but not the rest 🤣
Materials, vertex Painting, the many different ways of applying a texture to a model, baking... omg I'm so lost

Maybe I just rotate the trees a bit for now , before I get my blender "degree".

    mojomajor So whatever I do, I will have to paint things in blender, right?

    Yeah.

    mojomajor so in order to animate the UVs in a godot shader I have to go to blender, delete the old texture and create a new one to

    It's where the vertex colors are painted. The texture can stay.

    I use TreeIt to create trees — it colors the vertices itself and makes the tree completely ready for wind effect.

    But maybe soon trees for Godot will be finished.

      Tomcat

      Somehow I got it with the OLD texture AND vertex painting.

      I used the shader code from @Megalomaniak s link and passed the old texture as albedo

      This one passed as albedo param to the shader:

      Painted lower tree trunk vertices black(and a few others) in Blender, reexported.

      Shader code:

      shader_type spatial;
      render_mode depth_prepass_alpha, cull_disabled, world_vertex_coords;
      uniform sampler2D texture_albedo : source_color;
      uniform vec4 transmission : source_color;
      // https://docs.godotengine.org/en/stable/tutorials/shaders/making_trees.html
      uniform float sway_speed = 1.0;
      uniform float sway_strength = 0.05;
      uniform float sway_phase_len = 8.0;
      uniform float y_threshold = 0.75;
      
      void vertex() {
          float strength = COLOR.r * sway_strength;
      	if ( VERTEX.y >= y_threshold) {
      	    VERTEX.x += sin(VERTEX.x * sway_phase_len * 1.123 + TIME * sway_speed) * strength;
      	    VERTEX.y += sin(VERTEX.y * sway_phase_len + TIME * sway_speed * 1.12412) * strength;
      	    VERTEX.z += sin(VERTEX.z * sway_phase_len * 0.9123 + TIME * sway_speed * 1.3123) * strength;
      	}
      }
      void fragment() {
          vec4 albedo_tex = texture(texture_albedo, UV);
          ALBEDO = albedo_tex.rgb;
      }

      Godot setup:

      Thanks for the hints!

      I still don't know what I'm doing, but this is pretty much what I wanted 🥳