• Advertisement
Sign in to follow this  

Is ray tracing hard or is it just me?

This topic is 969 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 all

 

I have the humble goal of writing the most simple ray tracer possible.

 

No shadows or specularity, just primary rays that intersect a single sphere so I end up with a 2d circle on a plain background.

 

The ray tracing algorithm is simple and easy to understand, but every time I look at some code or read whatever snippet on the web I can find, I just get lost.

 

What are the odds of a decent programmer figuring this out without a math degree?

 

Does anyone know of a simple code example or an easy to follow tutorial?

 

I think most just assume a great deal of prerequisite knowledge and am not sure where to start.

 

Any info getting this done would be greatly appreciated.

Thanks

Share this post


Link to post
Share on other sites
Advertisement

I'm not a graphics programmer, but in listening to people who do this often, raytracing is like pimpin'. It ain't easy. Also, based on what they say, if you know the maths, it should be most of the battle.

 

I'm shocked though that google hasn't led to you a solution though.

 

------

 

This is the first link I found. Seems to have everything you want.

 

Google search.

Edited by Alpha_ProgDes

Share this post


Link to post
Share on other sites

Thanks Alpha

 

Yes, I assure you I have read all that, cant say I understood it all :P

 

I think the raytracing is the easy part, obviously struggling with the math.

 

Most of these sites explain raytracing down to a T but gloss over sphere ray intersections etc.

Share this post


Link to post
Share on other sites

A sphere is nearly the simplest thing you can imagine, its just a point with a radius attached. A box got 8 points. Thats probably why many pictures from people starting to write a raytracer show spheres.

Just take the point of the viewer, calculate a vector to one of the points on the view rectangle (thats the ray), then calculate the smallest distance of the spheres midpoint to the line, then check if its smaller than the radius and not the wrong half of the line. If it hit the sphere, set the point to the spheres color, otherwise the background color. Repeat for all points. Most basic raytracer is done.

Refine with handling more than a single sphere, lighting, secondary or shadow rays, if you like to.

Edited by wintertime

Share this post


Link to post
Share on other sites

IMHO stick to Pythagoras and avoid trigonometric functions. This is like 10th grade school math? Some people even associated pixel coordinates with angels :-(
With regard to ray sphere intersection I cannot help, but think of inner products, which are more 12th grade, aren't they?

Share this post


Link to post
Share on other sites


IMHO stick to Pythagoras and avoid trigonometric functions. This is like 10th grade school math? Some people even associated pixel coordinates with angels :-(

 

I know that DirectX vs OpenGL is the equivalent of a religious war. But I didn't know pixel coordinates had become so sectarian themselves.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement