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 4: Sydney Miller #16

Open
wants to merge 46 commits into
base: base-code
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
61594f3
basic shading
Sep 27, 2020
9831b6a
offset intersections
Sep 28, 2020
aa97128
cache first intersections
Sep 29, 2020
e3958d3
sort by material
Sep 30, 2020
3d17ac8
part1 renders
Sep 30, 2020
72b1dc1
add timer and both features can be true together
Sep 30, 2020
f4db1fe
part1 performance analysis
Sep 30, 2020
4ec1b92
refraction
Oct 3, 2020
db37af1
Merge branch 'master' of https://github.com/millersy/Project3-CUDA-Pa…
Oct 3, 2020
887b4a7
obj loader
Oct 4, 2020
9c07e27
modified obj loader to use triangle struct
Oct 4, 2020
b9eafb9
bounding box
Oct 4, 2020
4968879
antialiasing
Oct 4, 2020
bab5db4
fixed bounding box
Oct 5, 2020
ecb5027
fixed obj loading
Oct 6, 2020
8192958
sphere sdf
Oct 7, 2020
38f48f5
depth of field
Oct 7, 2020
5ea62a2
two sdf
Oct 7, 2020
49f5981
procedurall textures
Oct 9, 2020
2e76c4d
Readme Outline
millersy Oct 9, 2020
2d61469
Update README.md
millersy Oct 9, 2020
746f619
Update README.md
millersy Oct 9, 2020
0d4be3f
Update README.md
millersy Oct 9, 2020
0808276
Update README.md
millersy Oct 9, 2020
47f8dc6
stratified hemisphere sampling
Oct 10, 2020
e272468
Update README.md
millersy Oct 10, 2020
fc3118b
Update README.md
millersy Oct 10, 2020
6bcea15
new stratified render image
Oct 10, 2020
f81cc47
Merge branch 'master' of https://github.com/millersy/Project3-CUDA-Pa…
Oct 10, 2020
03de46e
final render
Oct 10, 2020
fe68b6e
Update README.md
millersy Oct 10, 2020
eb51a6c
Update README.md
millersy Oct 10, 2020
eb495c6
Update README.md
millersy Oct 10, 2020
7f9acbf
Update README.md
millersy Oct 10, 2020
384014f
Update README.md
millersy Oct 10, 2020
fe52944
added gui files
Oct 16, 2020
59fda5c
normal and position gbuffers
Oct 16, 2020
bd1e330
setting up kernels
Oct 17, 2020
cc53881
added to denoise kernel
Oct 17, 2020
bffc5af
added weights
Oct 19, 2020
b170f9a
weight parameter data types now floats
Oct 19, 2020
44aec46
renders
Oct 20, 2020
727c8c8
renders
Oct 20, 2020
529efba
performance analysis
millersy Oct 20, 2020
f8b1416
Update README.md
millersy Oct 20, 2020
2ed7ca5
Update README.md
millersy Oct 20, 2020
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
Prev Previous commit
Next Next commit
added weights
SYDNEY MILLER committed Oct 19, 2020
commit bffc5af83e75ab470745409bf115224742a82550
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ void runCuda() {
showGBuffer(pbo_dptr);
}
else if (ui_denoise) {
showDenoise(pbo_dptr, iteration, (int)(log2(ui_filterSize) + 1.f));
showDenoise(pbo_dptr, iteration, (int)(log2(ui_filterSize / 2) + 1.f), ui_colorWeight, ui_positionWeight, ui_normalWeight);
}
else {
showImage(pbo_dptr, iteration);
33 changes: 15 additions & 18 deletions src/pathtrace.cu
Original file line number Diff line number Diff line change
@@ -136,7 +136,8 @@ __global__ void imageToBuffer(GBufferPixel* gBuffer, glm::ivec2 resolution,
}
}

