Jump to content
  • Advertisement
Sign in to follow this  
one mind

OpenGL Opengl raytracer

This topic is 5465 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, 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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

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!