Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Testing out real-time (GLSL) raytracing  (Read 6835 times)

0 Members and 2 Guests are viewing this topic.

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Testing out real-time (GLSL) raytracing
« 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:




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 which I'm working on reverse-engineering for educational purposes.

I have my code on GitHub 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!
The truth will set you free but first it will piss you off.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Testing out real-time (GLSL) raytracing
« Reply #1 on: July 04, 2015, 09:44:11 am »
Looks quite interesting. Do you plan to do anything specific with it?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Testing out real-time (GLSL) raytracing
« Reply #2 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.  ::)
The truth will set you free but first it will piss you off.

zmertens

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Testing out real-time (GLSL) raytracing
« Reply #3 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:



This tutorial 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.
The truth will set you free but first it will piss you off.

ChronicRat

  • Sr. Member
  • ****
  • Posts: 327
  • C++ programmer
    • View Profile
    • My blog
Re: Testing out real-time (GLSL) raytracing
« Reply #4 on: July 16, 2015, 07:58:39 am »
Cool!

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Testing out real-time (GLSL) raytracing
« Reply #5 on: July 16, 2015, 10:08:58 am »
Awesome. :) Now make it 4K 60 FPS please. ;-)

 

anything