Skip to content
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
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,75 @@
Vulkan Grass Rendering
==================================
# 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)
- Jinxiang Wang
- Tested on: Windows 11, AMD Ryzen 9 8945HS w/ Radeon 780M Graphics 4.00 GHz 32GB, RTX 4070 Laptop 8 GB

### (TODO: Your README)
### Features Implemented:

*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.
1. Vulkan grass render pipeline
2. Force simulation (gravity, recovery, wind)
3. Culling (orientation, view-frustum, distance)
4. Grass blade tessellation
5. Distance based tessellation

## Forces

| Gravity | Recovery | Wind |
| ------------------------ | ------------------------- | --------------------- |
| ![](results/gravity.gif) | ![](results/recovery.gif) | ![](results/wind.gif) |

## Culling

---

### Orientation Culling

**Orientation culling** is calculated by the absolute value of dot product between blade's **width orientation** and **xz direction of view direction**

| Culling Off | Threshold = 0.1 | Threshold = 0.3 | Threshold = 0.6 | Threshold = 0.9 |
| -------------------------- | -------------------------- | -------------------------- | -------------------------- | -------------------------- |
| ![](results/orient_00.gif) | ![](results/orient_01.gif) | ![](results/orient_03.gif) | ![](results/orient_06.gif) | ![](results/orient_09.gif) |

### View-Frustum Culling

**View-frustum culling** is determined by whether or not a blade is inside view frustum's AABB

| Culling Off | Culling On |
| ----------------------------- | ---------------------------- |
| ![](results/viewFrus_off.png) | ![](results/viewFrus_on.png) |

### Distance Culling

In **distance culling**, we calculate distance between camera, and decide whether or not this blade is culled by computing **threshold < (dist - minDist) / fadeDist**

| Culling On |
| --------------------- |
| ![](results/dist.gif) |

## Tessellation

A **distance based tessellation** is performed in this project. By using similar concept introduced in Distance Culling, we lerp between preset min and max edge factors.

![](results/QuadLevels.png)

### Developing progress

| Setup and Bind Resources | Fixed Orientation | Add Forces and Culling |
| -------------------------- | ----------------------- | ---------------------- |
| ![](results/showgrass.png) | ![](results/bugfix.png) | ![](results/final.png) |

### Performance Analysis

Scene Spec:

| Resolution | Num Blades |
| ---------- | ---------------- |
| 1080x1080 | 262144 (1 << 18) |

Results:

| | No Culling | Orientation Culling | View Frustum Culling | Distance Culling |
| ------------ | ---------- | ------------------- | -------------------- | ---------------- |
| FPS | 112 | 136 | 184 | 189 |
| FPS Increase | 0 | 24 | 48 | 5 |
Binary file modified bin/Release/vulkan_grass_rendering.exe
Binary file not shown.
Binary file added results/QuadLevels.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 results/bugfix.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 results/culling.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 results/dist.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 results/final.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 results/gravity.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 results/orient_00.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 results/orient_01.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 results/orient_03.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 results/orient_06.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 results/orient_09.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 results/recovery.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 results/showgrass.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 results/viewFrus_off.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 results/viewFrus_on.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 results/wind.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Blades.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <array>
#include "Model.h"

constexpr static unsigned int NUM_BLADES = 1 << 13;
constexpr static unsigned int NUM_BLADES = 1 << 16;
constexpr static float MIN_HEIGHT = 1.3f;
constexpr static float MAX_HEIGHT = 2.5f;
constexpr static float MIN_WIDTH = 0.1f;
Expand Down
3 changes: 3 additions & 0 deletions src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "Camera.h"
#include "BufferUtils.h"

int WIDTH = 960;
int HEIGHT = 960;

Camera::Camera(Device* device, float aspectRatio) : device(device) {
r = 10.0f;
theta = 0.0f;
Expand Down
2 changes: 2 additions & 0 deletions src/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ struct CameraBufferObject {
glm::mat4 projectionMatrix;
};

extern int WIDTH;
extern int HEIGHT;
class Camera {
private:
Device* device;
Expand Down
12 changes: 7 additions & 5 deletions src/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
#include <vector>
#include "Instance.h"

#ifdef NDEBUG
const bool ENABLE_VALIDATION = false;
#else
//#ifdef NDEBUG
//const bool ENABLE_VALIDATION = false;
//#else
//const bool ENABLE_VALIDATION = true;
//#endif
const bool ENABLE_VALIDATION = true;
#endif

namespace {
const std::vector<const char*> validationLayers = {
"VK_LAYER_KHRONOS_validation"
"VK_LAYER_KHRONOS_validation",
"VK_LAYER_LUNARG_monitor"
};

// Get the required list of extensions based on whether validation layers are enabled
Expand Down
Loading