Advertisement Jump to content
Sign in to follow this  
GameDevGP

OpenGL Real-time Ray Tracer in GLSL

This topic is 1756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

 

 

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by Chris_F

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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).

Edited by Tasaq

Share this post


Link to post
Share on other sites

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? :?
Edited by 0Silencer

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!