• Welcome to Dark Bit Factory & Gravity.
 

Ray intersect Sphere??

Started by Devils Child, August 07, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Stonemonkey

#20
For specular lighting you use the dot product of the normalised point->light vector and the reflected ray vector, the calcs for reflecting a ray are in the function I gave before. To reflect a vector you need to know what the initial vector is (incoming) and the surface normal of the point it is reflecting off.

The only way I've raytraced cubes so far is by creating a mesh and using ray->triangle intersections, the example you linked to doesn't allow for rotating the cube at all so if you wanted to do that then you'd need to rotate the ray around the cube, find the intersection (if that's possible) then un-rotate and do your lighting and reflection, a similar procedure would be needed for shadowing.

There may be some specific way to raytrace cubes but I don't know, another idea may be to define the cube as 6 planes and do some sort of tests with those.

Devils Child

cool, fast reply :)
i like you!

sorry if a ask sooo many questions at once. i dont want you to feel like my dictionary.
but there is another bug coming up. i thought it would be good to have an infinite ray, but it isnt. i think i need a limited ray again, because the shadowing routine is extreme buggy because of infinite ray... ???

Stonemonkey

Sorry, I don't really understand what you mean by infinite ray. When you test for intersections it shouldn't matter how far away an object is or if there is no intersection and when you test for shadows you first find the distance from the point to the lightsource and only check for intersections within that distance.

Devils Child

well, whatever the reason is that you dont understand, i need the ray to be NOT infinite...