Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Volume Grass system on Asset Store soon

Discussion in 'Assets and Asset Store' started by tomaszek, Mar 8, 2011.

  1. TimeSniper

    TimeSniper

    Joined:
    Nov 26, 2012
    Posts:
    18
    Tom,

    Sent! Pls check your PM.
     
  2. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    Hi, I am investigating types of grass for potentially using in a big open wilderness game.

    I'm hoping that this volume grass can cover the area directly under the player's feet but fade out like unity's terrain features at a distance. For tall and far away grass, the terrain system in unity is good enough to be believable. It's just when you look directly down on the hard terrain that their solution falls short of satisfactory. That's where I was hoping your grass could supplement my terrain at super-close proximity to the camera.

    I have two questions:
    - How does volume-grass deal with LoD? Can volume grass reduce CPU/GPU usage when far away from the camera?
    - When massive terrains are in use, do I manually need to segment my volume grass into separate cells to avoid meshes going over unity's max mesh vertex limits?
     
  3. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    VolumeGrass is not based on dynamic coverage system like Unity's which stores grass density for given terrain part. VG is static mesh (although with a bit of effort you can instantiate it runtime as you walk over terrain).

    Although I put some view dir bending funcitonality which definitely helps, looking at very steep angle (view dir orthogonal to terrain surface) you'll see grass billboard cells anyway.

    Tom
     
  4. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    I see, well that makes sense.

    It's really going to come down to experimentation then, trying to measure performance versus appearance in various scene setups and resolutions. Thanks for your help!
     
  5. svf

    svf

    Joined:
    Aug 20, 2013
    Posts:
    8
    Hi Tom,

    first of all, thanks for the great grass shader! I already purchased it and it works quite well.

    However, I want to port my game over to DirectX 11 and I noticed that the shaders don't work for that case. I also tried your example scenes with the same result. Just the flat mesh without any lawn can be seen.

    Do you have any idea on how to solve this issue?

    Best Regards,
    svf
     
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Hi svf,

    VolumeGrass has been released 2011 when nobody even heard about DX11 support for Unity... I'll give it a look and will try to make it working on this platform too but can't tell how long it would take to fix (DX11 HLSL compiler is fussy and in many cases it complains about issues w/o giving any clue where exactly the problem is placed in shader code :( ). Anyway - I'd like to assure you "Emergency is on the way" so you don't need to feel abandoned with this problem... Just give me a few days to look around.

    Tom
     
  7. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    DX11 compatibility - excuse me you had to wait,

    It can be compiled with a tiny tweak in shader code. Find where this occurs in GrassShader.shader and in GrassShader_ALT.shader:

    Code (csharp):
    1.  
    2.         void vert (inout appdata_full v, out Input o) {
    3.             COMPUTE_EYEDEPTH(o.params.x);
    4.             o.params.yz=v.color.rg;
    5.            
    6.             float height=GRASSDEPTH/UV_RATIO;
    7.             v.vertex.xyz -= v.normal * height * v.color.g;
    8.         }
    9.  
    and replace with this:

    Code (csharp):
    1.  
    2.         void vert (inout appdata_full v, out Input o) {
    3.             #if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X)
    4.                 UNITY_INITIALIZE_OUTPUT(Input, o);
    5.             #endif
    6.        
    7.             COMPUTE_EYEDEPTH(o.params.x);
    8.             o.params.yz=v.color.rg;
    9.            
    10.             float height=GRASSDEPTH/UV_RATIO;
    11.             v.vertex.xyz -= v.normal * height * v.color.g;
    12.         }
    13.  
    you need this #if defined added at the beginning of every vert function. I should find it 3 times in 1st shader and 3 times in 2nd.

    Plaese, report it this works for you.

    Kindest Reagrds, Tom
     
    Last edited: Nov 19, 2013
  8. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Why the ifdef? Shouldn't this code (without making it conditional) work on all APIs? Or is it a performance hog?
     
  9. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Performance hog - maybe not that drastic :). It's required only for DX11, so why put it for other platforms... It's also for compatibility reason - for example Unity 3.5 doesn't have this init macro defined (nor DX11 anyway).

    Tom
     
  10. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I'm asking because a long time ago i had (dx9) issues with a shader that was caused by an uninitialized variable. Seemed to work for most people but broke it on integrated intel, so while only dx11 refuses it by spec i'm fairly sure it can cause hard to debug problems in rare cases
     
  11. svf

    svf

    Joined:
    Aug 20, 2013
    Posts:
    8
    Thanks a lot for delivering a fix that quick. It runs smoothly in DirectX 11 now!
     
  12. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    288
    Considering purchasing your plugin, just have a couple of questions:

    1. I'm already stacking together lots of billboards to create dense grass, how would your solution compare performance wise to dense billboards?
    2. Does this work well or at all with mobile?

    Thanks, Jake
     
  13. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    In case of flat terrain my solution requires extremely low number of polys (refer to pdf docs how it works) - as low as 2 polys for object like soccer field. This way it's very quick, but pixels rendered on polys surfaces (fragment shader) is expensive. You need to make a judgement yourself downloading and running demos.

    I haven't tested this on mobile yet. Would work fine for modern one I believe - as it can be compiled for glsl this should be also possible to compile this for gles2.0, however this plugin has been released almost 3 years ago. Those times mobile platforms was relatively slow and I disabled gles compilation for them in shader code. You can check this yourself by removing

    #pragma exclude_shaders gles

    directive from shader code.

    I'll try to update this release in next few months, optimizing this more (got more experience on Unity shaders now) and introducing some new opportunities like grass coverage based on density maps (for application on terrains).

    Tom
     
    Last edited: Jan 14, 2014
  14. TimBorquez

    TimBorquez

    Joined:
    Mar 18, 2013
    Posts:
    81
    hey 2 questions,

    1. does it work in unity free?

    2. can i cover any mesh i want with grass? (not just a terrain)
     
  15. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    1. In Unity free it has constrained functionality - you won't be able to cut silhouettes of brass blades against colliding mesh. I'll try to remove this shortcoming in next release.

    2. Yes you can build and stick grass to any model that has collider, however trying to put grass on cliffs would fail unless you use special script (available upon request) that can setup volume rendering on your custom mesh.

    Tom
     
  16. wr_uk

    wr_uk

    Joined:
    Nov 3, 2011
    Posts:
    29
    Hi, We purchased your script last week and Ive just got around to looking at it today. I'm seem to be having a problem plotting the nodes over an existing terrain. When I plot a point the mesh moves. I'm I doing something wrong?

    Also I've not read through all your Pdf at the moment but is there an option to have grass fall off is specific areas? for example a path going through a meadow the grass is smaller near the path and eventually no existant where the path is.

    Thanks
    Wayne
     
  17. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Hi, please go thru pdf first. There is everything described in detail :).
     
  18. wr_uk

    wr_uk

    Joined:
    Nov 3, 2011
    Posts:
    29
    Hi, Got everything working good with the grass and how I wanted it to look for a particular job I'm working on over the weekend. I bring the full directory for the scene into the office this morning open the file and I'm seeing a strange blue flickering in a few areas in the grass mainly where the grass edges are or where the grass intersects with and object. I also get message in the console 'The references script on this behaviour is missing!'

    $scene.jpg

    I'm a 3D artist and have very little experience with scripts. Do you know if the blue flickering and is related to the message I'm getting and how I can sole this?

    Let me know if you need me to send you the file though if you need a proper look at it

    I've also done a import again directly from the asset store into a clean project with nothing else in it just in case I accidently deleted a file while in transit. First off I get this message after import: 'Assets/VolumeGrass/_Internal/Editor/VolumeGrassEditor.cs(747,70): warning CS0618: `UnityEditor.Undo.RegisterUndo(UnityEngine.Object[], string)' is obsolete: `Use Undo.RecordObjects instead'

    'When I build grass I get this error: 'Shader error in '': Parse error: syntax error at line 1'


    The grass was working on my PC at work last week so that would rule out a compatibility issue with the PC

    Thanks
     
  19. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Hi,

    Missing script reference in addition to sihouettes cut masking problem I guess you don't have SetupForGrassRendering script attached and setup on your camera.

    Obsolete undo functionality warning - harmless (U4.3 changed things for Undo, but RegisterUndo still works). I'll take care about this in next release.

    "Shader error in..." - harmless message (shader works).

    Tom
     
  20. LastKnownHero

    LastKnownHero

    Joined:
    Nov 4, 2010
    Posts:
    35
    Could this technically be applied to an animated humanoid model??
     
  21. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Theoretically - yes, but you should expect problems with silhouettes. You would need to apply this material yourself. Also - I assume this would be meshskinned which could introduce artifacts (in case normals/tangets are not properly animated in companion to mesh deformations). I guess you'd like to simulate fur this way. I saw such usage on bear model and somebody tried it already. Wasn't bad, but works fine only for short fur.

    Tom
     
  22. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    First thanks for this awesome tool, love it. a few problems tho.. How to I increase the radius view of it? I'm only getting a few feet of it.




    Also. Why does it look like this? Your project the Meaw thing looks alot better. Anything Im doing wrong?




    Also, your tutorial about the Z pass. I cant seem to find "Grass depth layer? who do I do that? Pleaseee reply asap.


     
  23. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    Alright I managed to fix all the above. I found the radius view distance thing. But when increaseing the radius, I get this white thing in the back far distance, when I put it back to a low number its gone.. What's happening?

    Picture...

    http://puu.sh/7SrIs.png
     
  24. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    Any help????
     
    Last edited: Apr 1, 2014
  25. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    Another problem....the z pass thing still wouldnt work. I tried with the sphere, i even created a layer called grass depth and it still doesnt work, yes I even change the layer on the sphere to grass depth, and In the maincam rendergrassetup script...

     
  26. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    On the screenshots above I see:

    1. you're trying to span grass all over terrain, even at the blocky mountains. This will never look good when you stick grass to steep objects. Instead you should split you grass into many smaller parts and place them, on the gorund and eventually on the tops of mountains (as separate meshes)
    2. when you vg mesh consists of very big triangles you'll experience distortions when grass is viewed up-close and viewing direction is almost parallel to the grass mesh surface
    3. on such big areas covered by grass you'll need to comment custom hash function in shader defines section - refer to pdf documentaion, this has been also mentioned here on the forum before.
    4. grass silhouette cut works only in play mode and when you properly setup things. You need to attach SetupForGrassRendering.cs script to your camera. Compare with me example scenes where things work. Your "white thing" in the back might be also caused by the reason you acutally haven't setup your camera properly. If you like to have proper intersections with grass you need such objects to be placed on separate layer (no matter the name of the layer "grass depth" anything else). You should point this layer as a parameter for mentioned script that need to be attached to the camera.

    Follow my pdf documentation. There everything with in-depth explanation of how it works.

    ATB, Tom
     
    Last edited: Apr 2, 2014
  27. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    I got most things to work. Also. How to get rid of the noticable tiling in the grass plane? And why is the shadows on top of the grass and. An not in it? Can this be fixed??? I'm using dynamic shadows.
     
  28. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Grass takes it's data from one texture, it's unavoidable we'll see some similarity patterns. It also depends on how random is slice hashing function. To introduce more variation over grass apperance I introduced 2 colorization factors - for grass bottoms and upper part, their vailes are taken from noise textures and agrass is there colorised by "Slice bottom coloring" and "Noise coloring". They've got separate tiling vector to be set next to them in inspector.

    Shadows for VG are always received at their top surface, not inside. That's why VG works fine for shorter grass rather.

    Tom
     
  29. Baldwin

    Baldwin

    Joined:
    Apr 1, 2014
    Posts:
    37
    So there's No way to put them in the z pass to the shadows could be in the grass? If not I'll have to consider using a different plugin.
     
  30. rgoomes

    rgoomes

    Joined:
    Dec 12, 2012
    Posts:
    6
    Hi, I have followed the steps of the pdf inside the package but all I see is a pink material after generating the grass..



    .. and I think I found the problem.. Apparently the compilation of the shaders generate some errors, but the problem is I don't know how to solve it nor even how to code shaders.



    Any help??

    btw, testing the grass on Unity 4.5.0f6 free version and my graphics card GT540M runs dx11 and supports shadder model 3.0 and above..
    ..
     
  31. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    There's solution for DX11 on previous (8th) page. You need to add 3 lines in vert function in side shader.

    Tom
     
  32. rgoomes

    rgoomes

    Joined:
    Dec 12, 2012
    Posts:
    6
    Thanks Tom. I changed the code with MonoDevelop.. now how to compile it again, so the "Grass.mat" change from that pink color?
     
  33. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    If you changed it right way and saved in MonoDevelop shaders should get recompiled automaticaly. If not - right click them and select reimport. Actually there are 2 shaders in package - VolumeGrass.shader and VolumeGrassALT.shader, but 2nd one is used in opengl only. However it can be also used on PC in editor when "use alt shader in editor" checkbox is selected in VolumeGrass inspector. So - uncheck this to be sure that Grass.mat used uses VolumeGrass.shader, not this "ALT" version.

    ATB, Tom
     
  34. rgoomes

    rgoomes

    Joined:
    Dec 12, 2012
    Posts:
    6
    That worked! Thanks again Tom!!


    I have one more question.. is there a way to fix "the missing planes" when you're looking right straight to the grass like this:

     
  35. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    The only thing you can do is increasing "Bending for sharp view angles" slider, but this won't resolve the issue completely. Simply VolumeGrass is "billboard" system but realized in texture space, which means as many billboard as you wish with no polycount overhead. you could try to make underlying terrain color uniform and turn off drawing the floor of volume. It's adjustble in shader code via #define keywords. Refer to docs.

    Tom
     
  36. rgoomes

    rgoomes

    Joined:
    Dec 12, 2012
    Posts:
    6
    The "Bending for sharp view angles" can only be changed in the shader code right? Default is 0.85 in a range of 0 to 1.. So to increase the billboards at maximum I change it to 1 and compile the shader?
     
  37. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    No, bending is just material parameter. Play with this and you'll see what happen with the grass.

    Tom
     
  38. rgoomes

    rgoomes

    Joined:
    Dec 12, 2012
    Posts:
    6
    Okey, thanx!

    One more thing.. I dont have a "grass depth" layer on editor. Do you know why?

     
  39. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    As I remember you've got Unity indie - in this version of VolumeGrass you cant cut silhouettes.

    Tom
     
  40. will_jones

    will_jones

    Joined:
    Dec 20, 2011
    Posts:
    78
    Hey just purchased this,

    Is there a way to get wind working properly? Do I have to have a terrain underneath? I'm trying to see what's different from the meadow grass and the soccer grass but the wind parameters in your script don't have effect in my scene
     
  41. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Wind feature is optional/configurable, so it needs to be enabled in shader code. Look for #define WIND and uncomment this for soccer subshader.

    ATB, Tom
     
  42. RTSlang

    RTSlang

    Joined:
    May 3, 2013
    Posts:
    57
    Hi I'm still having trouble with the pink color on the grass and nothing happening to the mesh in any scene. I replaced the two shaders with the code properly. I even reimported them. Im stuck!
     
  43. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Give me your order number and date in private message. I'll send you working shaders then. I assume you've got troubles in DX11 ? Which version of Unity do you use ?

    Tom
     
  44. RTSlang

    RTSlang

    Joined:
    May 3, 2013
    Posts:
    57
    I am using the newest version. 4.5.1f2. DX11 was enabled by default when I import volume grass so I guess yes to that question but turning it on or off doesnt make a difference. I purchased this a while ago and have been digging through emails for 5 mins. Is there an easier way for me to find my order number?
     
  45. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Unfortunately not (about order number), but I can agree the solution you suggested in private conersation.

    Tom
     
  46. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    Volume Grass is on Supper Soccer Sale till the Germany-Argentina final. Grab it %50 off as low as $37.5 ! Unfortunately I wasn't able to finish VolumeGrass 1.5 before sale started but I'll ask Asset Store staff to put new version ASAP.

    Main improvements comparing to VG1 are:

    1.Simplier, more intuitive and clean user interface.
    2. Custom material inspector for grass shader. No more "space shuttle cockpit like" look. All features grouped logicaly and to be enabled / disabled dynamically. So no more need to configure shaders by hand - it's all available via material properties.
    3. Grass is textured basing on world global coords, you don't need to worry about how to put VG on your mesh. There is dedicated script that will turn your flat model into volume grass, carving sidewalls and managing basic parameters, rest you can do using new material inspector
    4. brand new wind handling. you can specify one directional and one spherical wind zone to affect the grass. Look at the new meadow demo for more info
    5. new editor that makes your life easy when you'd like to customise grass look. You can make gras billboards texture out of source elements (separate grass blades, flowers, leaves and so on).
    6. New IBL lighting to follow skyshop cubemaps or your own HDR/LDR skyboxes

    Tom
     
    Last edited: Jul 11, 2014
  47. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
    THREAD CLOSED - Volume Grass 1.5 is on the way and new thread has been started here
     
  48. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    where is plane (extruded) stored?

    also I'm having trouble storing saving grass as prefab, how can i do this?

    I want to be able to instantiate grass platform but it's just empty.
     
  49. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,842
     
  50. hanrysmith

    hanrysmith

    Joined:
    Feb 14, 2018
    Posts:
    1
    We have a ryobi 40V lawn mower, blower, and trimmer with 2 batteries. We love all 3. We have a large yard so the mower uses 1 1/2 battery but leaving enough charge to do trim and cleanup with blower. Then back in the two chargers and ready for the next week.
     
unityunity