From 93a4eb85f0bb62fc5f67d8cc5dc30bba927349ef Mon Sep 17 00:00:00 2001 From: lindayukeyi Date: Thu, 15 Oct 2020 17:57:40 -0400 Subject: [PATCH] 'gbuffer' --- src/pathtrace.cu | 15 ++++++++++++--- src/sceneStructs.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pathtrace.cu b/src/pathtrace.cu index 23e5f90..88f9bd2 100644 --- a/src/pathtrace.cu +++ b/src/pathtrace.cu @@ -74,11 +74,18 @@ __global__ void gbufferToPBO(uchar4* pbo, glm::ivec2 resolution, GBufferPixel* g if (x < resolution.x && y < resolution.y) { int index = x + (y * resolution.x); float timeToIntersect = gBuffer[index].t * 256.0; + glm::vec3 pos = gBuffer[index].position; + glm::vec3 nor = gBuffer[index].normal; + glm::ivec3 color; + + color.x = glm::clamp((int) (nor.x * 255.0), 0, 255); + color.y = glm::clamp((int)(nor.y * 255.0), 0, 255); + color.z = glm::clamp((int)(nor.z * 255.0), 0, 255); pbo[index].w = 0; - pbo[index].x = timeToIntersect; - pbo[index].y = timeToIntersect; - pbo[index].z = timeToIntersect; + pbo[index].x = color.x;//timeToIntersect; + pbo[index].y = color.y;//timeToIntersect; + pbo[index].z = color.z;//timeToIntersect; } } @@ -282,6 +289,8 @@ __global__ void generateGBuffer ( if (idx < num_paths) { gBuffer[idx].t = shadeableIntersections[idx].t; + gBuffer[idx].normal = shadeableIntersections[idx].surfaceNormal; + gBuffer[idx].position = getPointOnRay(pathSegments[idx].ray, shadeableIntersections->t); } } diff --git a/src/sceneStructs.h b/src/sceneStructs.h index da7e558..de38ec2 100644 --- a/src/sceneStructs.h +++ b/src/sceneStructs.h @@ -79,4 +79,6 @@ struct ShadeableIntersection { // What information might be helpful for guiding a denoising filter? struct GBufferPixel { float t; + glm::vec3 position; + glm::vec3 normal; };