1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Graphics Swaying grass tutorial - GMWolf

Discussion in 'Tutorials' started by GMWolf, Jun 12, 2017.

  1. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    GM Version: GameMaker:Studio 2
    Target Platform: ALL
    Download: N/A
    Links: YouTube Video
    Summary:
    Add lush swaying grass to your game with this powerful solution.
    This video aims to introduce you to Vertex Buffers and Vertex Shaders in GameMaker Studio 2, by building a a simple grass mesh generator, with a simple shader to animate it.

    Tutorial:

    Hope you find this useful! I would love to see what you come up with!
     
    Nux, DevGuyDonny, trichome and 2 others like this.
  2. trichome

    trichome Guest

    grass_shader.PNG

    Cheers for this Fel666, just finished your tutorial and have a working moving grass shader :). It's my first attempt at a shader and using vertexes.

    Very nice tutorial and easy to follow.
     
    GMWolf likes this.
  3. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    Thanks!
    And every good loockin! Especially with this background!
     
  4. SweetCelestia

    SweetCelestia Member

    Joined:
    Jun 20, 2016
    Posts:
    10
    Nice work dude :3
     
    trichome and GMWolf like this.
  5. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    166
    So this is what they did on breath of the wild... :p
    I'm trying to convert this from triangles into a trianglestrip (my grass is more rectangular). You used 2 triangles per blade of grass on this one (t1 and t2) what part of the blade do each of these triangles correspond to?
     
  6. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    I actualmy use more than two triangles (notice the for loop?)

    The pair of triangles actually form a rectangle, and multiple rectangles are used to build up a blade of grass.
     
  7. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    166
    So I wouldn't have to change it into a trianglestrip but rather keep the base width and top width consistent with each other?
     
  8. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    Yes.
    The reason I don't use triangle strip is to have multiple blades of grass in the same buffer.

    If you ony have a single blade, then triNgl strip may be better. But I have not seen much performance different e from just using triangle list.
     
  9. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    166
    That was easy. I even added random distances between the blades and random heights. You're the hero the GMC needs but doesn't deserve!

    [​IMG]
     
    GMWolf likes this.
  10. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    Hey that is very cool looking! The randomness really does add to It, and I like the square style!

    Something you could try is have each blade have a different "stiffness" by adding a new attribute.
     
    Sammi3 likes this.
  11. DevGuyDonny

    DevGuyDonny Guest

    Nice! Is this approach limited to flat ground?
     
  12. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    Now, but you will have to find a way to describe the ground in the room editor (a path, for example).
     
  13. DevGuyDonny

    DevGuyDonny Guest

    Cool, will have to give your tutorial a try. :)

    What's the framerate like?
     
  14. GMWolf

    GMWolf aka fel666

    Joined:
    Jun 21, 2016
    Posts:
    3,461
    Very good. Each patch of grass is a single draw call. And the shader is practically free.

    Actual numbers will depend on your hardware, but it's plenty fast enough to cover your maps with grass.
     
  15. DevGuyDonny

    DevGuyDonny Guest

    Nice. Will have a try today and post how I go. Wish me luck! :)
     
  16. Nux

    Nux Member

    Joined:
    Jul 7, 2016
    Posts:
    372
    I had followed your tutorial and managed to get this result, but it didn't replicate my desired grass effect strongly enough. It was so close but I hit a brick wall.
    I really liked the tutorial though and I learnt how to use vertex buffers and vertex shaders, so i appreciate that! ;o
     
    GMWolf likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice