Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project 5: Yuanqi Wang #28

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
561 changes: 561 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions - Vulkan Grass Rendering

This is due **Sunday 10/30 at 11:59pm**.
This is due **Sunday 10/29 at 11:59pm**.

**QUICK NOTE**: Please use `git clone --recursive` when cloning this repo as there are submodules which need to be cloned as well.

Expand Down
80 changes: 75 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,80 @@ Vulkan Grass Rendering

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

* (TODO) YOUR NAME HERE
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Yuanqi Wang
* [LinkedIn](https://www.linkedin.com/in/yuanqi-wang-414b26106/), [GitHub](https://github.com/plasmas).
* Tested on: Windows 11, i5-11600K @ 3.91GHz 32GB, RTX 4090 24GB (Personal Desktop)

### (TODO: Your README)
## Overview

*DO NOT* leave the README to the last minute! It is a crucial part of the
project, and we will not be able to grade you without a good README.
A quadratic Bézier curve is a parametric curve used in computer graphics and related fields to model smooth curves. Using quadratic Bézier curves to model grass allows for both aesthetic realism and computational efficiency. This method can create a wide variety of grass shapes and appearances by simply adjusting the positions of the control points. It's particularly effective in real-time rendering applications, like video games or simulations, where performance is critical, but a reasonable level of realism is also required.

In this project, I simulate the grass using quadratic Bézier curves based on the method introduced in this paper: [Responsive Real-Time Grass Rendering for General 3D Scenes](https://www.cg.tuwien.ac.at/research/publications/2017/JAHRMANN-2017-RRTG/JAHRMANN-2017-RRTG-draft.pdf).

![](/img/blade_model.jpg)

The blade of grass is represented using a quadratic Bézier curve defined by three control points and some essential attributes:

$v_0$: This is the base point, anchored at the ground level. It acts as the starting point of the grass blade.

$v_1$: This is the control point that doesn't lie on the curve itself but influences its shape. It essentially dictates the bend or curvature of the grass blade.

$v_2$: This is the endpoint of the curve and represents the tip of the grass blade.

*direction:* The general leaning or orientation of the grass blade.

*height:* The height of grass blade from base to tip (from $v_0$ to $v_2$).

*width:* The thickness of the grass blade base.

*up-vector:* a directional vector indicating the vertical orientation in 3D space. This usually aligned with the normal of the plane.

## Features
### Physics Simulation

To properly simulate grass movement, a combination of recovery, gravity, and wind is used. These animations show grass movement when different forces are considered:

| No Force | Gravity Only |
|---|---|
|![](img/no_force.png)|![](img/gravity.png)|


| Gravity + Recovery | Gravity + Recovery + Wind |
|---|---|
|![](img/recovery.png)|![](img/wind.gif)|

It is clear that when no force is applied, all blades of grass sts the same. When gravity is the only force, all grass fell to the ground since there is no stiffness or recovery force. When Recovery force is added, blades now have a natural curve. And finally when wind force is applied, the grass will move as wind direction and strength are different at varying locations and times.

### Culling

To improve performance, different culling methods are used to discard blades that are not or less visible.

| No Culling | Orientation Culling |
|---|---|
|![](img/no_culling.gif)|![](img/orient_culling.gif)|


| Frustrum Culling | Distance Culling |
|---|---|
|![](img/frustrum_culling.gif)|![](img/dist_culling.gif)|

With orientation culling we can see that some blades which are alighed with the viewing direction is omitted. With frustrum culling, If all $v_0$, $v_2$, and $m$ are not in the frustrum, the blade will be omitted. With distance culling, blades that are too far away will be omitted.

### Performance Analysis

#### Number of Blades
To analyse performance, we tested FPS under different number of blades. No culling is used in this testing.

![](./img/fps_vs_blades.svg)

Since both axis are log-based. We can see that the FPS decreases linearly with the number of blades. This is expected as the render cost increases linearly with the number of blades.

#### Culling

The actual performance benefit we can get from culling is highly dependent on the camera's position and viewing direction, as well as culling parameters. As a rule of thumb, the more blades culled by some culling rule, the more benefits we will gain from that rule. However, it does not mean that culling rules that yield less performance boost is less important, as it will vary a lot based in different scene and viewing situations.

For this part, I solely examine the FPS boost I get when not moving the position and viewing angle of the camera. The number of blades is set to $10^{15}$.

![](./img/culling.svg)

We can see that this is camera setup, performance benefits greatly from orientation culling. This is expected as a lot of the blades will be discarded based on their orientation against the camera. Frustrum culling introduces a small performance gain because in this camera setup, most of the blades are still within the frustrum. With all three culling enabled, a huge performance boost is obtained, as a massive portion of blades that are not visible is reduced from the rendering.
Binary file removed bin/Release/vulkan_grass_rendering.exe
Binary file not shown.
1 change: 1 addition & 0 deletions img/culling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/dist_culling.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/fps_vs_blades.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/frustrum_culling.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gravity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/no_culling.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/no_force.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/orient_culling.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/recovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/wind.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading