Commit 8b76ad7c authored by GERHarcos's avatar GERHarcos

es geht voran

parent 04b92c75
......@@ -3,29 +3,55 @@ layout (local_size_x = 1, local_size_y = 1) in;
layout (rgba32f, binding = 0) uniform image2D img_output;
void main () {
vec4 pixel = vec4 (0.0, 0.0, 0.0, 1.0);
ivec2 pixel_coords = ivec2 (gl_GlobalInvocationID.xy);
// INIT
// Set a Standard-Color for non-Hitted Points
vec4 pixel = vec4 (1.0, 0.0, 0.0, 1.0);
// Sphere-Attributes
vec3 sphere_center = vec3 (0.0, 0.0, -10.0);
float sphere_radius = 3;
// Scale-Values for our ray-ortho
float max_x = 5.0;
float max_y = 5.0;
// That is the Position on Screen where we will draw the Pixel to, we query the Dimensions too
ivec2 pixel_coords = ivec2 (gl_GlobalInvocationID.xy);
ivec2 dims = imageSize (img_output);
// CALCULATION
// Now we let the ray point to the Sphere at (0,0) and normalize it
float x = (float(pixel_coords.x * 2 - dims.x) / dims.x);
float y = (float(pixel_coords.y * 2 - dims.y) / dims.y);
vec3 ray_o = vec3 (x * max_x, y * max_y, 0.0);
vec3 ray_d = vec3 (0.0, 0.0, 1.0); // ortho
vec3 sphere_c = vec3 (0.0, 0.0, -10.0);
float sphere_r = 1.0;
// so that this here points from the current pixel_coords to the Sphere Coords in 2D
vec3 ray_ortho = vec3 (x * max_x, y * max_y, 0.0);
// obviously the ortho
vec3 ray_direction = vec3 (0.0, 0.0, -1.0);
vec3 omc = ray_o - sphere_c;
float b = dot (ray_d, omc);
float c = dot (omc, omc) - sphere_r * sphere_r;
// Do Sphere-Hitted?-Stuff
vec3 ray_orthoToSphere = sphere_center - ray_ortho;
float b = dot (ray_direction, -ray_orthoToSphere);
float c = dot (ray_orthoToSphere, ray_orthoToSphere) - sphere_radius * sphere_radius;
float bsqmc = b * b - c;
float t = 10000.0;
// hit one or both sides
//if (bsqmc >= 0.0) {
// pixel = vec4 (0.4, 0.4, 1.0, 1.0);
// If our Sphere was hitted, bsqmc should be >= 0 so change the Color of the Pixel
if (bsqmc >= 0.0) {
pixel = vec4 (0.4, 0.4, 1.0, 1.0);
}
// Check gl_GlobalInvocationID for error per 0-Check...
//if ( gl_GlobalInvocationID.x == 0 && gl_GlobalInvocationID.y == 0) {
// pixel = vec4(1.0, 1.0, 1.0, 1.0);
//}
pixel = vec4(1.0, 0.0, 0.0, 1.0);
// Write resulting Color
imageStore (img_output, pixel_coords, pixel);
}
// TODO: gl_GlobalInvocationID.xy gives (0,0), but we want it to hold the current Pixel's Position!
// After that, you should check on the Hit-Calculation if it does not give the Sphere Shape.
\ No newline at end of file
......@@ -364,6 +364,8 @@ void rt::rt_window::draw()
glUseProgram(userData->programObjectNonCompute);
checkError("glUseProgram");
glBindVertexArray(userData->vertexArrayObject);
//set finished texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
......
 glCalls.cpp
LINK : D:\Freiberg\Multimeida\Raytracing\mm_raytracer\OpenGL_Raytracer\x64\Debug\OpenGL_Raytracer.exe wurde nicht gefunden oder beim letzten inkrementellen Linkvorgang nicht erstellt; vollständiger Link wird durchgeführt.
OpenGL_Raytracer.vcxproj -> D:\Freiberg\Multimeida\Raytracing\mm_raytracer\OpenGL_Raytracer\x64\Debug\OpenGL_Raytracer.exe
B^D:\FREIBERG\MULTIMEIDA\RAYTRACING\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|D:\FREIBERG\MULTIMEIDA\RAYTRACING\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|D:\FREIBERG\MULTIMEIDA\RAYTRACING\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\OPENGL_RAYTRACER.OBJ
......
B^D:\FREIBERG\MULTIMEIDA\RAYTRACING\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLAD.OBJ|D:\FREIBERG\MULTIMEIDA\RAYTRACING\MM_RAYTRACER\OPENGL_RAYTRACER\OPENGL_RAYTRACER\X64\DEBUG\GLCALLS.OBJ|D:\FREIBERG\MULTIMEIDA\RAYTRACING\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