Commit 07d51783 authored by Brian's avatar Brian

glcalls and compute update

-add local/global work group size output
-add pre-surface normals (not in a working state)
parent 5575b40d
...@@ -8,6 +8,22 @@ vec3 ray_d = vec3(0.0, 0.0, -1.0); // ortho ...@@ -8,6 +8,22 @@ vec3 ray_d = vec3(0.0, 0.0, -1.0); // ortho
vec3 sphere_c = vec3(0.0, 0.0, -10.0); vec3 sphere_c = vec3(0.0, 0.0, -10.0);
float sphere_r = 1.0; float sphere_r = 1.0;
vec4 normals(float t, ivec2 pixel_coords)
{
if (t > 0.0)
{
vec3 normal = normalize(pixel_coords - vec3(0, 0, -1));
vec4 pixel = 0.5 * vec4(normal.x + 1, normal.y + 1, normal.z + 1, 2*1.0)
return pixel;
}
vec4 unit_direction = normalize(ray_d) + (0.0, 0.0, 0.0, 1.0);
t = 0.5*(unit_direction.y + 1.0);
pixel = ((1.0 - t) * vec3(1.0, 1.0, 1.0) + t*vec3(0.5, 0.7, 1.0)) + vec4(0.0, 0.0, 0.0, 1.0;
return pixel;
}
void main() { void main() {
// base pixel colour for image // base pixel colour for image
vec4 pixel = vec4(0.0, 0.0, 0.0, 1.0); vec4 pixel = vec4(0.0, 0.0, 0.0, 1.0);
...@@ -28,11 +44,23 @@ void main() { ...@@ -28,11 +44,23 @@ void main() {
float b = dot(ray_d, omc); float b = dot(ray_d, omc);
float c = dot(omc, omc) - sphere_r * sphere_r; float c = dot(omc, omc) - sphere_r * sphere_r;
float bsqmc = b * b - c; float bsqmc = b * b - c;
float t = 10000.0; //maximum bounds
// hit one or both sides // hit one or both sides
if (bsqmc >= 0.0) { if (bsqmc >= 0.0) {
pixel = vec4(0.4, 0.4, 1.0, 1.0); if(bsqmc > 0.0){
float t = 2
}
else
{
float t = 1
pixel = normals(t, pixel_coords);
}
} }
// output to a specific pixel in the image // output to a specific pixel in the image
imageStore(img_output, pixel_coords, pixel); imageStore(img_output, pixel_coords, pixel);
} }
...@@ -219,6 +219,7 @@ bool rt::rt_window::init(int sizeX, int sizeY, std::string name) ...@@ -219,6 +219,7 @@ bool rt::rt_window::init(int sizeX, int sizeY, std::string name)
checkError("glClearColor"); checkError("glClearColor");
generateTexture(); generateTexture();
queryWorkGroups();
initComputeShader(); initComputeShader();
return GL_TRUE; return GL_TRUE;
...@@ -261,8 +262,8 @@ void rt::rt_window::generateTexture() ...@@ -261,8 +262,8 @@ void rt::rt_window::generateTexture()
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
//set texture clamp to border //set texture clamp to border
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//set pixel filter to linear //set pixel filter to linear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
...@@ -277,6 +278,26 @@ void rt::rt_window::generateTexture() ...@@ -277,6 +278,26 @@ void rt::rt_window::generateTexture()
glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F); glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F);
} }
void rt::rt_window::queryWorkGroups()
{
int work_grp_size[3], work_grp_inv;
// maximum global work group (total work in a dispatch)
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &work_grp_size[0]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, &work_grp_size[1]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, &work_grp_size[2]);
printf("max global (total) work group size x:%i y:%i z:%i\n", work_grp_size[0],
work_grp_size[1], work_grp_size[2]);
// maximum local work group (one shader's slice)
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &work_grp_size[0]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &work_grp_size[1]);
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, &work_grp_size[2]);
printf("max local (in one shader) work group sizes x:%i y:%i z:%i\n",
work_grp_size[0], work_grp_size[1], work_grp_size[2]);
// maximum compute shader invocations (x * y * z)
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &work_grp_inv);
printf("max computer shader invocations %i\n", work_grp_inv);
}
void rt::rt_window::initComputeShader() void rt::rt_window::initComputeShader()
{ {
char* computeShaderSource = readShaderFromFile("Shader/compute.glsl"); char* computeShaderSource = readShaderFromFile("Shader/compute.glsl");
......
...@@ -66,6 +66,7 @@ namespace rt ...@@ -66,6 +66,7 @@ namespace rt
//methods related to raytracing //methods related to raytracing
void generateTexture(); void generateTexture();
void queryWorkGroups();
void initComputeShader(); void initComputeShader();
//methods to run the initialized program //methods to run the initialized program
......
 OpenGL_Raytracer.cpp  glCalls.cpp
glCalls.cpp OpenGL_Raytracer.vcxproj -> C:\Users\brian\Desktop\Multimedia\mm_raytracer\OpenGL_Raytracer\x64\Debug\OpenGL_Raytracer.exe
Code wird generiert...
OpenGL_Raytracer.vcxproj -> C:\Users\eleph\source\repos\OpenGL_Raytracer\x64\Debug\OpenGL_Raytracer.exe
B^C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C B^C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C
......
B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C
......
B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\GLAD.C
......
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0 #TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Debug|x64|C:\Users\eleph\source\repos\OpenGL_Raytracer\| Debug|x64|C:\Users\brian\Desktop\Multimedia\mm_raytracer\OpenGL_Raytracer\|
B^C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ B^C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\ELEPH\SOURCE\REPOS\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ
......
B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ
......
B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ B^C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|C:\USERS\BRIAN\DESKTOP\MULTIMEDIA\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment