Reduce Grass Density by Distance

The Grass Generation at Material is awesome but currently it is hard to get a soft transition at cull distance. With the “Per Instance Fade Amount” Value you can soften it a little bit but a better (or additional) approach would be to reduce the density of the Grass by distance. With this Method you can save performance too.

+1000 would be very useful

Any Feedback from Epic?

+1 , i need that too.

Hi everyone,

Thank you for your request. I have entered a feature request, UE-24865, to be considered by the development staff.

[= ;447455]
Hi everyone,

Thank you for your request. I have entered a feature request, UE-24865, to be considered by the development staff.
[/]

Great! This feature would be very useful.

Thank you very much!

+1000 for grass density transition

+1000 for something to have more control over the density.

I’ve been experimenting with this for a few days and in the end I finished doing something that works, but I think is not the best. It would be better to have some parameters on the settings to define the maximum density and minimum and interpolate between these with a gradient over distance.

What I did was play with the cull distance, so close to the camera I have more density and far away less density using 4 grass types, Is not the ideal but at least I win some fps ( the 4 grass types use the same mask on the lasnscape material). The grass meshes have 20 tirs (5 blades each clump)

&stc=1

Test failed but that would be very good that something like this would work: create the grass mask dinamically (with the posibilitie to have a gradient to control the density), for example masking by altitude or using the distance from the camera like this

&stc=1

&stc=1

Greetings!

I’m actually surprised this is not how it is done by default :stuck_out_tongue: distance-based density seems like the way to go… not only that would potentially result in smoother transitions but you could also have foliage at greater distances.

Would you guys be interested in a plugin that does something like this? A procedural forest spawning script is on my to-do list for my game so I will eventually need to create something like that anyway.
I’m thinking the tricky part might be reading the landscape masks (especially with multi-tiled landscapes) but in my case I would just manually import the masks as a texture and feed it to the plugin.

I will be interested of course, however , if is a paid plugin I don’t know if I could purchase it. What I can do is help with tests etc.

Another idea for you if you start the plugin, I think controlling the scale of the meshes over distance can help too, because if far away, you have a little bit more large meshes, then you would need less meshes in total to cover the screen and the effect is more or less the same

About how to do it, well I thinck the gras mask can’t be dynamic because must be baked and then the engine do the calculations on “white” areas. For spawn the instances should exist a code that say something like… it is white on the mask, spawn “X” amount of “this” instance/s (array) using “this formula” for location. So if you trace a radious form the camera you can say… at that radious spawn “X” amount, and at that radious “X - linear interpolation value from max and min density based on the radious” using “this formula” for location. Right? or maybe instead of ussing a radious form the camera, using the forward vector for the camera and create a gradient from the max distance. I don’t know the code so maybe I’m wrong , just some thoughts

I made another experiment. I optimize the grass mehes with 2 more LOD’s (at the end the LOD 2 and 3 only are visible in the distance) and for grass type 2 and 3 I use a slighly bigger mesh ( type 1 and 2 are scaled 0.5 and type 3 and 4 at 0.8), also I do the same thing for “control” the density. “Cast shadows” for LOD’s are disabled. Now I have better frame rate and greather distance covered by grass

Some more info:
-My GPU: GTX 960
-My CPU: i5-2300 @2.80GHz
-I use foliage shader model for the grass meshes , but I not have any complete trasnparent surface rendered, like when the grass is maded with the typical planes
-The landscape material on this scene is very complex, without the landscape my framerate is about 120. With the landscape about 90.

&stc=1

Compairson, same meshes , same total density, same max distance, but without density “control”:

&stc=1

I hope this can help in something, Greetings!

Just a heads up @, what you are doing is great and is the right idea but the ‘Start Cull Distance’ doesn’t do what you thing it does (i wish it did). The instances will still render up to the camera. The behaviour I want is that the instances will actually start rendering at that distance but not before. I’m trying to figure out where in the source code that is happening but its hard to track down. I’m currently looking in HierarchicalInstancedStaticMesh.cpp but no luck yet.

[=dokipen;513155]
Just a heads up @, what you are doing is great and is the right idea but the ‘Start Cull Distance’ doesn’t do what you thing it does (i wish it did). The instances will still render up to the camera. The behaviour I want is that the instances will actually start rendering at that distance but not before. I’m trying to figure out where in the source code that is happening but its hard to track down. I’m currently looking in HierarchicalInstancedStaticMesh.cpp but no luck yet.
[/]

What you can do as a temporary workaround (its how we do it), is to make 3 copies of the same grass then set one at 100 desnsity, 2000 view dist (set start and end cull to same value), 1 at 25 density, 5000 view dist and 1 at 5 density and 10000 view dist.

But yes a proper feature for it would be nice.

dokipen](https://forums.unrealengine.com/member.php?11545-dokipen) I know that, this is why Close to the camera I have more density, because sum the density of the 4 grass types, I made this as a test because I not found any way other than that to have dinamically more density close to the camera than far away (well Lods but what I want is reduce the instances). I’m with you, the ideal would be control the density(and scale) besed on a region determined by the distance to the camera, and yea initially I was thinking the Start/End cull distance will act like “from that distance to that distance render X Density” , Unfortunately, I quickly saw that was not the case

[=;513171]
What you can do as a temporary workaround (its how we do it), is to make 3 copies of the same grass then set one at 100 desnsity, 2000 view dist (set start and end cull to same value), 1 at 25 density, 5000 view dist and 1 at 5 density and 10000 view dist.

But yes a proper feature for it would be nice.
[/]

where do you set the ‘view dist’? is that where it starts drawing?

Just send start and end cull to that distance

[=;513207]
Just send start and end cull to that distance
[/]

Oh i see so thats just the end distance. There seems to be no way to have start distance then.

Its not perfect but its fairly effective, you could do it with a function parameter; but its easier just to tweak density down a tiny bit.

Hello all,
This a old topic, but it seams no fix has been added to the engine according to this request…
Any new about it?