Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Real-time Ray Tracer in GLSL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 0Silencer   Members   -  Reputation: 110

Like
0Likes
Like

Posted 01 April 2014 - 01:14 PM

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.

 

 

 



Sponsor:

#2 Glass_Knife   Moderators   -  Reputation: 5058

Like
0Likes
Like

Posted 01 April 2014 - 02:51 PM

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"
Indie Game Programming

#3 Tasaq   Members   -  Reputation: 1258

Like
0Likes
Like

Posted 01 April 2014 - 05:00 PM

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.



#4 Chris_F   Members   -  Reputation: 2469

Like
0Likes
Like

Posted 01 April 2014 - 05:30 PM


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, 01 April 2014 - 05:32 PM.


#5 0Silencer   Members   -  Reputation: 110

Like
0Likes
Like

Posted 02 April 2014 - 08:02 AM

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.



#6 Tasaq   Members   -  Reputation: 1258

Like
0Likes
Like

Posted 02 April 2014 - 08:54 AM

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


Edited by Tasaq, 02 April 2014 - 08:55 AM.


#7 0Silencer   Members   -  Reputation: 110

Like
0Likes
Like

Posted 02 April 2014 - 12:09 PM


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



#8 Tasaq   Members   -  Reputation: 1258

Like
0Likes
Like

Posted 02 April 2014 - 02:18 PM

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, 02 April 2014 - 02:19 PM.


#9 0Silencer   Members   -  Reputation: 110

Like
0Likes
Like

Posted 03 April 2014 - 10:26 AM


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, 03 April 2014 - 10:27 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS