Search Unity

[Shader] Enhanced Foliage Free. Non Terrain grass and leaves with more quality and movement!

Discussion in 'Shaders' started by marmito, Feb 7, 2017.

  1. marmito

    marmito

    Joined:
    Jan 19, 2014
    Posts:
    40
    Hi, i decide to share with you guys two shaders I wrote for moving foliage outside of the unity terrain, one for the leaves based on the Standard Surface Shader, with metallic and smoothness, and a simplified one for grass, whitout the GI thing, but you can use one of them in both cases. The part of the shader corresponding to the motion I took from here. Thanks, GambinoInd! :p



    https://github.com/lukasRodrigues/unity-enhanced-foliage

    The idea is to make it easier for anyone looking for a shader that lets your own trees look more pleasing, since the built-in tree soft occlusion leaves does not have many options(haha), and make wave grass moviment outside the terrain.

    Unfortunately I did not find any solution to move the bark, if any of you could help it would be very good. By the way, this is the first interesting shader that I implement, do not crucify me if you find some grotesque mistake and sorry for my bad english! :)
     

    Attached Files:

    Last edited: Feb 7, 2017
    Lex4art, sylon, mgear and 3 others like this.
  2. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    might want to add the codes in the repo not only a packages, to make it easier for people check your code without need to download and import the packages in unity
     
    Phantom_X likes this.
  3. marmito

    marmito

    Joined:
    Jan 19, 2014
    Posts:
    40
    Done! Check the "Shaders" folder. unity-enhanced-foliage/Enhanced Foliage/Shaders/
     
    Reanimate_L likes this.
  4. marmito

    marmito

    Joined:
    Jan 19, 2014
    Posts:
    40
    Bump!!!
     
  5. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    71
    Thank you very much for this! I see the examples and it looks great!
    However, what are the reqruirement for the models, such as the tree models? The low poly tree has two materials, one for the top, and one for the bottom, where only the top one has the shader applied. GIF here https://cl.ly/3e2p2p0F4410
     
  6. marmito

    marmito

    Joined:
    Jan 19, 2014
    Posts:
    40
    Sorry for the too late answer. Everything needs to be a single object with two materials(leaves and bark), like the setup in documentation for custom trees.
     
  7. kayb14

    kayb14

    Joined:
    Jun 12, 2016
    Posts:
    10
    wow, thanks a lot! This is exactely what i wanted. Our game features small outside places, like a backyard or a small meadow, so a terrain would be total overkill but we still need some movement in our grass.
    perfect, as said thanks a lot!!!
    If you want any credit, when the game is done, pm me. ;)
     
  8. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,316
    Nice one, thanks a lot :)
     
  9. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,316
    Hello Lucas,

    thanks for this nice foliage shader. I Looks very interesting!

    I am trying to use it with a texture Atlas: I have 8x8 gras textures on one texture.
    I have different gras meshes. each one has 4-16 surfaces which Point on one of those gras textures.

    It works and Looks very good with your shader, but it does not move (at all). I added a Windzone but still no movement.
    Is there a way to get the grass moving using a texture Atlas and many different meshes for each gras on that Atlas?
    With a wind Zone or it would also be okay for me just to get each one Swinging randomly?

    That would be great :)
     
  10. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,316
    PS: -> works better with v.vertex.y. I guess I can find a solution with that, thanks!
     
  11. marmito

    marmito

    Joined:
    Jan 19, 2014
    Posts:
    40
    It will not work with a texture atlas, not as expected at least. This shader is based in the old built-in solution for moving grass in unity terrain and it was made to only support a single texture per image file. To be able to move it using a texture atlas you'll need to use a solution based in vertex colors, so the information of the vertices that should move or not will be stored in the mesh itself, not in the texture. It may work with this shader, you'll need to dig into vertex colors. I've code a better solution for it, with proper vertex color implementation, but I think unity itself already have a solution for vegetation, so you should use theirs.