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
325 changes: 79 additions & 246 deletions README.md

Large diffs are not rendered by default.

Binary file added bin/Debug/vulkan_grass_rendering.exe
Binary file not shown.
Binary file added bin/Debug/vulkan_grass_rendering.ilk
Binary file not shown.
Binary file added bin/Debug/vulkan_grass_rendering.pdb
Binary file not shown.
Binary file added img/0.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/1/1_aoff_far.JPG
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/1/1_aoff_mid.JPG
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/1/1_aoff_near.JPG
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/1/1_aon_far.JPG
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/1/1_aon_mid.JPG
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/1/1_aon_near.JPG
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/1/1_d_far.JPG
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/1/1_d_mid.JPG
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/1/1_d_near.JPG
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/1/1_f_far.JPG
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/1/1_f_mid.JPG
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/1/1_f_near.JPG
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/1/1_o_far.JPG
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/1/1_o_mid.JPG
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/1/1_o_near.JPG
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/2/2_aoff_far.JPG
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/2/2_aoff_mid.JPG
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/2/2_aoff_near.JPG
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/2/2_aon_far.JPG
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/2/2_aon_mid.JPG
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/2/2_aon_near.JPG
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/2/2_d_far.JPG
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/2/2_d_mid.JPG
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/2/2_d_near.JPG
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/2/2_f_far.JPG
Binary file added img/2/2_f_mid.JPG
Binary file added img/2/2_f_near.JPG
Binary file added img/2/2_o_far.JPG
Binary file added img/2/2_o_mid.JPG
Binary file added img/2/2_o_near.JPG
Binary file added img/3/3_aoff_far.JPG
Binary file added img/3/3_aoff_mid.JPG
Binary file added img/3/3_aoff_near.JPG
Binary file added img/3/3_aon_far.JPG
Binary file added img/3/3_aon_mid.JPG
Binary file added img/3/3_aon_near.JPG
Binary file added img/3/3_d_far.JPG
Binary file added img/3/3_d_mid.JPG
Binary file added img/3/3_d_near.JPG
Binary file added img/3/3_f_far.JPG
Binary file added img/3/3_f_mid.JPG
Binary file added img/3/3_f_near.JPG
Binary file added img/3/3_o_far.JPG
Binary file added img/3/3_o_mid.JPG
Binary file added img/3/3_o_near.JPG
Binary file added img/a.JPG
Binary file added img/b.JPG
Binary file added img/c.JPG
Binary file added img/d_culling.JPG
Binary file added img/f_culling.JPG
Binary file added img/o_culling.JPG
9 changes: 7 additions & 2 deletions src/Blades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Blades::Blades(Device* device, VkCommandPool commandPool, float planeDim) : Mode
float x = (generateRandomFloat() - 0.5f) * planeDim;
float y = 0.0f;
float z = (generateRandomFloat() - 0.5f) * planeDim;
float direction = generateRandomFloat() * 2.f * 3.14159265f;
float direction = generateRandomFloat() * 2.f * 3.14159265f;
glm::vec3 bladePosition(x, y, z);
currentBlade.v0 = glm::vec4(bladePosition, direction);

Expand All @@ -45,8 +45,9 @@ Blades::Blades(Device* device, VkCommandPool commandPool, float planeDim) : Mode
indirectDraw.firstInstance = 0;

BufferUtils::CreateBufferFromData(device, commandPool, blades.data(), NUM_BLADES * sizeof(Blade), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, bladesBuffer, bladesBufferMemory);
BufferUtils::CreateBuffer(device, NUM_BLADES * sizeof(Blade), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, culledBladesBuffer, culledBladesBufferMemory);
BufferUtils::CreateBuffer(device, NUM_BLADES * sizeof(Blade), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, culledBladesBuffer, culledBladesBufferMemory);
BufferUtils::CreateBufferFromData(device, commandPool, &indirectDraw, sizeof(BladeDrawIndirect), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, numBladesBuffer, numBladesBufferMemory);
BufferUtils::CreateBuffer(device, BUCKET_COUNT * sizeof(uint32_t), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bucketBladeCounts, bucketBladeCountsMemory);
}

