Volume Grass system on Asset Store soon

Hi there,

I’ve decided to move discussion here from thread:

http://forum.unity3d.com/threads/76748-Volume-grass-system/
(if you have any questions read above thread first)

Volume Grass system is nearly complete. If only below links work on every Mac (that with GPU of SM3.0 / conditionals compatible cards) the only thing is write a bit of documentation and I’ll submit the system to the Asset Store (counting that Unity staff response reasonably fast because a few people asked me about release date):

http://www.stobierski.pl/unity/meadow.html
http://www.stobierski.pl/unity/soccer.html

The demos and used assets will be included in the package together with some additional scripts/goodies to help setting up quickly.

The system will consists of grass mesh editor - you’ll be able to conveniently place grass areas of any shape/coverage on the ground and the heart of the system - special volumetric (raytraced) shader to render it (so beware of performance that should be reasonable for mid range GPUs - SM3.0 with conditionals / texture2Dlod compatible at least).

So - please report me any issues before I submit the content to be sure every potential customer (esp. Mac one where some issues with shader occured) will be satisfied.

EDIT - the package is already on AssetStore.
Two additional links for potential users are:

Example workflow:

Docs as published in the package: http://www.stobierski.pl/unity/VolumeGrass.pdf

EDIT - VolumeGrass v1.1 (mowing expansion)
By request of a user new mow expansion is ready on AssetStore, look at live demo available:

http://www.stobierski.pl/unity/lawnmower.html

This tweak can be also used to cut grass randomly - when we use noise texture to modulate grass height (like in lawnmower example) we can achieve effect of “bumpy” grass with even more depth apperance comparing to the original.

I also tweaked a bit grid revealing when viewed at sharp angles. One may refer to new version of pdf docs available. I made some minor changes to documentation and adjusted it to mowing extension.

For some GPUs configs (for example Win XP, 7900 GS) z-testing has been fixed so ball and lawnmower properly intersect grass.

Everything at new better price ($75). This is what I meant by repricing it “a bit”. I believe now it should be attractive for more users.

EDIT:
New Volume Grass (1.5) is submitted for Asset Store. Can’t tell when it will be ready to get. You can look for new thread here:

as a sneak peak for new version I update here some pictures:

I’ve got additional wish to Mac users.

Please, test the following links on various Macs (except for nVidias GF8000 and above, because I already know all optimizations works without crash as in very original version of shader - tested on d3d9 - PC):

http://www.stobierski.pl/unity/soccer_MACTEST_A.html
http://www.stobierski.pl/unity/soccer_MACTEST_B.html
http://www.stobierski.pl/unity/soccer_MACTEST_C.html
http://www.stobierski.pl/unity/soccer_MACTEST_D.html

Please report which of above versions eventualy crashes the player (or doesn’t work at all, however they might look weird).
Testing result might greately help with Mac shader version and it’s optimization issues. I’d like the shader works as fast as possible on the widest range of machines.

ATB, Tom

Nice grass, this looks very cool. How easy it it to change the style and look of the grass?

Easy :slight_smile: I’ll probably upload some tutorial/demo on youtube soon with quick workflow overview.

I look forward to it. Could be a great asset in my current fantasy project.

Wow, just wow. Is it actually possible to use it as ground instead of the plain old texture way to go? How perfomance heavy would it be?

Don’t know what exactly you want to achieve, but this grass system can’t be replacement for terrain (ground). In simple case (like soccer field) it’s just a slim “box” mesh with special shader that renders grass inside such “box”. You could give it the mesh collider, but it won’t work good as collisions would be detected at the surface of grass rather than on it’s “bottom”. In soccer example I put plane collider below grass mesh so ball behaves like it should.

It looks really amazing.
I’m wondering if you need to be, or have already been, considering the copyright of UNION Agency - Science Press, Plzen, Czech Republic written into the original paper on the first page, you linked to in your previous thread?

They’re pure scientists, researchers. I’m only a man who pushes their ideas to the limits :slight_smile:
Refering to the paper from I’ve got the original idea. No part of the paper was copied, nor original Habel’s code was used. I’ve implemented the idea own way. In fact I found much more compact formula to describe tracing the ray (comparing to the original HLSL source code). To be sure I also contacted Ralf Habel about using the idea in my project and it turned out it’s not restricted.

Tom - any ETA on when this will be available on the asset store? Also, how is the grass handled - do we “paint” it on the terrain as per the current foilage option in the terrain inspector (i.e. is applying this to an area integrated with the unity3d editor)?

I’m just finishing submission pack, so AssetStore staff get it today for revision. I’ll try to make youtube movie today, too. Thank you for your patience, stay tuned :slight_smile:

Sounds good :slight_smile: - thanks for all the work and best of luck with this project, count me in for sure!

VolumeGrass is on AssetStore now.

Example workflow movie uploaded on youtube, shows how to create grass mesh area, modifying coverage, configuring object to intersect grass:

http://www.youtube.com/watch?v=04TaWOmWsCM

If somebody want to take a look into documentation before buying the package, pdf file is available here:

http://www.stobierski.pl/unity/VolumeGrass.pdf

Great product, best of luck to you!

Oops,

