Search Unity

Volume Grass system on Asset Store soon

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

  1. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I sure do wish my wad of cash turned into the plugin. I have the money but I don't have a credit card.
     
  2. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
  3. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    What about Paypal? (Though i don't like paypal myself). Also you can also get those temp visa cards (just numbers really) which you fill up with a set amount of cash, and then you can use them online like a normal credit card, but without the risks since it'll only have as much on it as you put in, kinda a hybrid debit card.
     
  4. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Supa, so how did you get Unity Pro license ? :)
     
  5. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Oh, oops, I didn't know this plugin requires Unity Pro. Oh well.
     
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Not exactly. It would show the grass but without right intersections between grass and other objects. Grass coverage wouldn't work (so only full height available like on soccer field). And lawnmower example wont work as it also uses rendertexture (unless you implement grass height texture another way).

    Unity Pro requirement is mentioned on the AssetStore package description.
     
  7. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    I see. Thanks for the information.

    Perhaps someone could provide screenshots/video of how it looks like on non-Pro, or is it not worth getting at all it if you have no Pro?
     
  8. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I built 2 players with z-testing disabled (required render textures). This way it would work in Unity Indie:

    www.stobierski.pl/unity/meadow_indie.html
    (look at the bottom of the tree and terrain grass in meadow scene)

    www.stobierski.pl/unity/soccer_indie.html
    (look at the bottom of ball)

    No grass blades can be displayed over the intersecting object. Grass object is treated as solid in terms of depth-testing.

    However - there is one trick. One can use _CameraDepthTexture instead of render texture to get right intersections (I described it widely in shader code), but will have to turn the grass into transparent, so - forget the shadows on grass. Or - if you find better idea to get depth buffer of camera WITHOUT grass mesh renderd into it - feel free to tell me :) (maybe tricks with 2 cameras setup would work somehow, but this is only speculation).

    ATB, Tom

    P.S. As you see in meadow_indie scene - grass coverage will work right which I told you it wouldn't. So shorter grass areas are possible as they not rely on render texture. Good for Indie users :)
     
    Last edited: Apr 1, 2011
  9. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Do I need always to combine your Grass with Terrain, or I can cover with it any mesh which actually represents a ground level, or even use it without any under layered object?
     
  10. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    You can use any underlying mesh (we need its collider) or without anything below, grass mesh will be built on plane of y=0.
     
  11. josh_sg1

    josh_sg1

    Joined:
    Feb 19, 2009
    Posts:
    325
    Hi,

    The Product is amazing.

    I like it a lot. I want to know if I can develop it on a different engine. You say it is a shader. I want to add it to the Visual3d.NET Engine.
     
  12. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    If you have at least basic knownledge of writing shaders it should be possible to implement it in any engine (that allows to write vertex/pixel shaders). However it relies on custom depth buffer which is needed to solve z-test (intersection between volume grass mesh and other objects). Originally it has been solved by writing into depth buffer (refer to original thread and reference to Ralf Habel's article), but Unity shaders can't do it. Doing so has also impact on performance.
     
  13. josh_sg1

    josh_sg1

    Joined:
    Feb 19, 2009
    Posts:
    325
    That is AMAZING and Visual3d.NET is a lot more powerfull than Unity 3d. I like the z-test Interaction that is great. I want to know if the interaction of footprints and tank treads can be added to a script like that and if scripts can be mod to react to wind and effects like a Helicopter and Fire, burning a field of the grass and possible to interact a shovel the grass script where you can shovel the ground and sand particles and grass collect into stacks of poly and the stacks collect together into large models etc.. I developed the concept for my game project though I do not know you can do that with shader. Your shader is amazing. I can talk to my programmer I know we can do it if you think it is compatible and I want to know what that added depth buffer would do. It sound like fun to try. If you think that is possible and if you are available I know you prol work a lot I am interested in designing the shader to work on Visual3d.NET.
     
  14. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Josh. There is no such thing like "z-test interaction". Only z-test _intersection_, so objects that intersects grass volume are "visible thru". Talking about interaction with grass. Look at soccer demo. I implemented there simple method of bending grass below the ball, but more general solution (footprints, tank threads), although possible would not be that simple to implement. Reaction to wind generated by helicotper - possible. About more bells and whistles - you've bombarded me with bunch of ideas which, if even possible, wouldn't be easy to implement (sand particles ???). I'm not competent in Visual3D.NET, so I can't tell more. Anyway I didn't use here any techniques that are strictly Unity dependent in terms of shaders coding. Of course, doing such shader for another platform will require some effort, and such shader alone is not everything. The shader is used on special model with proper uvs, tangent, color info.
     
  15. josh_sg1

    josh_sg1

    Joined:
    Feb 19, 2009
    Posts:
    325
    That is great, Developing a shader like that is a lot of work you say. I know the results of it would be amazing enough to surpass that of the big guys in the game industry. I know what I am talking about when it comes to a Dynamic Interactive Environment, and Developing Explosive Gameplay for Players as I have Design for my Game Project.


    It is great that you are talking to me about it as I need to know that about the shader interaction as the grass is amazing as it is, with a feature pack it would be Speed Tree Level Products.


    I know it is a lot of work. If it can design the shader on Visual3d.NET the community there would like it a lot as I do already for presenting that it is possible. I like that you have done it and it load great on a web player that is amazing and I know right from there you are great at what you do.
     
  16. tarragon

    tarragon

    Joined:
    Dec 28, 2010
    Posts:
    38
    Will the sources(shader..) be part of the package as well, or just binaries?

    I would welcome access to sources for this gem.
     
  17. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    There is no such thing like "shader binaries" in Unity... Every shader used in Unity has its (open) source code, even these built-in. But as I said - shader is not enough to use the system convinient way. That's way my package consists of editor which gives an opportunity to cover choosen part of ground with right mesh with right shader setup in seconds.
     
  18. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    look nice!
     
  19. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    2tomaszek: I am quite currious, how this will look with some more realistic grass "texture". Current version in demo is quite "comic-like". Do you have any screens with diffent grass textures?
     
  20. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Good news about it - user may try any grass texture (what's rather obvious) :), but this moment I don't intend to prepare another artwork for it. Maybe in future release I'm thinking about I'll put more textures by default into the package.
     
  21. Fierce Waffle

    Fierce Waffle

    Joined:
    Dec 23, 2010
    Posts:
    93
    I recommend changing the title to "released" rather thann "soon to be release". When you edit the thread simply click advanced editor and it will let you change the title.
     
  22. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    @Fierce Waffle - how could I "edit the thread" ? I'm looking for such option for a while but I can't see anything like this.
     
  23. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hik tomaszek, I have been searching for a way to replace the traditional billboard system that is used in Unity. Your extension look's great. I need my grass to be 'compatible' with beast though, as I am doing a large visualization project. Can you tell me how it is designed to work with Unity's lighting setup?

    Thanks alot
     
  24. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Hi kinetiknz,

    The grass is beast compatible as this is treated as regular flat surface during lighting computations. All examples presented (meadow, soccer, mower) uses beast precalculated lightmaps and forward rendering path for best performance (1 pass with shader).

    P.S. Excuse for delay. This thread is almost inactive so I don't look here often
     
  25. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    thanks tomaszek,
    I will buy today.
     
  26. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hey, I can't add the Voume Grass script to any gameobject. It says one of these errors:

    > "Script VolumeGrass has not finished comilation yet. Please wait until compilation of the script has finished and try again".

    > "Can't add script behaviour VolumeGrass.
    The scripts file does not match the name of the class defined in the script!"

    Also on importing I get this error:

    >"A script named 'AnimateColor.cs' already exists at "Assets/VolumeGrass/VolumeGrass Sample Assets/AnimateColor.cs". Please rename one of the scripts to a unique name."
    nb. that AnimateColour.cs script



    It works fine in a new project, but not in my current one. Is there a methodology to deleting assets before re-importing? I tried deleting all dependancies and the VolumeGRass folder, but nothing I do can get rid of that AnimateColor.cs error

    In the console it says:

    "log in file: Assets/PlayMaker/Actions/AnimateVariables/AnimateColour.cs at line: 1

    Is it a conflict with Playmaker?
     
    Last edited: Aug 5, 2011
  27. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Just something to add. I made a new project, then imported PlayMaker and VolumeGrass and VG presents the errors above. I need to use both 'plugins' in my project.

    Any help very appreciated.
     
  28. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    I renamed the AnimateColour script from the volumeGrass section. here;s hoping it won't affect much
     
  29. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Seems like playmaker uses the same classname so the naming conflict occurs. You may change AnimateColor class name and .cs filename for VolumeGrass and it shouldn't mess much.You'll just put my animate color script on the grass object (if I only remember well - I'm on holidays without access to my work PC) to make it work. It's not that important part of volumegrass at all - it simply changes some offsets in grass material (to make an illlusion of coluds shadow movement - it's used in meadow example scene).


    ATB, Tom
     
  30. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Thanks Tom, I have the grass setup the way I wan't it, size position, colour, the only thing I can't get done is baking the lightmap into it. There is no mention of it in the tutorials, but I's imagine the methodology for it is to set the parent gameobject to static. I get errors, because there are no UV's on the emtpy gameobject or the sidewall.
     
  31. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    That's it. I also had to fight against the Beast a bit :). At the end I did it for example scenes so it's definitely "doable". The only problem is setting proper object with grass mesh to be baked.

    ATB, Tom
     
  32. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    I bought VolumeGrass yesterday and tested it.
    Actually it shows the grass correctly. But it reports an error on Console.

    I just created a GameObject and attached VolumeGrass.cs on it
    And added three nodes and pressed build button.

    Anyway, Volume Grass is so nice and handy.
    Thank you!

    OS: Win7 64bit,
    Gfx: AMD Radeon 6800 Series
     
    Last edited: Nov 17, 2011
  33. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Yes, there is error message after you create the object (first time you click "Build"). I can't find the moment it's throwed. Maybe when I mess around switching material/shader on the grass object. Anyway - it's harmless :).
     
  34. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Hi, Tomaszek!

    Is any way exists to rebuild grass mesh in runtime? Because MeshFilter is to big to add it in to the AssetBundle, if all data for grass exists, why not to rebuid it on-the-fly?

    My way, which not work:
    1) I make grass example object, clean MeshFilter and MeshRenderer components from it and build assetbundle with that grass object.
    2) After this I was load AB in to the client with all VolumeGrass classes included (with no errors).
    3) When I instantiate assetbundle no grass appear!

    I was try to add in to the VolumeGrass.Start() method this construction, nothing happined:
    Code (csharp):
    1.  
    2. void Start() {
    3. // ..... all previous code ...
    4. // my code at the end of method
    5. //            MeshFilter mfr = gameObject.GetComponent<MeshFilter>();
    6. //            if (mfr != null) Destroy(mfr);
    7. //            MeshRenderer mr = gameObject.GetComponent<MeshRenderer>();
    8. //            if (mr != null) Destroy(mr);
    9.             state = 1;
    10.             BuildMesh();
    11. }
    12.  
    When I was press Edit/Build Button in inspector tab on selected grass object all works fine! Grass was builded successfully.

    P.S. I was try add BuildMesh() to start and end of Start() method, but any time nothing was builded. All tests was maked in Editor, for pure client/webplayer needs to move Build method out of UNITY_EDITOR define.
     
    Last edited: Nov 25, 2011
  35. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,971
    Whoa! This should be in the asset store's front page!! It's extremely useful!

    You can use a custom image grass quad for the shader, right?
     
  36. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Awesome grass system, I really like the look of this. Is a "transition" possible which allows to make the grass less dense on the outer limits of the volume, to create a more natural look from no grass/less dense-> dense grass?
     
  37. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    sure, look at meadow example at the beginning of the thread - just go to the edge. There is also "a hole" in the middle, near the big tree :)
     
  38. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Hi KEMBL, your idea is just fine, but the BuildMesh wasn't intended to be done realtime. You may, however overcome it by putting necessary functions outside #if UNITY_EDITOR branch. You have to keep in mind:

    - BuildMesh() uses a few additional functions which also have to be exposed runtime
    - build functions uses Editor, EditorUtility, HandleUtility classes calls which are unavailable runtime.

    I'd suggest to copy BuildMesh, and modify it your way. You'll have to disable error/warning tests (at your own risk :) - you have to be sure the mesh will be built w/o problems - this way you can cut from code conditionals which test process and throws messages.

    The critical moment you'll need to tweak is code for assigning grass material (around line 937). As you don't have access to AssetDatabase, you'll have to keep the material with properly assigned shader/params somewhere else and copy it into your mesh after such custom runtime building.

    Build Mesh also uses HandleUtility.ProjectPointLine function which casts Point on vector. As you don't have HandleUtility access runtime you have to take care yourself. Writing your own implementation is straightforward. Just use vector Dot operator for it (quite easy to find such point casting operation when googling).

    BuildMesh uses external triangulator encapsulated in NET dll assembly. You should take this into account, because this dll also has to be included in projector (and increases capacity of projector's build).
     
  39. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Thx, tomaszek, for your answers, they just in time!

    I was fork BuildMesh, already, and start to replace UnityEditor methods to run-time equivalents! Now I can better understand how things flow!

    How do you think, is possible to make lawnmower similar scene for several grass objects in one scene?
     
    Last edited: Nov 25, 2011
  40. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Today, I was complete to rewrite grass script for on-the-fly grass building, all flows success :), but one thing annoying me! :eek: I can't clean grass looking from strange artifacts, which present on it earlier before I start to convert script.

    Please, Tomaszek, take a look to this pictures, all grass setup just like in meadow example, but in my own scene strange slices wraps grass looking!!! :confused: It looks like interference pattern.
     

    Attached Files:

    Last edited: Nov 26, 2011
  41. romeo_ftv

    romeo_ftv

    Joined:
    Oct 20, 2009
    Posts:
    36
    try comment all #define CUSTOM_HASH_FUNCTION in GrassShader.shader
     
  42. KEMBL

    KEMBL

    Joined:
    Apr 16, 2009
    Posts:
    181
    Thx! This realy works!

    As you mentored, I comment all
    comment all #define CUSTOM_HASH_FUNCTION lines
    and change all
    #define HASH_OFFSET CUSTOM_HASH_FUNCTION
    to
    #define HASH_OFFSET
    in GrassShader.shader

    Thank you very much! This step completes work to move grass script in to assetbundle without any mesh with possibility of post rebuilding of it :)
     
  43. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    @KEMBL - lawnmower version of subshader isn't any problem using it with many grass objects in scene. You can mix different grass subshader objects in one scene, too (just set different compatibility "level" for different grass objects so they use different subshaders).

    @romeo_ftv - I'm so happy users like you go deeper into the grass construction and reads #defines section in shader code which I've made so richly commented exactly for that reason ! KEMBL problem was - although my custom hash function works pretty well in terms of performance (no need to access random bitmap function), on some GPUs it may generate rounding error artifacts. It's shame random function is almost non implemented "standard" on GPUs, so we have to implement it other way. Maybe array instead of bitmap acess ? Well, let users find their own best way to hash slices (when we disable hashing, grass has noticeable "patterns" along).
     
  44. ilya_ca

    ilya_ca

    Joined:
    Nov 19, 2011
    Posts:
    274
    Hello, will this plugin work on iPhone? I want to display a relatively small amount of grass.

    Thanks!
     
  45. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Nay, will either crawl or not work at all. It's rather expensive shader. I believe in 2-3 years mobile devices will be able to handle it.
     
  46. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Hi there, Unity 3.5 compatible versions is released. For users using Macs and trying to use my package there is a problem in U3.5. I had to tweak a bit shader code because U3.5 OpenGL compiler seems to have serious bug that unable to compile it (just used fract function with ? comparison operator and ... Cg compiler got nutz resulting in buggy uncompilable surface shader code). One of customers told me it doesn't work on his Mac so I've decided to upload new version. Meanwhile there were a difference in shader compilation in U3.4 (soccer ball shader in one of example scene didn't work). Now everything is up and running.
     
  47. kinetiknz

    kinetiknz

    Joined:
    May 5, 2010
    Posts:
    173
    Hi there?
    I have been using your script for a while and never really had problems, but I just tried to re-do a grass and I get a solid brick instead of blades.

    If I make a new project and build, it is fine. So obviously it's related to my project.

    I have deleted the VG folder and re-installed, but still get a brick. I have uScript,EZGUI,Cubegen and Hard surfaces Pro.
    So one of these could be interfering, though I'm not getting any errors.

    Do you have any ideas as to the cause/solution?
     
    Last edited: Mar 22, 2012
  48. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    When you see "brick structure" (virtual grass planes perpendicular to the ground) seems that shader itself works fine, but it doesn't have proper texture assigned. You may try to fix it manually assigning grass blades texture to shader after rebuilding. The reason of issue is probably some of your installed component got texture which is interpreted by my system as grass blades texture. If you see nothing but solid geometry shader is not working (diffuse fallback - look at compiled shader properties - there should be no errors) or material assigned to the grass is bad (interference with other material on scene so VG is not assigning right material but another one).
     
    Last edited: Mar 22, 2012
  49. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    Just now taking a glance at this tech. Can I change the art used for the grass blades? Interested in using it for thick carpet of varying lengths.

    Thanks!
     
  50. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Sure you can. Not only adjust bitmap with blades but also length, coloring, etc. However doing carpet with fancy pattern would require some work and could probably not meet your needs with "out of the box" version but its not that hard to mix colors inside shader the way you need (in soccer example I use coloring channel to put white lines and grass mowing patterns and such grass coloring IS "out of the box").
     
    Last edited: Mar 29, 2012