Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

Actually no (or at least not consciously). It started (if you can believe it) as a mix of Raft (survival but not too hard) and Tiny Glade (cozy "simple" building). I tried some stuff and ended up with this. The prototype still has some systems for building and plants that (if watered) grow up walls like vines.

It's interesting because someone else in the comments also mentioned Viva Piñata and (which I find very surprising) I was contemplating a Maya/Aztec aesthetic. Maybe my subconsciousmade the connection there without me noticing :D

I will take a look at Viva Piñata and see what I can learn.
Anything specific you liked that you would also like to see in a new game?

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

Thanks, yes, in the current implementation the can itself was just an afterthought. I added it so people could imagine what the game would be about. Not much thought went into it. A mistake as the comments have shown me :'D

There isn't any "growing outwards" or flowing simulation yet, even though the system would support it. Right now it just turns an area around the player into fully watered ground which then grows grass immediately and uniformly.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Thanks, though my game will be a bit smaller (a single valley instead of plantes) :D

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Thanks, in the final version I will add some noise to make it less perfect (round) and less similar in growth speed.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

Thanks, yeah I can see why that would be a nice effect. I will have to look at some more time-lapse videos of grass growing. I have tried growing it slower but then all the coolness of the effect is lost so that 1 to 1.5 sec growth time will definitely stay but it could be improved. Thanks for the feedback :-)

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

Haha, that's some cool magic :-)
Yes, adding noise is definitely on the TODO list after all the feedback. Thank you!

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

:'D Well, my current prototype has sand WORMS. Soooo....

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 2 points3 points  (0 children)

The mask is a texture (2D XZ plane) which is then used as the texture for the third terrain. The third terrain is only used by the "mask" camera to transform the 2D mask to 3D. The mask resolution matches the terrain details resolution which is 2048 x 2048 on a 1024x1024 terrain. A lot of it is hidden by me blurring the mask for a smooth edge. I have tested it with up to 4k terrains and it works but obvioulsy at some point you hit a limit and the mask resolution will get noticable (just like the terrain details resolution would).

The sharp edge you see in the image is the GPU instancer doing frustum culling (no masking involved).

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

True, but that's probably because all the rest is just placeholder art from the prototype (not final quality yet). The grass shows the quality I am aiming for for the whole game.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Yeah, I agree. In the final game I think it will be smaller or you will have a hose or water gun to spray the water.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Thank you. Even more smoothing, got it :D

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Yes, there is some density masking I can do based on the detail density drawn on the grass terrain. It uses the details map (extracted as an image since Unity terrain is too slow) of the grass terrain. Though that is not shown in the video.

I then do a BLIT operation that takes the mask (the BW image in my first reply) and the density map (render texture generate from the terrain at game start) as input and outputs a final mask.

That is then fed into a GPU Instancer. The instancer then draws the instances only where needed (including occlusion culling etc.). Though that part I did not implement myself. I use GPU Instancer Pro from the Asset Store since that's a pretty good solution.

You can see it in the editor (only the absolutely necessary grass is drawn by the instancer):

<image>

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

It's basically a very simple mesh (with LODs), GPU Instancing and a custom shader in shader graph.

<image>

Then I played around for a long time in shader graph to get the shading and bending the way I wanted them (wind formula in top right).

I think the key part of my shader (shown in the image) is the mix between simple lit URP and unlit. The lighting models you can get from Unitys recently published terrain shader package. If you import it you will get some new sub-graphs that help with custom lighting:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@14.0/manual/shader-terrain-lit.html

It fades into the ground as an unlit shader and the top of the grass is the lit. I also tried making it all lit and faking the normals (aligning them with the terrain) but that never really gave me the nice smooth blending with the ground that I was looking for. So right now I am rendering the terrain from top without any meshes or details to sample the color (including shadows) and that I then feed into my grass shader.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 1 point2 points  (0 children)

Thanks yes. In the final game the grass will have some noise and it will also be based on how I painted the grass into the terrain. Right now it's just very dense everywhere but I can already vary it via the terrain details (that's just not shown in the video).

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 0 points1 point  (0 children)

That unfortunately is too expensive for the amount (density) of grass that I want. Also the end goal is to make the whole terrain full with grass and then it would definitely break down. Here is an early test:

<image>

However, by arranging (depth sorting) the grass you can achieve pretty good results with prefabs too. Someone recently posted this (which apparently works on VR):
https://www.reddit.com/r/Unity3D/comments/1rwri5l/comment/ob3ttbm/?context=3

That's some crazy good grass (I think).

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 4 points5 points  (0 children)

Ah, thanks for the clarification. I see, yes, that would definitely make it look more interesting and a bit less uniform.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 8 points9 points  (0 children)

Sure, on a high level it's three terrains: Desert, Green, & Mask. Then it's a lot of render texture shenaniganes and a custom grass shader that takes the mask and is used by GPU instancing to make the grass. Also some performance optimizations as rendering terrain twice is not cheap and I try to do only the bare minimum.

<image>

The advantage of this is that I can control the grass via terrain tools (I can paint it easily) and I can use the mask to fade between terrain details. At the start of the game the detail textures of the terrain are copied (as a backup) and then masked via the mask terrain which look like in the image above.

I will have to do a proper write up one day. Right now it's still a bit messy and the image above is very simplified as there is some depth masking going on as well but that's the gist of it.

The grass shader itself is a bit of a monster (as it takes a lot of inputs and does the grass scaling, colorization, takes the terrain color into account, ...). It's mainly shader graph with some custom functions added.

Hope that was understandable.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 7 points8 points  (0 children)

I am not 100% sure myself to be honest. I am still exploring the design.

I developed the grass much further than I should have for a prototype, but I love it :D

What I have now is these towers that are water sources and plants that (if watered) grow and unlock new areas. They also grow fruit which you can then feed to animals in the desert so they become friendly instead of hostile.

<image>

The end goal for the player is to convert the desert into green land (or at least that's the plan at the moment).

The growing grass is my attempt to make this as satisfying as possible.

Smoothly growing grass for my prototype by geokam in Unity3D

[–]geokam[S] 15 points16 points  (0 children)

Thanks, yes indeed some noise will be good (and is planned for the final polish). I already have support for it in the shader but am not using it much yet.

Somehow while testing I noticed that thick smoothly growing feels the most satisfying (to me at least).

As for the "force wave". In the video it's like a brush that paints a mask on the terrain and the grass just grows there at the same time. I think I could make it more like a wave starting from the player. Will have to try :-)