I want to generate a bunch of plant meshes using a multimesh generator of some kind. Can I make the mesh transform itself pending its position on a surface?

Godot Version

4.5

Question

All this is basically me just trying to find some way to make lots of plants spawn themselves on a plain as one object for the sake of GPU/CPU efficiency. I want to put flowers and other plants on a plane, and make the meshes themselves flush with the plane itself, so the plants look like they’re coming out of the ground properly. This is based on studying the ways plants were placed in an old Nintendo DS game, The Wizard Of Oz: Beyond The Yellow Brick Road:

Everything is placed on a hillside that’s at an angle. Each plant in the original game was clearly hand placed by an artist, who then took each individual plant and made it flush with the environment. This model in particular is one I made by studying their methods, but all the textures here are theirs.

And here’s an image of what the landscape looks like below; all the plants are pulled just a bit below the ground so they look like they’re in the landscape itself. That’s how they did it in the original, too. But one thing they didn’t do in the original game was sway. Every plant in the game just sat there, motionless. My goal is:

  1. Get all (or most) of the plants in one object, generated as a shader.
  2. Get all the plants flush with the landscape.
  3. Pull all the plants juuuust a little bit below the landscape, so they look like they’re coming out of it properly.
  4. Get the plants to sway in the wind.

Now, I’ve figured out how to get the plants to look like they’re swaying in the wind in a different thread. But If I try to individually place every plant as if they’re all individual instances of the same scene, the game is going to hate me. After all, an average scene might look something like this:

Too many plants! It would look beautiful if they all swayed in the wind, but it would also be great if they did that at a proper frame rate.

If I could make some kind of generic scene set up that I could repeat for plants ad nauseam, that would let me place plants dynamically in a scene, that would be a dream come true. So I’m trying to brainstorm solutions. And I figure I’m not the first wannabe dev in history to have this problem, so I thought I’d come ask here for insight and suggestions.

ANYWAYS, I THOUGHT I’D POST SOME STUFF I’VE CONSIDERED (but haven’t had time to try yet):

  1. A multimesh3D. Here’s a link to a youtube video tutorial I’ve been reviewing. It looks really useful for your standard grass or fur shaders, but it doesn’t seem to let you choose where specifically the spawned meshes go. Useful for a perfectly flat plane, but not for our dynamic hillsides and valleys.
    1. I though, maybe, harshly limiting the options for spawning plants? I could, say, figure out where I want all the plants to be on the landscape by placing them in blender. Then I’d place vertices at the base of each given plant, delete every plant so I just have a map of loose floating vertices, export that as its own object into Godot, and now I have a perfect map of the location of every plant I want to spawn. But I have no idea if that would even work.
  2. Path based mesh generation. This would let me just spawn a path in any given mesh and place shader flowers wherever I want. It might be kind of awkward and unwieldy, and result in some strange paths in the editor, but if it creates plants placed neatly where I want them, what does that matter?
    1. The video explains briefly how to make meshes that rotate themselves perfectly aligned to your path, but it doesn’t solve the problem where I need the vertical sides of the mesh to be perfectly vertical every time; the horizontal top and bottoms of each quad should rotate to be flush with the landscape they’re sitting on, but the sides should always be vertical, to make sure the plant looks like it’s growing upwards.

I’m so certain someone out there with experience in this just read whatever I wrote and said “What? No, you’re wrong, this is what you should do.” Please tell me what I should do! I’m still a novice and I’m trying to figure out how and where to learn all of this stuff to begin with! Thanks in advance!

Not a good idea, geometry shaders have been largely abandoned (though many use compute shaders to do similar tasks, but smarter). The idea of generating geometry in a shader is bad because you would be throwing away that work every frame, it’s way harder to write and debug GPU code. GPUs do not like to share data, aligning one mesh to other meshes on the GPU will be difficult.

Make a @tool script or plugin to position your MultiMesh transforms. There is a built-in “place on surface” tool Godot has, it’s pretty strict in use, it does one thing and it does one thing alright. But it’s probably good enough for what you need, maybe with some tweaks.

These are also all great @tool/plugin tasks.


Have you tested if Godot hates you? Make sure to profile before optimizing.

Godot does try to instance geometry where it can, low hanging fruit like instanced scenes can be transparently baked into less draw calls. You may be over engineering with MultiMeshInstances where Godot can not only handle it on it’s own but may be more optimal- a MultiMeshInstance must draw all of it’s geometry, where Godot can cull non-visible nodes before making any draw calls.


This is a killer feature of proton’s scatter! Pretty much the only reason I use the plugin in some games, other scatter techniques are easy enough to create yourself, paths tip the scales for me.

Thank you, I’m going to look into this tomorrow (or, since my work schedule is about to really pick up, maybe not until next week).

This is another really good point. I’ve been listening to other people talk about Godot and how to run things efficiently, but it’s also not lost on me that I’m trying to use techniques that are 20 years old, or more. I’ve set a goal for myself of keeping every scene less than 2000 tris, and every character less than 500 tris, if only for love of the old low poly look. That, and trying to only use vertex shading if possible. From what I’ve read, that’s trivial to render on even low end modern devices. So should I really be stressed about placing a bunch of plant scenes, if they’re still, on their own, really easy to render? I haven’t technically tried this yet… One of my next goals will be to mock up a sample scene with swaying plants, and see how hard it is for Godot to render.

Also, the course I’ve been following has never mentioned profiling even once. So, thank you for mentioning that too.

I’ll be sure to look at this tool if it turns out just manually placing every scene/plant/object, like I’d otherwise like to do, is actually too stressful for Godot to handle.

Thank you for writing all this out!

Okay, I’ve been really busy with work and life for the past week, but I’m back, and I’m able to really sit and try some of this stuff.

I tried making a bunch of simple meshes and adding a simple shader effect to them, to get them to wave in the wind. I’m not sure how I feel about it- they wave fine, but it seems like I don’t have any specific control over their vertex colors once they’re in Godot. Like I can’t just grab a paint tool of some kind and click specific vertices on a model until I like the color I see. I’m sure there’s got to be some way to do that, but so far I’m so new to Godot I don’t know how to start.

Anyways, if I could find some way to just alter the shape of a mesh, just a simple quad, after I added it into Godot. I don’t mean scale or transform, I mean grab a specific vertex and move it wherever I wanted to in space. That would be a dream come true for what I’m trying to do.

I also need to try to learn about “profiling,” because I ran the profiler and, uh, I have no idea what any of this means lol

Yeah once the mesh is imported you cannot (or generally should not) change it inside of Godot, including vertex colors. You can still change the looks in many many ways with your shader. You can change shader uniforms per-material so each flower can be modulated uniquely.

Probably not, but you can skew meshes (and Node3Ds in general). Changing the node’s “Rotation Edit Mode” to “Basis” will open up a matrix of values to change, some of them skew.

Time is how long it takes to render this frame, generally you are targeting the lowest time per frame possible, at 60FPS you must use less than 16ms to render a frame. You may notice that “Physics Frame Time” is slapped right at 16ms, don’t worry about this, but it can be hard to gauge if you are close to over-budget

The graph shows how long each checked section took per-frame, so you have spikes at the beginning which makes sense and is unavoidable as the game loads and builds a rendering pipeline. Check in again on this Profiler later on in your game, or duplicate your scene 50 times and check it, watch the numbers grow!