University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 6
- Ziad Ben Hadj-Alouane
- Tested on: Windows 10, i7-8750H @ 2.20GHz, 16GB, GTX 1060
In this project, I implemented a grass simulator and renderer using Vulkan. The main paper referenced is Responsive Real-Time Grass Rendering for General 3D Scenes.
I use a compute shader to perform physics calculations (gravity, wind, etc..) on Bezier curves that represent individual grass blades. I also use this to perform culling optimizations: based on distance, orientation, and the view-frustum.
To generate grass vertices, I tessellate the grass blade using a quad based on how far it is from the camera. A blade is more detailed the closer it is.
After a grass is tessellated, I compute a fragments lerped values in the evaluation tesselation phase. After that, I perform simple lambert shading on each fragment.
src/C++/Vulkan source files.shaders/glsl shader source filesimages/images used as textures within graphics pipelines
external/Includes and static libraries for 3rd party libraries.
Here are some heuristics I used to cull blades that won't contribute positively to a given frame.
Consider the scenario in which the front face direction of the grass blade is perpendicular to the view vector. Since our grass blades won't have width, we will end up trying to render parts of the grass that are actually smaller than the size of a pixel. This could lead to aliasing artifacts. We remove this blades from the rendering phase
We also want to cull blades that are outside of the view-frustum, considering they won't show up in the frame anyway. The paper describes an algorithm to determine if a blade needs to be culled.
Similarly to orientation culling, we can end up with grass blades that at large distances are smaller than the size of a pixel. This could lead to additional artifacts in our renders. In this case, we can cull grass blades as a function of their distance from the camera.
Below is a graph that showcases the different results obtained by the simulation for different paramters (types of optimizations, and number of input grass blades)
It is clear that for best results (and for most cases), it is better to enable all optimizations. We notice a significant drop in performance as we disable all optimizations. It seems that the biggest gain in performance comes from distance culling.
The following resources were useful in implementing this project