__global__ void denoiseToPBO(uchar4* pbo, glm::ivec2 resolution, GBufferPixel* gBuffer, int logFilterSize) {
__global__ void denoiseToPBO(uchar4* pbo, glm::ivec2 resolution,
int c_weight, int p_weight, int n_weight, GBufferPixel* gBuffer, int logFilterSize) {

int x = (blockIdx.x * blockDim.x) + threadIdx.x;
int y = (blockIdx.y * blockDim.y) + threadIdx.y;
@@ -145,13 +146,12 @@ __global__ void denoiseToPBO(uchar4* pbo, glm::ivec2 resolution, GBufferPixel* g

int index = x + (y * resolution.x);

// how many iterations to fill filter size?
int iterations = logFilterSize;

for (int i = 0; i < iterations; i++) {
for (int i = 0; i < logFilterSize; i++) {
int step = pow(2.f, i);
denoiseIteration(index, x, y, step, resolution, gBuffer);
denoiseIteration(index, x, y, step, c_weight, p_weight, n_weight, resolution, gBuffer);
__syncthreads();
pingPongGbuffer(index, gBuffer);
__syncthreads();
}

glm::vec3 color = gBuffer[index].denoise_color;
@@ -162,7 +162,8 @@ __global__ void denoiseToPBO(uchar4* pbo, glm::ivec2 resolution, GBufferPixel* g
}
}

__device__ void denoiseIteration(int index, int x, int y, int step, glm::ivec2 resolution, GBufferPixel* gBuffer) {
__device__ void denoiseIteration(int index, int x, int y, int step,
int c_weight, int p_weight, int n_weight, glm::ivec2 resolution, GBufferPixel* gBuffer) {

//kernel
float kernel[25] = { 1.f / 16.f, 1.f / 16.f , 1.f / 16.f , 1.f / 16.f , 1.f / 16.f,
@@ -183,10 +184,6 @@ __device__ void denoiseIteration(int index, int x, int y, int step, glm::ivec2 r
glm::vec3 curr_nor = gBuffer[index].normal;
glm::vec3 curr_color = gBuffer[index].denoise_color;

float c_phi = 1.f;
float n_phi = 1.f;
float p_phi = 1.f;

float cum_w = 0.f;
for (int i = 0; i < 25; i++) {
glm::vec2 temp_cords = glm::clamp(glm::ivec2(x, y) + offset[i] * step, glm::ivec2(0.f, 0.f), resolution);
@@ -196,21 +193,21 @@ __device__ void denoiseIteration(int index, int x, int y, int step, glm::ivec2 r
glm::vec3 temp_color = gBuffer[temp_index].denoise_color;
glm::vec3 t = curr_color - temp_color;
float dist2 = glm::dot(t, t);
float color_weight = glm::min(glm::exp(-(dist2)/c_phi), 1.f);
float color_weight = glm::min(glm::exp(-(dist2)/c_weight), 1.f);

glm::vec3 temp_nor = gBuffer[temp_index].normal;
t = curr_nor - temp_nor;
dist2 = glm::dot(t, t);
float nor_weight = glm::min(glm::exp(-(dist2) / n_phi), 1.f);
float nor_weight = glm::min(glm::exp(-(dist2) / n_weight), 1.f);

glm::vec3 temp_pos = gBuffer[temp_index].position;
t = curr_pos - temp_pos;
dist2 = glm::dot(t, t);
float pos_weight = glm::min(glm::exp(-(dist2) / p_phi), 1.f);
float pos_weight = glm::min(glm::exp(-(dist2) / p_weight), 1.f);

float weight = color_weight * nor_weight * pos_weight;
sum += temp_color * 1.f * kernel[i];
cum_w += 1.f * kernel[i];
sum += temp_color * weight * kernel[i];
cum_w += weight * kernel[i];
}
}
gBuffer[index].updated_denoise_color = sum / cum_w;
@@ -661,7 +658,7 @@ void showGBuffer(uchar4* pbo) {
gbufferToPBO << <blocksPerGrid2d, blockSize2d >> > (pbo, cam.resolution, dev_gBuffer);
}

void showDenoise(uchar4* pbo, int iter, int filterSize) {
void showDenoise(uchar4* pbo, int iter, int filterSize, int c_weight, int p_weight, int n_weight) {
const Camera& cam = hst_scene->state.camera;
const dim3 blockSize2d(8, 8);
const dim3 blocksPerGrid2d(
@@ -670,7 +667,7 @@ void showDenoise(uchar4* pbo, int iter, int filterSize) {

// CHECKITOUT: process the gbuffer results and send them to OpenGL buffer for visualization
imageToBuffer << <blocksPerGrid2d, blockSize2d >> > (dev_gBuffer, cam.resolution, iter, dev_image);
denoiseToPBO << <blocksPerGrid2d, blockSize2d >> > (pbo, cam.resolution, dev_gBuffer, filterSize);
denoiseToPBO << <blocksPerGrid2d, blockSize2d >> > (pbo, cam.resolution, c_weight, p_weight, n_weight, dev_gBuffer, filterSize);
}

void showImage(uchar4* pbo, int iter) {
4 changes: 2 additions & 2 deletions src/pathtrace.h
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ void pathtraceFree();
void pathtrace(int frame, int iteration);
void showGBuffer(uchar4* pbo);
void showImage(uchar4* pbo, int iter);
void showDenoise(uchar4* pbo, int iter, int filterSize);
void denoiseIteration(int index, int x, int y, int step, glm::ivec2 resolution, GBufferPixel* gBuffer);
void showDenoise(uchar4* pbo, int iter, int filterSize, int c_weight, int p_weight, int n_weight);
void denoiseIteration(int index, int x, int y, int step, int c_weight, int p_weight, int n_weight, glm::ivec2 resolution, GBufferPixel* gBuffer);
void pingPongGbuffer(int index, GBufferPixel* gBuffer);

PerformanceTimer& timer();