Stretchy Rippable Grass

Hello everyone,

I’ve been working on a few different concepts for a VR game, and the one I like the most right now is about a weird gardening game. In it, the player stands on a 1.5x2m patch of grass. This grass is the most complex part of the concept, and I’m having some problems with implementing it.

The grass is made with shell rendering, in the top image with 100 layers and in the bottom one with just one.


When the player grabs one of the small green cubes, they can pull on the grass, and it will spring back to its original position when releasing it. The vertices of the grass mesh follow the position of the cubes.

Now the way I implemented it here was by getting the mesh.vertices of the grass mesh every frame, setting them to the position they need to be (the springing and such is in the code of the small cubes), and then reassigning that Vector3 array to the mesh.vertices again, for every one of the layers.

This all works pretty nicely so far, but I’m pretty sure this is a terrible way of doing it, and would like some advice for other ways of doing it I could look into. I don’t want to proceed working on this if this method will cause me some problems down the road. Should I redo it with a vertex shader or something similar? Is there a more optimised/stable to move the vertices to the position I need them in?

Additionally, I would like for the player to be able to rip out the grass when they pull on it hard enough, and also be able to plant different kinds of grass(different in appearance, not in height). This is how I would, in theory, like for that to work(The anchor points here are moved to the center because it would make the stretching look much better, should have thought of it earlier):

You can see that the green and white spots ‘bleed into’ the orange ones, to give it less of an obviously pixely feel, though I’m open for suggestions to how to better deal with this. Now what I’m asking is what is the best way of achieving this, I’m guessing with a surface shader, but I’d like to be sure before starting to learn about that.

The final thing I would like to implement is the dots on the grass texture getting smaller with every layer, thus making it actually look like grass haha. I suppose they could also just get more transparent as they reach the top, but this doesn’t look as good. What’s the best way of doing this? Having a texture atlas with the different layers getting thinner and thinner? Having a shader making the dots smaller with each layer? Is this even feasible performance-wise?

Sorry for the long post, I just figured all of these things were somewhat connected and the ways for doing each thing were dependant on the functionality needed for the whole thing. I’d be thankful for any inputs at all!

I’m not that familiar with VR devices and the hardware capabilities, but you could indeed use a shader. For instance, there used to be (and meanwhile there are probably better ones) shaders for grass that bends whenever you come close / walk through it.

I can’t really imagine what it’d look like in your example, as you wanna pull it [out], but if shaders were overkill for what you’re trying to do, you could also try to replace the grass you grab with a copy that supports blend shaps or any kind of animator stuff that reacts to a certain value. That is, the blend shape modifies the mesh in a pre-defined way, and the value indicates how much force is used to pull on it.

Perhaps that’s a workaround and enough for that scenario, I’m not 100% sure though.