XaiJu
minionsart
minionsart

patreon


Grass Geometry Shader with Interactivity (Part 2, the editor tool)

Edit: Improved the script a bit, you can now edit the grass too with color and length/width, pastebins are renewed. Grass Shader linked below is also updated!

Hi all,

Here are finally the 2 scripts that let you paint the grass from the Geometry Grass Shader Part 1 post 

The first script does the actual painting, the second script is a custom editor

Geometry Painter Script  

GeometryPainterScript.cs(Updated): PasteBin Link 

The script is sending out raycasts based on your mouse position. When the raycasts hit something that is defined in the layer mask, it puts down Mesh Points that the grass shader will use to create grass blades on.

Grass Painter Editor Script

GrassPainterEditor.cs (Updated) : Pastebin Link  

The editor script creates the brush-sized disc that changes color depending on mode, and the custom inspector sliders and buttons

How to use

1. Grab both scripts, GeometryGrassPainter.cs and GrassPainterEditor.cs

The latter goes in the Assets>Editor folder

2. Create new empty Gameobject.

3. Add GeometryGrassPainter.cs, it will automatically add a MeshFilter and MeshRenderer

4. Drag a Material of the Geometry Grass Shader into the MeshRenderer

5. Turn on Add Toggle

6. Paint! By holding right-click. You can swap modes to remove and edit too.


Settings Breakdown;


Grass Limit, just in case, you can limit the number of points painted (number of grassblades per point are defined in the shader, so it's more blades than points)
Paint Status - Add, remove points, or edit color and size

Layer Mask - The Physics layers you can paint on
Brush Size -
Radius size of brush
Density -
How many points are put down within the brush radius
Normal Limit -
Angle limit of where the points are placed. 0 = only perfectly flat, 1 = every angle

Brush Color - Additional tinting to the grass material

Color Variation - Add some random color values into the material per point, split into Red Green Blue.

Clear Mesh - Deletes all points (Has extra confirmation dialogue to make sure)


Thanks for reading!

Grass Geometry Shader with Interactivity (Part 2, the editor tool)

More Creators