Opengl raytracer

Started by
16 comments, last by s_p_oneil 19 years, 6 months ago
Hi, I am making a simple modeling app and was thinking about making a raytracer before I set up my objects and materials in opengl. Would it be possible to make a raytracer using an opengl scence? eg cast a ray from the eye(glulookat) and intersect gl objects then plot the pixel? Or is it a waste of time? Has this ever been done? Thanks for any info
Advertisement
Quote:Original post by one mind
eg cast a ray from the eye(glulookat) and intersect gl objects then plot the pixel?


?? why isnt this making any sense to me?
f@dzhttp://festini.device-zero.de
Quote:Original post by Trienco
Quote:Original post by one mind
eg cast a ray from the eye(glulookat) and intersect gl objects then plot the pixel?


?? why isnt this making any sense to me?


in other word,what ray tracing does is assuming there are rays of light fired from user's eyes and for every pixel on screen there is such a ray goes pass it.these rays will be casted until it hit a object,and then according to the type of the object it hit,angle,lighting and other factor,the colour of the pixel where the ray is form will be determined.in that way a 3D picture will be generated on screen.

and to the original question,certainly it is possible to make a raytracer with opengl.because raytracer is a algorithm for finding the colour and opengl is for plotting the colour onto correct pixel.what i am saying is you basically write a raytracer to find out colour of the pixels. then create a instance of opengl,get the address of video memory and draw the colour on.
Normally open gl isn't used for more than drawing each pixel using glRect. The rest is all done in code. If you wish to use pixel shaders this changes.
Quote:Original post by jimywang
...then create a instance of opengl,get the address of video memory and draw the colour on.


I'm certainly curious to find out how you managed to do that.
Quote:Original post by mikeman
Quote:Original post by jimywang
...then create a instance of opengl,get the address of video memory and draw the colour on.


I'm certainly curious to find out how you managed to do that.


well,I never used opengl,so dont really know if I shall say create instance or interface.but bottom line is it is similar to directdraw and direct3D.what I mean is get the opengl to draw the colour for you.
http://www.icarusindie.com/DoItYourSelf/rtsr/realtime3d/lessons23-30.php

that shows you how to get a basic raytracer going using OpenGL.

And no, OpenGL doesn't provide the interfaces to doing intersections with primatives so you have to supply all that math yourself. OpenGL uses rasterization for everything which is quite a bit different than raytracing.

OpenGL also doesn't provide direct access to video memory so it's slower for doing software rendering than DirectDraw.

All tutorials after the first couple use DirectDraw to get the software render into video memory to display to the user.
Quote:Original post by jimywang
well,I never used opengl,so dont really know if I shall say create instance or interface.but bottom line is it is similar to directdraw and direct3D.


except that it is decidely NOT object oriented, all 2d pixel writing is slow as hell and basically using opengl for raytracing -unless you (ab)use fragment shaders- is like using an elephant to buy cake.
f@dzhttp://festini.device-zero.de
Quote:Original post by Trienco
Quote:Original post by jimywang
well,I never used opengl,so dont really know if I shall say create instance or interface.but bottom line is it is similar to directdraw and direct3D.


except that it is decidely NOT object oriented, all 2d pixel writing is slow as hell and basically using opengl for raytracing -unless you (ab)use fragment shaders- is like using an elephant to buy cake.


agree.with directX you can get the video memory address directly.however, he is not going to make a real-time ray tracer anyway. it is doable with opengl.
Quote:Original post by jimywang
Quote:Original post by Trienco
Quote:Original post by jimywang
well,I never used opengl,so dont really know if I shall say create instance or interface.but bottom line is it is similar to directdraw and direct3D.


except that it is decidely NOT object oriented, all 2d pixel writing is slow as hell and basically using opengl for raytracing -unless you (ab)use fragment shaders- is like using an elephant to buy cake.


agree.with directX you can get the video memory address directly.however, he is not going to make a real-time ray tracer anyway. it is doable with opengl.


It's doable, but it's insane.You don't need to use an API like OpenGL to draw pixels on the screen. Even GDI would be better: You just draw the pixels in a memory block in RAM and use StretchDIBits() to display them.

This topic is closed to new replies.

Advertisement