Custom Grass Engine

READ THE LAST UPDATES HERE: Custom Grass Engine - #21 by SwiftTheReal

This is a grass ‘engine’ I’m doing for fun.


(It’s still not finished and there is room for optimizations)

The goal is to make something that can render TON of grass without using too many resources, a PLAYABLE experience.

How is this better than ROBLOX’s grass system?
At the moment, I don’t know if this system can be faster than what roblox offers, but here are some comparasions on draw counts and triangles:


Roblox can be fast, you just gotta figure how to use it.
I will come with updates in the future, as I want to add more features such as dynamic grass.
@swiro

29 Likes

Finally, I can touch grass.

This looks very nice! I am excited to see dynamic grass, as the current ones on the market can’t be used in large spaces.

5 Likes

Thanks for the feedback! Adding dynamic grass while allowing all devices to run smoothly will be a challenge. But for sure it will be possible!

It’s interesting that this grass is very tasty))) Okay, I would like to advise you to make some unevenness.

2 Likes

This engine will support multiple grass colors, sizes and density.

This looks really nice. How does it work?

1 Like

There is a lot going behind the hood, I would need a new topic with all the methods using.

But in short:
• Using octrees to efficiently know where the grass will be rendered
• Instead of creating every time new mesh instances, objects that should not render anymore gets reused.
• To move grass fast without lag, use BulkMoveTo using batched tables (moving all grass at once causes lag)
• Using an LOD system to render the grass and using a super fast frustum culling method when animating grass

Note: When animating the grass, it’s all inside the same loop when retrieving the current grass objects. That way we avoid using 2 different loops.

Using octrees on large scenes can be super efficient, as instead of looping trough all the possible positions, you retrieve the current octree the player is located and it’s neighbours.

LOD helps the system render less instances on higher distances, potentially reducing the amount of instances rendered and CPU power.
Frustum Culling helps rendering only the objects that can be seen, avoiding behind the camera obejcts by being animated.

This system is still not finished and there are more optimizations I can do to further optimize it.

1 Like

Omg this is actually brilliant. I don’t know how Roblox renders grass, but I totally get what you mean with using a bounding volume hierarchy to efficiently figure out grass positions.

I made something utilizing the logarithmic lookup complexity in an octree for some reply a bit ago but never shared it:

7jluUmYMD

I didn’t know of trying the frustum culling trick, so that’s actually pretty cool optimization to learn! I think it’d made my rendering much more seamless. Also, I have to look into LOD as I did not account for that in the project–it just didn’t feel applicable.

Do you know of any potentially better ways to render or structure your grass (chunking) given certain grass requirements (including area deviations or not)? I am trying to learn more about how to render stuff efficiently.

3 Likes

The secret behind it it’s how the code is structured. The code re-uses all the variables and tables, without creating new ones every update, reducing GC pressure and improving CPU computing time.

The previous version couldn’t run smoothly at all with animations and higher distances. A lot of the performance is gained by how the code is written.

2 Likes

Update V1.1 :star:

  • Interactive grass
    The player can interact with the grass now, making it more realistic and satisfying.
    Watch videotestengine | Streamable

  • Less Instances
    I managed to reduce the amount of instances used by the engine using an algorithm that can spread distant grass more natural and better.


    241K tris > 120K tris
    1.82k instances > 1.17k instances

  • Smoother animations
    Wind animations are more realistic now, making them look more nice.
    (can be seen in the Interactive grass showcase video)

Some things I want to add in the future:

  • Customize the world with different grass colors, heights and densities
    Right now, developers are limited to build immersive worlds and having different zones with different types of grass.

  • Increase grass rendering radius without affecting performance
    I’ve already managed to decrease the instance count and triangles with this release, but I want to push it even further. I want grass to be rendered much more far away than the current limits!

In the future, this might become a free community resource.

3 Likes

Okay this is insane!
I don’t think I’ve ever seen a grass engine THIS good, from what I can see it’s better than Roblox’s in nearly every way, visuals, possibly performance, and interactive grass.

Though I would like to ask, what are your PC specs? Since those obviously take a big factor in seeing just what this engine can do.

1 Like

Ryzen 7 5800x3d and amd 6650 xt, but this is not all! This engine is made to run smooth on all devices, here is an example taken from my phone (Iphone 11) running at 60 fps

Note that the grass is interactive and wind works aswell. Differences are also close to the roblox’s default grass.
This can work well for low end devices aswell.

1 Like

This is very cool stuff.

In terms of the actual grass models, do you use planes with surfaceappearance?

It’s a bit hard to see in the videos.

I use meshParts that are planes with surface appearances

Much appreciated, I thought it was more efficient to use triangle grass than surfaceappearance grass, but I’ll have to give it a try.

I’m not sure either which one is faster :sweat_smile:
I can tell that the first version of this engine was running much slower than the current version.
Before when I ran a test with 1/(os.clock() - start) to, it returned me 500, now it returns 3000 with wind animations and 6000 without animations.

I can def say that the code plays a lot of importance in optimizing grass and a lot of moving objects

man, that’s so cool! i hope its gonna be even better in the future!

1 Like

Gonna make a new update soon.. With new things I added and changed
leak: I optimized the grass and now it takes only 2 draw calls and 20k tris to render this scene

That’s really good.. before it was 170k tris hahaha

3 Likes

Very cool grass :+1:

Looks awesome

1 Like

Alright.. did you sell your soul for this? and don’t lie

Jokes aside this is some pretty insane stuff, 2 draw calls with 20k tris is just stupidly impressive.

1 Like