Real-time Ray Tracer in GLSL

Started by
7 comments, last by GameDevGP 10 years ago

Hi there, I'm new in Computer Graphics. so I started writing Ray Tracer and here is't.

and there are some questions I would like to answer..

I wrote iterative ray trace, I have one global array of stuctures; each structure can contain state of each step for ray trace.

and it's size is 2 ^ Depth; because in each state I may throw 2 rays(max), reflection or refraction ray, or otherwise its diffuse object so it doesn't need any other calculations.

at last I loop from last state to first one and update parent states.

also I'm passing all the information about my objects with uniforms. and drawing just single rectangle to make opengl call fragment shader for each pixel.

It's my solution and isn't too fast.. got fps 10.

so If I'm doing something wrongly or there is a some better way, I'll be glad to listen.

thanks.

Advertisement

Is this an April Fools? I would say, (if you're not joking) then you understand way more than most. For the next step, I would recommend:

Physically Based Rendering, Second Edition: From Theory To Implementation [Hardcover] and Source Code:

http://www.pbrt.org/index.php

http://www.amazon.com/gp/product/0123750792?ie=UTF8&tag=pharr-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0123750792

The book walks you through all the source code for the renderer.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

I don't quite get how you did this :)

In my real-time ray tracer I used compute shader instead of fragment. I am using this to experiment with new rendering technique, so it's not very sophisticated, it got texturing, reflections, shadows and classic Phong, and it's only based on speheres. I can get 60fps in 720p with one large textured sphere and dozen other flying around. All spheres are reflective (5 bounces). What I did is I just passed arrays of structures with lights and sphere's to the shader and did everything in one huge (aka uber) shader. It required to implement stack inside shader and other nifty things.

Could you describe step by step what are you doing? Could you provide us with more details, like resolution, your hardware etc.?

On a side note, ray tracing is hardcore to implement in real-time and low fps is predictable, "I'm new in Computer Graphics" and real-time ray tracing doesn't mix if you ask me.


It's my solution and isn't too fast.. got fps 10.

so If I'm doing something wrongly or there is a some better way, I'll be glad to listen.

I didn't quite understand you when you explained your approach. If you really want someone to critique it, then you should probably post your code. Also, if you are going to give performance information like FPS, you should really say what type of graphics card was used. Is that 10fps on a 8800GT or is that 10fps on a Titan Z? It makes a huge difference.

Thanks for reply :)

I said "I;m new" because it's my first project after doing some examples in OpenGL..

I'm uploading my code to git hub so, will post it here soon.

and also my Video Card is NVidia GeForce 525M.

and also my Video Card is NVidia GeForce 525M.

If you have Nvidia GPU why don't you try OptiX?

link here:

https://developer.nvidia.com/optix


If you have Nvidia GPU why don't you try OptiX?

I didn't know about it..

p.s Here's the source https://github.com/0silencer/RealTime-RayTracer

Any suggestions will be helpful :)

I think you did it in a similar way as I did mine.

I don't see part for triangle intersection? Does that mean the walls in your video are just enormous speheres? smile.png

More reasonable approach for ray tracing in real-time is to use either OpenCL or CUDA, they are much more flexible than fragment shaders. As you experienced you got 10 fps for scene with 10(?) spheres and 2 lights. I don't want to discourage you in any way, but imagine you want to render scene with, for instance, 5000 triangles smile.png For that you are bound to use acceleration structures, and they might be tough to implement with GPGPU.

If you want to follow the path of writing real-time ray tracers, you can try implementing geometry shader ray tracing:

http://ar.in.tum.de/pub/ralovich2010rsigs/ralovich2010rsigs.pdf

Note that this technique is slower than fragment shader method (ready article's results section for details).


I don't see part for triangle intersection? Does that mean the walls in your video are just enormous speheres?


More reasonable approach for ray tracing in real-time is to use either OpenCL or CUDA, they are much more flexible than fragment shaders. As you experienced you got 10 fps for scene with 10(?) spheres and 2 lights. I don't want to discourage you in any way, but imagine you want to render scene with, for instance, 5000 triangles For that you are bound to use acceleration structures, and they might be tough to implement with GPGPU.

It wrote that for educational purposes, so this was the proof that my idea was correct biggrin.png

but now if I want to write some acceleration structure, is there a way to pass it into a shader?
As I have read, there are limited number of uniform variables in GLSL..
The way I'm passing uniforms to shader are Ok? or there is a better way? :?

This topic is closed to new replies.

Advertisement