Ray tracing Help back

Board: Home Board index Raytracing General Development

(L) [2011/12/29] [ost by Tom] [Ray tracing Help] Wayback!

HI,
I am new to ray tracing and I had a project to do and I have written a code and it did work and I had 2 spheres as a result, but the image was not that clear and I didn't know how to create the 2 planes in the image so I need some help please.
Thanks.
(L) [2011/12/30] [ost by jbikker] [Ray tracing Help] Wayback!

So basically you're asking us to do your homework? [SMILEY :)]
Try to get started, see where you get stuck, then you can ask detailed questions. There are some good tutorials on ray tracing on the web.
(L) [2011/12/30] [ost by Tom] [Ray tracing Help] Wayback!

No I told you that I did it and I got 2 spheres as a result but the image is not quite good so I need some help to see where is the problem why am I having this, I need someone to take a look at my code but I won't post it cz I can't post it unless I've presented the project..
(L) [2012/01/02] [ost by Arite] [Ray tracing Help] Wayback!

So presumably you want to intersect rays with planes? Here's a useful webpage with links to lots of different object-object intersections (including ray-plane):
[LINK http://www.realtimerendering.com/intersections.html]

From there - Line-Plane intersection:
[LINK http://www.softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm#Line-Plane%20Intersection]

Be sure to normalise your vectors accordingly, and check that the normal and ray directions aren't perpendicular first. If dot(ray_dir, norm) > 0 then they won't intersect. Also if the distance to the plane is negative then the plane is behind the camera so also won't intersect.

Cheers, Arite.
(L) [2012/01/03] [ost by Arite] [Ray tracing Help] Wayback!

Can you be more specific? Like jbikker said ask detailed questions, and there are lots of good tutorials on the web. One I found useful is the Codermind tutorial:
[LINK http://www.codermind.com/articles/Raytracer-in-C++-Introduction-What-is-ray-tracing.html]

And of course Jacco's tutorials (URL is now slightly different as DevMaster's been updated):
[LINK http://devmaster.net/posts/raytracing-theory-implementation-part-1-introduction]

Anyway, the shading part is done after the intersection part. If you had diffuse, reflective and refractive surfaces, then you'd check/lookup the material of the object you intersected before you shade it. So to make a ray tracer without the reflection or refraction you just assume the object you've hit is a diffuse surface.

If you only have diffuse surfaces then, after your primary ray intersects with an object, fire another ray from that object to the light source (assuming it's a point light source); a shadow ray. Check the light source isn't behind the object (so ensure dot(norm, shadow_ray) > 0), and trace the ray to light source. If there are objects in the way then the part is occluded and so the colour is black/ambient colour. If it's not occluded then you colour the pixel.

Assuming you're doing [LINK http://en.wikipedia.org/wiki/Lambertian_reflectance lambertian reflection], the incoming light is inversely proportional to the square of the distance from the light source (which is just dot(shadow_ray, shadow_ray)). Multiply that by the light colour to give the incoming light. Then take dot(shadow_ray, norm) (normalise vectors first!) to get the cosine of the angle of the normal to the incoming light.

Multiply the incoming light by that, then multiply by the object colour (if it's white then no need). Return that colour and you're done.

EDIT: Seems I replied to a now deleted post.

Arite.
(L) [2012/01/03] [ost by jbikker] [Ray tracing Help] Wayback!

His professor found ompf. [SMILEY ;)]
(L) [2012/01/04] [ost by Tom] [Ray tracing Help] Wayback!

No he didn't actually [SMILEY :P] but it worked with me and I had 2 spheres with shadow thanks arite.

back