Jump to content
  • Advertisement
Sign in to follow this  
PlutoWarrior

OpenGL render a raytraced scene in opengl

This topic is 3899 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

Hey guys, So I've just finished writing up some code to make a basic ray tracer. It handles all vectors and ray casts and can do all the things I need to do to calculate lighting and reflections in my scene. Now I want to render all the wonderful math into a beautiful scene but I dunno what the best way to go about doing this in OpenGL. I'm open to suggestions!

Share this post


Link to post
Share on other sites
Advertisement
I guess the only thing left to do is give the buffer to GL. You can use glDrawPixels to draw it to a GL surface. GOogle it to see code examples

Share this post


Link to post
Share on other sites
hey

I think it might be best to just copy into a texture, and render the texture on a quad to the screen or something. Well it's just that I've heard glDrawPixels() is slow or something? although I have no clue about this myself, as I've never looked into it :\.

Checkout glTexSubImage2D() for updating part of, or all of the texture data.

Hmm, or maybe you can use a Pixel Buffer Object to access and update the texture data directly? but I know quite little about these.

cya

Share this post


Link to post
Share on other sites
Quote:
Original post by yosh64
hey

I think it might be best to just copy into a texture, and render the texture on a quad to the screen or something. Well it's just that I've heard glDrawPixels() is slow or something? although I have no clue about this myself, as I've never looked into it :\.

Checkout glTexSubImage2D() for updating part of, or all of the texture data.

Hmm, or maybe you can use a Pixel Buffer Object to access and update the texture data directly? but I know quite little about these.

cya


I would do it using textures. Create a map of a given resolution on a texture, from the perspective of each triangle in the scene, then turn it into a texture and render it to that object. The same would work if the only OpenGL polygon in the scene was drawn over the entire screen.

Share this post


Link to post
Share on other sites
Are you trying to use OGL to display the result of RT or are you trying to integrate RT in a OpenGL rendered scene?
In the first case I would create a full screen quad and use the RT resulting image as a texture. If you are going to build a real time raytracer, consider the possibility to use Pixel Shader to perform some operations too speed them up, like Tone Mapping, Blooms, and other post processing effects.

Share this post


Link to post
Share on other sites
Thanks everyone, I took what you said into account and I finally got something to the screen. It's not much but at least it's a start. Next step is to add some more features like reflection, refraction, and shadows. I also need to make the algorithm a little more suitable to recursive ray casting cause right now it's pretty hacked together. Here's a look.

Free Image Hosting at www.ImageShack.us

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!