Can I create grass from code ? And where do I look to learn the systems needed

So I was looking for a grass system I like and stumbled uppon this video:

https://youtu.be/bp7REZBV4P4?si=Bs5wbD9G2JvLgYeo

I really love how it turns out and want to create it myself but in unreal engine. However all the tutorials on grass always use grass cards and I don’t know where to look to generate grass purely from code as he does.

In generall there are a few things I don’t know where to start looking in unreal:

  1. How do I create meshes from code?
  2. How can I create a brush to place them and make the ammount of meshes visible by player distance. (In his video he explains how the number of triangles aswell as blades reduce, based on the distance to the player, and merge to fewer triangles and fewer grass… What systems would I need in unreal ?)
  3. How I would add the animation via code?

He’s talking about shader code. So, code you enter in the material.

Actually, I think he talking about procedural grass AND shader code.

So you can use PCG and material code.

But, I have to ask, WHY!? :joy:

Here’s something on procedural meshes

The rest you might be able to make with material nodes, but if you can’t then use

1 Like

Thx for the answer ^^ I saw a video from Simon Dev on how they made the grass in ghost of tsushima and wondered how you’d implement it into Unreal engine.

1 Like

Essentially, you dont…

The engine works of TAA and gosting stuff to oblivion, and does not take well at all to custom geometry generating shaders even when you do things properly within the forward shader and in something other than TAA.

@ClockworkOcean
Hes talking about generating triangles in batches via code on the GPU only.
You can optimize the mesh structure so much that you could potentially get incredible results - if the engine was any friendly at all to this type of approach.

Think about it this way. You read in a list of values streamed in from the CPU with minimal computation and adjust/do the math on the fly in the shader which can handle said math effortlessly.
Fuether, you batch it so that its 1 drawcall for all the visible grass, and the overall scene cost goes from the 2fps you are used to running in to the 120htz its supposed to be when there is only a mesh and grass in the scene…

Here is some better explained Theory for you

2 Likes

search for bezier curve grass unreal engine on youtube and you’ll find a whole series that teaches you how to make it

1 Like

The stuff that comes up is a great example of “just because you can doesn’t mean you should”.

Also, the tutorial that comes up is a great example of what not to do.

You are rendering One Mesh - as a single blade of grass.

  • Thats an insane amount of drawcalls.

The concept is to not use any mesh at all, but rather generate geometry on the GFX via call batching in such a way that all the grass takes 1 call and hoever many MS it requires to compute.

It is not - paint stuff via foliage, make the shader make it do stuff.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.