Vertex movement

MagicLordMagicLord Posts: 578Unconfirmed

Hi there,

I want to make grass waving movement.
How to make each vertex of mesh wave on X Y for example using Cos function ?

Best Answer

  • MegalomaniakMegalomaniak Posts: 4,430
    Accepted Answer

    Right, the normal map bit was just an extra oh-btw-before-I-forget tidbit, as I mentioned in previous post.

    basically for pseudo-code it would be something along the lines of VERTEX.y += sin(TIME*speedMultiplier); //again just pseudo code not tested

Answers

  • MegalomaniakMegalomaniak Posts: 4,430Admin

    remember the wavey water shader from the other thread? I was offsetting vertices along y for that.

  • MagicLordMagicLord Posts: 578Unconfirmed

    @Megalomaniak said:
    remember the wavey water shader from the other thread? I was offsetting vertices along y for that.

    There is lot of functions, some not necessary because it's not a water shader.

    i just need an a short example showing how to move a mesh vertex along Y offset with Cos and Time.
    The modified vertex value should be position while Normal, Tangent, Binormal should not change.

  • MegalomaniakMegalomaniak Posts: 4,430Admin
    edited February 2018

    OK, now when you say you want to move on the XY plane you do understand that Y in godot is up/down right? Or did you mean the XZ plane instead?

    Also just so we are on the same page Sin and Cos are essentially alternating periods of the same thing:

    Image courtesy of 1ucasvb's lab. Check out this post for further details. The whole blog is worth checking out. Also while I'm throwing useful calculus resources around heres a playlist of 3blue1brown called the essence of calculus. The good stuff™. Also essence of linear algebra.

    Normal, Tangent and Bi-normal have to change, you will not escape that, but you can do everything you need to modify the vertex positions first and only manually calculate normal components last when using render_mode skip_vertex_transform;

    And learning to dissect the code of others is a very valuable thing to-do. ;)

    Aw heck here is a page with a gif showing also the tangent:
    https://socratic.org/questions/how-do-you-evaluate-sine-cosine-tangent-of-pi-2-without-using-a-calculator

    edit nr bazilionth. Also before I forget: from the texture blending/flaky lighting thread I noticed in the scene you uploaded that your normalmaps were oriented wrong, so here is a normalmap I have baked for using in godot that shows which way the axis gradients should be oriented in:

    red highlights from left, green highlights from top. In terms of extrusions from the surface.

  • MagicLordMagicLord Posts: 578Unconfirmed
    edited February 2018

    @Megalomaniak said:
    OK, now when you say you want to move on the XY plane you do understand that Y in godot is up/down right? Or did you mean the XZ plane instead?

    Also just so we are on the same page Sin and Cos are essentially alternating periods of the same thing:

    Image courtesy of 1ucasvb's lab. Check out this post for further details. The whole blog is worth checking out. Also while I'm throwing useful calculus resources around heres a playlist of 3blue1brown called the essence of calculus. The good stuff™. Also essence of linear algebra.

    Normal, Tangent and Bi-normal have to change, you will not escape that, but you can do everything you need to modify the vertex positions first and only manually calculate normal components last when using render_mode skip_vertex_transform;

    And learning to dissect the code of others is a very valuable thing to-do. ;)

    Aw heck here is a page with a gif showing also the tangent:
    https://socratic.org/questions/how-do-you-evaluate-sine-cosine-tangent-of-pi-2-without-using-a-calculator

    edit nr bazilionth. Also before I forget: from the texture blending/flaky lighting thread I noticed in the scene you uploaded that your normalmaps were oriented wrong, so here is a normalmap I have baked for using in godot that shows which way the axis gradients should be oriented in:

    red highlights from left, green highlights from top. In terms of extrusions from the surface.

    In fact i just want to wave each vertex with some offset in Y first before going further.
    For example a plant will have it's leaves doing a small up and down movement, it should result about the whole plant going up and down.

    It's not bitmaps or normal maps related, i would need a vertex offset wave effect on Y i could apply to some plant object.
    From there i will expand the vertex to something new ;)

  • MegalomaniakMegalomaniak Posts: 4,430Admin
    Accepted Answer

    Right, the normal map bit was just an extra oh-btw-before-I-forget tidbit, as I mentioned in previous post.

    basically for pseudo-code it would be something along the lines of VERTEX.y += sin(TIME*speedMultiplier); //again just pseudo code not tested

  • SchusterSchuster Posts: 369Member
  • MagicLordMagicLord Posts: 578Unconfirmed

    @Bishop said:
    I think you need a wind shader?
    https://godotengine.org/asset-library/asset/edit/292

    Nice one, i'll give it a try.
    The shader i want to make is for plants instead, it will use vertex color to control wave frequency, some leaves will have a slighlty faster or slower movement depending on vertex color.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file