Skip to content

salaark/Vulkan-Grass-Rendering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vulkan Grass Rendering

Introduction

This repository features real-time grass simulation and rendering using Vulkan, based on the paper Responsive Real-Time Grass Rendering for General 3D Scenes. The grass simulates forces such as gravity, recovery, and wind for realistic, tunable behavior. Additionally, grass blades can be selectively rendered based on viewport position, orientation, and distance. After describing the general graphics pipeline used to achieve these techniques, I will describe how they individually impact performance. With simulation and culling, the grass rendering performs at over 1500 frames per second.

Pipeline

  1. Set up the Vulkan graphics pipeline (send data to shaders using descriptor sets and descriptor set layouts)
  2. Simulate wind, gravity, and recovery forces in the compute shader
  3. Cull (do not render) grass blades based on orientation, distance, and view-frustum
  4. Grass vertex shader to transform positions and calculate bitangent, up vectors
  5. Tesselation shader to subdivide grass into Bezier splines for more detail
  6. Fragment shader to calculate final color by interpolating vertical position on the blade

Culling

Below are gif images of the grass blades that are culled using the techniques described.

Distance Culling

Distance Culling - Render less grass the further the camera is away from the blades. Has parameters for number of buckets that grass is grouped in for distance culling as well as the interval between these buckets.

Frustum Culling

Frustum Culling - Do not render grass that is outside the viewport. Has tunable parameter for how far the grass must be outside of the viewport to not be rendered.

Orientation Culling

Orientation Culling - Do not render grass that is facing perpendicular to the camera. Has tunable parameter for what the angle between camera and grass blade must be to not be rendered.

Analysis

In the graph below, features are added incrementally from left to right and performance is measured in the form of frames per second.

Static Grass

Clearly, the fps increases with the addition of new culling techniques. Some of these techniques are conditional, for example, frustum culling can only hurt performance if every blade of grass is in the viewport. However, in the general case where the camera is somewhere inside the scene, all culling methods boost performance by about 50 fps or more. Distance culling and orientation culling are particularly efficient regardless of how the camera is positioned and oriented.

Static Grass

Grass before any simulation forces are applied. According to the analysis, simulation forces cost very little in comparison to the fps gains by various forms of culling.

About

Grass rendering and simulation implemented on the GPU using Vulkan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 91.1%
  • CMake 5.2%
  • GLSL 3.4%
  • C 0.3%