Search Unity

VOLUME GRASS - Unlimited Density

Discussion in 'Assets and Asset Store' started by tomaszek, Jul 11, 2014.

  1. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    It took a couple hours, but I figured out how to make it work again.

    Just replace this line:
    Code (cginc):
    1. sceneDepth = 1.0 / ( (_VGZBufferParamA * tex2Dproj(_GrassDepthTex,UNITY_PROJ_COORD(IN.screenPos)).r) + _VGZBufferParamB );
    With this:
    Code (cginc):
    1. sceneDepth = LinearEyeDepth(tex2Dproj(_GrassDepthTex, UNITY_PROJ_COORD(IN.screenPos)).r);
    From what I understood from a quick search, the original code is supposed to improve the curve/distribution of the depth-buffer's z-values, so it works better for close grass blades.

    However, after making the change above, I compared before and after screenshots, and it doesn't seem to be any worse. Did Unity perhaps implement better depth-buffer distribution themselves?


    I know that in the changelog here [https://unity3d.com/unity/whats-new/unity-5.5.0], they do mention: "Graphics: Improve shadows precision for large game worlds. Use reverse-float depth buffer for improved depth buffer precision on modern GPUs. Particularly improves directional light shadowing for large view distances.". However, that seems different than what your "custom LinearEyeDepth() parametrization" code does.

    Anyway, I'm certainly not a shader/rendering-pipeline expert, so the above is just a guess. But the fix does seem to restore at least the main functionality of the plugin, until an official patch is made.
     
    tomaszek likes this.
  2. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I've just submitted version from U5.5.0p3. Should be available within a few days. Above fix would work if depth catching camera would have exactly the same distances (which is not the case - by default I set it to 40). So - it works "at first glance", but it's better to use my formula. The only issue is that in U5.5 we've got reversed floating point depth buffer. We need to check it with #if defined(UNITY_REVERSED_Z) and use 1-tex fetch.

    ATB, Tom
     
    Venryx likes this.
  3. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Just before Unity forum problems that happened April 30th I had here user request about performance of VG.

    To answer missing question - I've just installed U5.6 on my laptop with 960m nVidia GPU and have around 170fps in fullscreen MSAAx2 - both meadow and soccer scene. We need to remember that VolueGrass is pixel intensive shader, so we ndefinitely need to reduce number of passes needed to solve this object - in forward with many pixel lights object needs to be redrawn multiple times which affects performance.

    Tom
     
  4. Deleted User

    Deleted User

    Guest

    Hi. A got the errors

    Trying to create a material from string - this is no longer supported.
    UnityEngine.Material:.ctor(String)

    Shader error in 'Grass Shader ALT': 'vert': output parameter 'o' not completely initialized at line 813 (on d3d11)
     
  5. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Unity version agains VG version please.

    Tom
     
  6. Deleted User

    Deleted User

    Guest

    5.5.3 f1 what the vg version?
     
  7. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    734
    Volume Grass version of course ;):)
     
  8. indie6

    indie6

    Joined:
    Dec 15, 2012
    Posts:
    101
    Is the mobile version included in this? or still in the making?
     
  9. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    It's supposed to work with GLES3 mobile hardware, but it's rather GPU intensive solution.What's the main strength is that it completely releases CPU from drawing ton of grass patches.
     
  10. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Did this ever seen any upgrades to procedural generation in runtime over the years?
     
  11. lawsochi

    lawsochi

    Joined:
    Oct 24, 2016
    Posts:
    107
    Hi, I'll use VG instead of terrane, in the places where I have a meadow. but, the size of the world is very large, I need several VG objects on the same meadow. At the junctions between the objects there are unpleasant artifacts (yellow line). is there any way to fix it?
    Thanks for the great tool)
    and have not changed the plans well the future for you, in part VG?
     
  12. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Grass objects are mapped in world space so seams should be no problem as far as you provide exactly the same normals and tangents at stitched edges.

    The fact is that GPUs get powerful and we don't need to rely on old DX9 architecture (Unity dropped this platform as well). VG technique is fine, but I more and more think about providing users with mesh based solutions rather than trying to master VG which is in the end billboard like solution. We don't need to pay any price for the number of billboards rendered so it's CPU free, but the look is constrained to the idea principle. Take a look at the solutions I made for our D.R.O.N.E. project:



    It's solution basing on DX11 architecture and works pretty effective together with physical interactions, wind, explosion blows, burnt grass. If at some point I will release grass similar, it will be rather done this way. Problem is I can't focus on new UAS products. Anyway - I'll always keep in mind what my users gave me buying my products. So VG users will be surely eligible to get discounts on new releases when they come (like I did for example with RSP to UBER upgrade path for $1).

    Tom
     
    Last edited: Sep 28, 2017
    Lars-Steenhoff likes this.
  13. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I love VG. But it appears it is no longer compatible as it throws errors on importing the package into Unity 5.6.3p1. Please consider me as a beta tester for whatever comes next. I will need it for my current project.
     
  14. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I'll take a look importing VG into the Unity version you mention.

    Tom
     
  15. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Installed up-to-date VG in U5.6.3p1 and it doesn't seem to throw any errors. All example scenes work fine.
     
  16. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    It looks like it must be a conflict with my existing project. Thanks for confirming it is supposed to be working. I will start a clean project and import it and compare that with my project and see if I can find the conflict.

    ------

    I have narrowed it down. If I start a new project and import BuildR2 I get no errors. If I then import VolumeGrass, I get errors.

    Code (CSharp):
    1. Assets/VolumeGrass/_Scripts/VolumeGrass.cs(585,16): error CS1729: The type `Poly2Tri.PolygonPoint' does not contain a constructor that takes `3' arguments
    2.  
    3. Assets/VolumeGrass/_Scripts/VolumeGrass.cs(599,27): error CS1729: The type `Poly2Tri.TriangulationPoint' does not contain a constructor that takes `3' arguments
    4.  
    5. Assets/VolumeGrass/_Scripts/VolumeGrass.cs(611,40): error CS1061: Type `Poly2Tri.TriangulationPoint' does not contain a definition for `index' and no extension method `index' of type `Poly2Tri.TriangulationPoint' could be found. Are you missing an assembly reference?
    6.  
    It seems both assets use PolygonPoint.

    -------

    It looks like both assets use poly2tri
     
    Last edited: Oct 30, 2017
  17. dougbello

    dougbello

    Joined:
    Apr 9, 2015
    Posts:
    15
    Hello Tom, your package looks amazing, I need to make it for a soccer field grass, but it needs to work in VR in a pc with 1080 so I'm just wondering if you had any issues with VR like the terrain grass has in unity. The grass in terrain rotates with the vr headset and looks really weird. If your package works fine with vr headset, i'm buing it.

    Thanks
     
  18. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    It works, but will have problems with cutting silhouettes where grass intersects ball and other objects. If you can live with it - should be fine.

    Tom
     
  19. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Package approved. Downloaded it in U2018.3 fresh project to check if right package is given Unity side. Seems everything works.

    Tom

    EDIT I misplaced this post - should be posted on RTP thread. Sorry.
     
    Last edited: Jan 8, 2019
    hopeful likes this.
  20. Leewonki

    Leewonki

    Joined:
    Sep 6, 2018
    Posts:
    2
    need more function SetupForRendering script.
    'GrassDepthCamera' need to Same fov
     
  21. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I don't understand exactly the problem. Could you describe it?
     
  22. Leewonki

    Leewonki

    Joined:
    Sep 6, 2018
    Posts:
    2
    If the camera created as a child is not the same as the parent Fov, it will not work properly.
     
  23. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Yes, you're right. We need to make sure rendering camera and aux "child" camera (used to grab depth for intersecting objects) parameters match (i.e. FOV).
     
  24. Gerard_Slee

    Gerard_Slee

    Joined:
    Apr 3, 2017
    Posts:
    11
    Is it possible to add Volume Grass to a mesh at runtime? I have a material picker and would like to add your shader and add some materials to the library. I currently click to change materials. Is this system smart enough to adapt to new meshes at runtime?
     
  25. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Yes, it is possible. You simply need to follow what happens script side in my system when you apply volume grass (it extrude mesh and mark sidewalls with vertex colors). I'ts relatively easty to spot and follow. Might be some scripts are marked as editor only, but it doesn't hurt to change then all for runtime usage.
     
  26. ElanGr

    ElanGr

    Joined:
    Mar 10, 2019
    Posts:
    4
    Does the grass in this asset exert a force on whatever rigidbody is moving through it? In other words, if I had a vehicle driving from a solid surface onto the grass, would the grass be able to slow down the vehicle so the vehicle acted like it was actually driving on grass?
     
  27. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Not by itself. You need to detect when car is over grass and apply drag force then. Determining car vs grass collisionshouldn't be that much hard - simply make mesh collider that is of grass shape (you can even use grass mesh for this) and treat it as trigger for collisions.

    Tom
     
  28. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Is this URP compatible or are there any plans for that? Cheers.
     
  29. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    No plans for URP by now.
     
  30. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    Hello,

    I'm seeing some issues when building for WebGL, simply put the grass does not display when testing in the browser. From what i've read, i'm pretty sure this is supposed to support this platform, so i'm not sure what the issue is.

    Do i need to apply a specific setting for WebGL?

    Any assistance on this would be greatly appreciated! ^_^
     
  31. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Can you give me exact Unity and VG versions used so I can reproduce it on my side?
    However if WebGL is GLES2 constrained it could be problematic to use it on this platform at all.

    Tom
     
  32. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I'm using Unity 2018.3.6, in the player settings i attempted builds with Auto Graphics API on, WebGL 2.0 and WebGL 1.0 but all builds don't show the grass.

    Yes it seems GLES3 is grayed out, do i need to grab that through android studio before it can be used?

    Here's a few images showing my current settings





     
  33. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    Oh my bad, i'm using VG 1.5d
     
  34. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    So it's been a while, still looking for a proper response to my inquiry. Please do look over my recent posts and let me know.

    Thanks.
     
  35. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    By default WebGL is ES2.0 equivalent, so it won't work for WebGL 1.0.

    You need to remove WebGL 1.0 API in the Player settings, open the Other Settings panel, disable the Automatic Graphics API setting and set it to 2.0 which covers an ES3 spec (DX11 ish).

    upload_2020-3-4_17-28-14.png

    Note: I don't own this asset or anything so obviously I can't test it for you. Seems this is logically the issue though.

    This asset is nowhere near fast enough for ES2 devices so you would want ES3.0+ regardless for this (WebGL 2.0).
     
  36. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    So, opened my VG project under 2018.3.8f1. Installed WebGL support and built example meadow scene. It works for me as WebGL2.0 is preferred API in player settings (auto api has only WebGL2.0 so that I hadn't change anything).

    Tom
     

    Attached Files:

  37. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I already did this and showed that in my previous post (spoiler content)

    So i spent some time today and installed 2018.3.8, upgraded the project, made a build and.... still no grass :p


    I did however make a new project (unity 2018.3.6) and import volume grass, made a build and it actually does show. SO it's either something with my scene or settings :(

    UPDATE:
    Alright I fixed it, seems it was the grass layer and static settings.
     
    Last edited: Mar 8, 2020
  38. asherkenyon98

    asherkenyon98

    Joined:
    Jan 28, 2021
    Posts:
    1
    Hi, just come across this plugin and im curious if it can be used to create very short grass, like on a golf course.
     
  39. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Yes, that's basically the most obvious VG usecase (soccer field example scene is included in the package).