Posts Tagged ‘ray’

26Jun

Here is a screen shot from my ray tracer. I have 2 triangle in the background (lighting isn’t very awesome on them), 2 spheres with specular lighting and shadows working.  I am going to go back and add reflection and refraction one day. Like any other ray tracer this one works like this:

for each pixel

calculate ray, check if it intersects with any object

if it does find the color of that point on object determined  by light position and whether it is behind something or not

else use background color.

So as far as the code… This is writen in C++ using almost completely C conventions. I am using OpenGL (a pretty early version). Its about 70% C 30% C++. Prior to writing this program my knowledge was pretty limited. I am going to fix this and make it 100% C style. For now though I am being a little lazy.

Here is the source. Not the most elegant C code, but it is easy to follow and it is CLEAN, and I think commented even. Also the project folder is a little messy. If you open the solution it looks pretty clean though.

Share