VkBuffer Blades::GetBladesBuffer() const {
Expand All @@ -61,6 +62,10 @@ VkBuffer Blades::GetNumBladesBuffer() const {
return numBladesBuffer;
}

VkBuffer Blades::GetBucketBladeCounts() const {
return bucketBladeCounts;
}

Blades::~Blades() {
vkDestroyBuffer(device->GetVkDevice(), bladesBuffer, nullptr);
vkFreeMemory(device->GetVkDevice(), bladesBufferMemory, nullptr);
Expand Down
4 changes: 4 additions & 0 deletions src/Blades.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Model.h"

constexpr static unsigned int NUM_BLADES = 1 << 13;
static constexpr unsigned int BUCKET_COUNT = 50;//not used
constexpr static float MIN_HEIGHT = 1.3f;
constexpr static float MAX_HEIGHT = 2.5f;
constexpr static float MIN_WIDTH = 0.1f;
Expand Down Expand Up @@ -74,15 +75,18 @@ class Blades : public Model {
VkBuffer bladesBuffer;
VkBuffer culledBladesBuffer;
VkBuffer numBladesBuffer;
VkBuffer bucketBladeCounts;

VkDeviceMemory bladesBufferMemory;
VkDeviceMemory culledBladesBufferMemory;
VkDeviceMemory numBladesBufferMemory;
VkDeviceMemory bucketBladeCountsMemory;

public:
Blades(Device* device, VkCommandPool commandPool, float planeDim);
VkBuffer GetBladesBuffer() const;
VkBuffer GetCulledBladesBuffer() const;
VkBuffer GetNumBladesBuffer() const;
VkBuffer GetBucketBladeCounts() const;
~Blades();
};
33 changes: 33 additions & 0 deletions src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,39 @@ void Camera::UpdateOrbit(float deltaX, float deltaY, float deltaZ) {
memcpy(mappedData, &cameraBufferObject, sizeof(CameraBufferObject));
}

void Camera::SetOrientationCullingEnabled(float mode)
{
cameraBufferObject.orientationCullingEnabled = mode;
memcpy(mappedData, &cameraBufferObject, sizeof(CameraBufferObject));
}

void Camera::SetFrustumCullingEnabled(float mode)
{
cameraBufferObject.frustumCullingEnabled = mode;
memcpy(mappedData, &cameraBufferObject, sizeof(CameraBufferObject));
}

void Camera::SetDistanceCullingEnabled(float mode)
{
cameraBufferObject.distanceCullingEnabled = mode;
memcpy(mappedData, &cameraBufferObject, sizeof(CameraBufferObject));
}

float Camera::IsOrientationCullingEnabled()
{
return cameraBufferObject.orientationCullingEnabled;
}

float Camera::IsFrustumCullingEnabled()
{
return cameraBufferObject.frustumCullingEnabled;
}

float Camera::IsDistanceCullingEnabled()
{
return cameraBufferObject.distanceCullingEnabled;
}

Camera::~Camera() {
vkUnmapMemory(device->GetVkDevice(), bufferMemory);
vkDestroyBuffer(device->GetVkDevice(), buffer, nullptr);
Expand Down
20 changes: 19 additions & 1 deletion src/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
#include "Device.h"

struct CameraBufferObject {
CameraBufferObject()
{
orientationCullingEnabled = -1;
frustumCullingEnabled = -1;
distanceCullingEnabled = -1;
}

glm::mat4 viewMatrix;
glm::mat4 projectionMatrix;
float orientationCullingEnabled;
float frustumCullingEnabled;
float distanceCullingEnabled;
};

class Camera {
Expand All @@ -20,13 +30,21 @@ class Camera {

void* mappedData;

float r, theta, phi;

public:
float r, theta, phi;
Camera(Device* device, float aspectRatio);
~Camera();

VkBuffer GetBuffer() const;

void SetOrientationCullingEnabled(float mode);
void SetFrustumCullingEnabled(float mode);
void SetDistanceCullingEnabled(float mode);

float IsOrientationCullingEnabled();
float IsFrustumCullingEnabled();
float IsDistanceCullingEnabled();

void UpdateOrbit(float deltaX, float deltaY, float deltaZ);
};
Loading