Skip to content

418Cat/gpu-grass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPU Grass

A small shell texturing grass implementation, based on Acerola's video about fur/grass rendering. Written in C++ using OpenGL


How

The only geometry in the scene is a single flat plane: Plane

The plane is then subdivided in multiple square sections: Subdivided plane

Each section is assigned a random number between 0 and 1 based on the square's x&y coordinates: Random squares

The plane is drawn multiple times at different heights. Each square section is drawn only if the height is less than the random number assigned to it: Discarded random squares

By shading the square based on its height, it gives it a nice grass-like look: Green squares


Misc

The camera moves with WASD/ZQSD and can be rotated by clicking&dragging the mouse. Imgui is used to allow changing parameters during runtime


Credits

The hash function used to generate random numbers for the height was made by David Hoskins: https://www.shadertoy.com/view/4djSRW


Pictures

Square grass

Round grass

Round dense grass

Pointy grass 0

Pointy grass 1

Wind 0

Wind 1

Wind long


This code is under the MIT license

About

Grass rendering on the gpu using 4 vertices, made with OpenGL

Resources

Stars

Watchers

Forks

Packages

No packages published