Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Stylized Grass Shader [URP] ☘️

Discussion in 'Assets and Asset Store' started by StaggartCreations, Jan 5, 2020.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Scene complexity and the number of benders has no bearing on the functionality. There's a maximum render range specified on the render feature, perhaps that's too low for your larger scenes?
    upload_2023-11-10_8-51-19.png
     
  2. TreyH

    TreyH

    Joined:
    Feb 6, 2014
    Posts:
    15
    I thought it might be that setting yeah, but those don't seem to impact the problem -- it happens reliably on terrains with low elevations, though.

    In the clip, the right side has an elevation of -100, and the left side is at -102. The bending does appear on the right side, but dissipates on the left sadly.

    edit: I thought it was alpha blending, but it seems a little hard to pin down when this will happen atm.

     
    Last edited: Nov 10, 2023
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Thanks for taking the time to record some videos, that's certainly helpful!

    I can't quite explain what is happening I'm afraid. I notice a distinct "fading" effect taking place, which is fairly specific behavior. I feel it requires some debugging to get to the root of the cause. If you are able to provide a minimal repo-project, that would be a huge shortcut, as I'm not able to reproduce this on my side.
     
  4. Fm115

    Fm115

    Joined:
    Jul 24, 2022
    Posts:
    1
    Which argument should I put in there: OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
    Cause I got error message:
    'OUTPUT_SH': Too few arguments to a macro call.
     
  5. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    This is a particular code function that's prone to breaking between different URP versions. Best to use the latest version on the store, as this takes newer URP versions into account as well. Using an older version in a newer Unity version may certainly cause this compile error.
     
  6. AustinDrozin

    AustinDrozin

    Joined:
    Jun 8, 2016
    Posts:
    43
    I can't seem to get objects with the shader to cast shadows. I'm wondering if there is a setting in Unity that I need to change. URP shadow settings seem normal and the renderer has cast shadows turned on.
     
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Shadow casting is certainly supported! You may need to give the shader a kick by forcing it to recompile. You can do so by selecting the "Shaders" folder in the Stylized Grass Shader folder, right-clicking and and choosing "Reimport".

    You can otherwise try out the demo scene, and enabling shadow casting on one of the prefabs, to check if the issue isn't scene-specific.
     
  8. AustinDrozin

    AustinDrozin

    Joined:
    Jun 8, 2016
    Posts:
    43
    i ended up just deleting the material and making it again since the example scene's material worked with shadows. If I put the grass material from the example into my prefab, it worked as well. I checked all the values between them and they were identical so idk what happened. Works now though since I just duplicated the demo mat and changed values.

    another question though, how would I tweak the shader to make the receive shadows a different color/alpha? Would like to lighten them up on the meshes that use them.
     
  9. AustinDrozin

    AustinDrozin

    Joined:
    Jun 8, 2016
    Posts:
    43
    just wanted to follow up on this since you may have missed it being at the end of my last reply.
     
  10. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Apologies, I did miss that!

    The shader uses URP's lighting model in the end, so the shadow strength, per material can't be altered.

    What you can do is to use the Emissive color paramater (defaults to black) to boost the brightness of the final color. Emission is always added on top of shadows/occlusion, so it will appear to make shadows lighter.

    Alternatively, increasing the Translucency Indirect parameter (even if 0.01) also adds a bit of brightness to shadows.

    Both also affect the grass material outside of shadows though!
     
  11. AustinDrozin

    AustinDrozin

    Joined:
    Jun 8, 2016
    Posts:
    43
    thanks :)
     
  12. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hello @StaggartCreations, I recently updated from 1.3something to the current version hoping I could figure out why my gust direction wasn't matching the specified wind direction. Unfortunately I can't quite seem to get the two to match. The best I can do is to change gust strength to a negative to have it go in the opposite direction, however it seems to ignore the wind Vector4. Is there something I'm missing to have directional control over gust? Thanks.
     
    Last edited: Jan 3, 2024
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    There are two ways to control the wind direction, the default is on a per-material basis. The other being through a Wind Zone, in a global manner.

    I see in the former there appears to be something wrong. If the wind direction is set to (0,0,0,0) the gusting still moves forward. So your findings are on point!

    I've submitted an update that includes a fix for this.
     

    Attached Files:

  14. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Version 1.4.3 is now available!

    Fixed:
    - Wind gusting not respecting the wind direction configured on a material.
    - Shader error when building for PS5

    Removed:
    - GrassBendingFeature script file (obsolete since v1.3.0)

    ---------

    In a few days this asset will have been on the asset store for 4 years. I would like to thank every user for their confidence in my work and purchasing a license! Every now and then I spot this being used in a game, and that's a true pleasure to see :)

    As I mentioned in an earlier post, this asset is no longer under active development, as its feature set is already well rounded and the backlog has simply been exhausted. Support and fixes will be extended up to Unity 2023.3. But beyond that it is really time for a separate asset/license altogether, this is also a more sustainable approach in terms of revenue, which in turn funds development. An upgrade discount will be available for current users.
     
  15. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Wonderful, thank you, that fixed it! I hadn't realized you were wrapping up support for this so I really appreciate you taking time here. I'm still years away from completion however I'm pretty happy with the state of the asset, but I'll definitely keep my eyes open if you end up releasing something else. Thanks again!
     
  16. unity_OITuiZ9sdZf6cQ

    unity_OITuiZ9sdZf6cQ

    Joined:
    Jan 10, 2023
    Posts:
    3
    I have two questions:
    1. When I apply the grass to the terrain, I notice a massive hit to FPS. Is there something I am doing wrong?
    2. Can you be more specific with how to get the trail bending working?

    Thank you
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Matters of performance always boil down to "it depends" because it is specific to the context and implementation. From where I'm standing, I'm left to guessing what this means for you. I'd recommend using Unity's profiler and frame debugger, this is ultimately the best way to determine where and why you're encountering performance bottlenecks.

    For bending to work, there is a single project setup step required as outlined here: https://staggart.xyz/unity/stylized-grass-shader/sgs-docs/?section=using-grass-bending

    Using a trail for bending can be as straightforward as dragging in the BendTrail or BendParticleTrail prefabs into a scene, and parenting it under any kind of moving object.
     
  18. unity_OITuiZ9sdZf6cQ

    unity_OITuiZ9sdZf6cQ

    Joined:
    Jan 10, 2023
    Posts:
    3
    I am applying the grass using unity terrain tools. As soon as I add the grass, I lose like 200fps. What can I do differently?
     
  19. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    34
    Hi! I'm using an external library to load fbx files for levels. It loads them as mesh renderers so none of the terrain code seems to work. I would like the grass to match the colors of the textures on the mesh. Is there an easy way to do that?
     
  20. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    Color map rendering from Mesh Renderers is also possible. This works the same as it does for Terrain objects. It would be a matter of assigning the renderers that represent the terrain to a Colormap Renderer component as outlined here.
     
  21. protomor

    protomor

    Joined:
    Dec 13, 2021
    Posts:
    34
    oh, I somehow thought that was only for terrain objects. Works great! I just need to figure out how to run the render after I'm sure all textures have been loaded. Otherwise the grass comes out gray.
     
  22. icarranza

    icarranza

    Joined:
    Sep 7, 2022
    Posts:
    1
    Hey guys,

    was this something that was still in the works, I know this is an old post, but I was wondering if it was something that could still be done for the Stylized Grass Shader?

    Thanks
     
  23. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,204
    The material has an Emission Color (HDR) parameter as of now, which affects the top of the grass gradually. This can be used to make a glowing grass material