(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
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.
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:
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.
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.
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.
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.
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.
I’m not sure either which one is faster
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
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