Small raytracing shader performance changes

This commit is contained in:
saschawillems 2016-04-12 20:28:46 +02:00
parent f44afda9ab
commit 343a25cbed
3 changed files with 10 additions and 4 deletions

View file

@ -5,8 +5,8 @@
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (local_size_x =16, local_size_y = 16) in;
layout (binding = 0, rgba8) uniform image2D resultImage;
layout (local_size_x = 16, local_size_y = 16) in;
layout (binding = 0, rgba8) uniform writeonly image2D resultImage;
#define EPSILON 0.0001
#define MAXLEN 1000.0
@ -113,6 +113,7 @@ int intersect(in vec3 rayO, in vec3 rayD, out float resT)
{
id = spheres[i].id;
resT = tSphere;
return id;
break;
}
}
@ -153,6 +154,11 @@ vec3 renderScene(inout vec3 rayO, inout vec3 rayD, inout int id)
// Get intersected object ID
int objectID = intersect(rayO, rayD, t);
if (objectID == -1)
{
return color;
}
vec3 pos = rayO + t * rayD;
vec3 lightVec = normalize(ubo.lightPos - pos);
vec3 normal;

View file

@ -52,7 +52,7 @@ public:
glm::vec3 lightPos;
// Aspect ratio of the viewport
float aspectRatio;
glm::vec4 fogColor = glm::vec4(0.025f, 0.025f, 0.025f, 0.0f);
glm::vec4 fogColor = glm::vec4(0.0f);
struct {
glm::vec3 pos = glm::vec3(0.0f, 1.5f, 4.0f);
glm::vec3 lookat = glm::vec3(0.0f, 0.5f, 0.0f);