Ray tracing

Started by
3 comments, last by Sand_monkey 18 years, 1 month ago
Hello... In OpenGL I need to ray trace a sphere and illuminate it using the phong lighting model. I was wondering how I would go about doing this. I have a limited understanding that OpenGL does not support ray tracing but it must be possible (otherwise my task is impossible lol). I have seen allot of stuff online about the theories of ray tracing, and I have seen ALLOT of mathematical stuff... but absolutely no example code! For example I want to shoot rays at a sphere and basically say if the lights hits the sphere the pixel is white and if not it's black, but I have no idea how to go about coding this as I can’t seem to find any example code anywhere. Sorry for this REALLY noobish post… Thanks in advance for any useful help…
Advertisement
If OpenGL is a requirement you have two options: ray trace normally on the CPU and use OpenGL ortho mode to plot the pixels; or use programmable shaders to do the ray tracing. The first mode is easier, while the second mode is (performance-wise) faster and envolves more OpenGL coding (for example you could use GLSL). As a reference for the second method, look into:

Ray Tracing in Programmable Graphics Hardware
GPGPU

Hope this helps,

JVFF
ThanQ, JVFF (Janito Vaqueiro Ferreira Filho)
Thanks the first link was kinda helpfull...

But what I really need is just some basic example code... (As I said i'm a massive noob, srry again)
Quote:
I have seen allot of stuff online about the theories of ray tracing, and I have seen ALLOT of mathematical stuff... but absolutely no example code!

I searched google for "ray tracing tutorial" and found this article in about ten seconds. There's lots of sample code (and pseudocode) out there.

OpenGL won't be very helpful to you, except that you can use it to display the final result using glDrawPixels. You will store your image in a buffer in memory, and the actual ray-tracing code (given your description) won't require any external library; it's all math.
Free Mac Mini (I know, I'm a tool)
Excellent! Much thanks to you! (Much thanks to you? rofl)

This should really help me! *gives a shiny coin to igni ferroque*

This topic is closed to new replies.

Advertisement