SFML community forums

General => SFML projects => Topic started by: zmertens on July 03, 2015, 09:38:05 pm

Title: Testing out real-time (GLSL) raytracing
Post by: zmertens on July 03, 2015, 09:38:05 pm
I've been playing around with making a real-time raytracer using OpenGL (and SFML for window management). I got a pretty simple scene down but the camera is broken. Here's a very brief video:

http://youtu.be/0pBEnXEJ7ug


I'm using the same camera system I use for my OpenGL projects, but I think there's an issue with the coordinate system. The camera rotation isn't working but the movement appears to work decently (at least forward and backward). I think that I need to transform the vertices of the objects into view space using the ModelViewProjection matrix which is what I normally would do using OpenGL:

layout(location = 0) in vec3 VerticePosition;

uniform mat4 uMVP;

void main()
{
    gl_Position = uMVP * vec4(VerticePosition, 1.0);
}

However, I'm not sure how to emulate this with the purely GLSL raytracer raytracer. I found an example on GitHub (https://github.com/ArturKovacs/GL-raytracer) which I'm working on reverse-engineering for educational purposes.

I have my code on GitHub (https://github.com/zryan3/raytracing-experiments) if anyone's interested in checking it out. I used the C++ raytracer in the same repo as a guideline. The GLSL version is not optimal but more focused on getting the job done for testing purposes. I'm interested with the idea of learning compute shaders and maybe making raytraced Pong or something which could be cool.

I'm interested in any comments or critisicms of course!
Title: Re: Testing out real-time (GLSL) raytracing
Post by: eXpl0it3r on July 04, 2015, 09:44:11 am
Looks quite interesting. Do you plan to do anything specific with it?
Title: Re: Testing out real-time (GLSL) raytracing
Post by: zmertens on July 04, 2015, 05:31:34 pm
Looks quite interesting. Do you plan to do anything specific with it?

It's mostly for fun and experimentation. I think I'm going to try to intersect more objects and maybe try some more interesting effects. I'm interested in compute shaders so if I can figure those out I can do all the intersection tests outside of the fragment shaders which could speed the program up. I'm toying with the idea of making a basic game like pong. I need to fix the camera system first though.  ::)
Title: Re: Testing out real-time (GLSL) raytracing
Post by: zmertens on July 16, 2015, 07:00:55 am
I have a new video to add with the camera working, 40 spheroids, and (semi-working) reflections:

http://youtu.be/Q1ozJ7oykHs

This tutorial (https://github.com/LWJGL/lwjgl3-wiki/wiki/2.6.1.-Ray-tracing-with-OpenGL-Compute-Shaders-%28Part-I%29) helped me finish up the 3D camera for the raytracer. I also managed to get reflections working. I already knew how to do it but I haven't done it using iteration before (since GLSL doesn't use recursive function calling). But the reflections aren't working correctly.

This is still a sandbox sort of project but I'm happy with what's working and I think it looks pretty neat. If I can fix the reflections I'll probably add refractions and I want to try soft shadows, and I'm going to need use the computer shader I think to optimize the program.
Title: Re: Testing out real-time (GLSL) raytracing
Post by: ChronicRat on July 16, 2015, 07:58:39 am
Cool!
Title: Re: Testing out real-time (GLSL) raytracing
Post by: Tank on July 16, 2015, 10:08:58 am
Awesome. :) Now make it 4K 60 FPS please. ;-)