Skip to content

ziedbha/Project6-Vulkan-Grass-Rendering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vulkan Grass Rendering

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 6

Grass Rendering

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.

Compute

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.

Tessellation

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.

Rendering

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.

Contents

  • src/ C++/Vulkan source files.
    • shaders/ glsl shader source files
    • images/ images used as textures within graphics pipelines
  • external/ Includes and static libraries for 3rd party libraries.

Culling Optimizations

Here are some heuristics I used to cull blades that won't contribute positively to a given frame.

Orientation culling

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

View-frustum culling

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.

Distance culling

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.

Performance Analysis

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.

Credits

The following resources were useful in implementing this project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 90.3%
  • CMake 5.2%
  • GLSL 4.2%
  • C 0.3%