Skip to content

Commit

Permalink
'gbuffer'
Browse files Browse the repository at this point in the history
  • Loading branch information
lindayukeyi committed Oct 15, 2020
1 parent e2738f1 commit 93a4eb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pathtrace.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/sceneStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 93a4eb8

Please sign in to comment.