I’ve just found one little bug. Users - please put nodes clockwise when building grass shape. Puting it counter clockwise causes problems with sidewalls :).

For people curious about “how easy is to tweak grass look” - please refer to package content on AssetStore (no necessity to buy the package to do it of course) . You’ll find grass_blades.png in _Textures subfolder which defines slices of grass grid rendered by shader. Further look can be adjusted by right coloring grass in shader params (by fully adjustable / custom noise textures).

I love it :slight_smile: Looks absolutely natural.

What about performance impact? What if i use it on whole 2000*2000 terain? How LODing works? What is better, one big mesh for whole terrain, or many smaller meshes?

BTW, I like your documentation. This is nice example, how should be Unity documented, for example new pro water. Unity documentation team should learn from you. I would recommend them to kick current documentation team manager and hire you :slight_smile:

Splitting one big grass mesh into several small ones is definitely better idea. Umbra can occlude completely grass models hidden for example behind hills, buildings, etc. Considering shader itself the most important factor is platform. On PC grass always uses optimized version of shader. On Macs grass system uses optimized shader only for higher nVidias. On other GPUs on Mac alternative version of shader is used. Visual result is exactly the same, but that shader doesn’t benefit from many optimizations.

The major optimization available is far distance. For distant pixels (distance adjusted in shader properties, in my demos it’s about 20meters) shader skips most of its calculations. Only 1-3 (depending on settings) texture lookups are performed to determine pixel color and fragment program breaks. So - if you make one huge grass mesh on your 2000x2000 terrain, you won’t notice any performance hit (for optimized shader - PCs, nVidia Macs) that fragment program could introduce for distant areas of grass. Original terrain shader also has a few (4) tex lookups at least, so for distant pixels grass shader renders as fast as terrain shader. The only slowing down factor is then complexity of mesh (number of polys). I guess for huge terrain with many hills mesh that has to be build for grass would consists of several tens thousands triangles. Upper limit in the engine is 40000 vertices/polys. You can’t build grass mesh more complex (I put this limit because its safe for triangulator which could crash beyond). I believe that optimal number of polys per grass mesh is about 5000-10000 for larger areas. Example meadow scene has 8000tris of grass mesh, but could be much smaller if we adjust build settings compromising grass mesh smoothness on hills.

Again - splitting into small pieces will be better in terms of occlusion opportunities (grass is always static object, isn’t it ?). Don’t hesitate to split your grass into meshes of even a few polygons, because bottleneck is not vertex count here (unless you try to render >10000-20000 polys), but fragment program which is quite expensive.

LODs in mesh editor works on per distance basis. You can prepare up to 4 LODs (grass meshes) with decreasing number of polys and decide which mesh will be used on specified distance. This would work similar to Unity’s terrain which reduces number of polys on far areas. I put it into the system to give users the best opportunities available, but in fact, when you wisely use occlusion, you’ll probably don’t have to use as many LODs. First, as I said, performance bottleneck lays in fragment program, not in vertex program. Furthermore - using 4 LODs with for example 10000, 8000, 6000, 4000 tris will cause your player weight will increase considerably. In practice I believe that 2, max 3 LODs are enough.

Next optimization is that you can specify quite different shader (material) to be used for very far, specified distances at which user probably won’t see any difference between “Vertex Lit” shader and grass shader. So - if you split grass areas on your huge terrain into smaller pieces and specify that on very far distances it should use different, simple material, it will work as fast as possible.

The last optimization (that works on every platform) is that when you build grass mesh and cut several bare “holes” (for example paths) with grass coverage brush tool, then triangles that are whole cleared from grass are skipped at once - that is, instant clip function at the beginning of fragment program skips everything and that areas costs NOTHING.

As one may notice when preparing VolumeGrass I put much concern into performance issues. I made literally hundreds of tests and tweaks to push shader performance to the limits. Believe me or not - it’s not easy to optimize shader programs with complex structure and conditional instructions inside, because every single decision on how and where place some calculations might have dramatic impact on performance as, unlike CPUs, GPUs are designed to work parallel. Hopefully GPUs of todays low-mid range level like ATI HD 4650 (available at prices below $50) will be history in a year. That’s the time you’ll polish your game :slight_smile: and then most of users could benefit from our nice looking grass. As an example I tested meadow scene on such ATI HD4650 and it worked easily 60+ fps (webplayer 800x600).

Final word about performance. With such expensive shader as VolumeGrass shader is, try to use forward rendering. If you put only one dynamic light, and rest is lightmapped, everything will be rendered in ONE pass. In deferred there are always TWO passes which has to be considered for grass shader… Of course if you want to have better shadows and many dynamic lights on scene, use deferred. In such case it’s worth using even if grass shader has to take it in two passes.

I hope this thorough post explain many eventual doubts.

ATB, Tom

P.S. thanks for nice words about my documenatation. Honestly, as I’m not native speaker I was anxious if Unity refuse my submission because of my English, but it turned out it’s not that bad… :slight_smile:

Thanks a lot! This is really perfect answer, now I know everything I need to know :slight_smile: I wish Unity support worked same way, because exactly such documentaion and support saves literally tens of hours of experimenting and frustraton. You are living proof, that if there is will to do it right way, it can be done.

P.S. I am not native speaker too.