PDA

View Full Version : raytracing: inside and outside sphere

your-dentist
28th January 2004, 11:36
it took me only two days to understand the basics of raytracing and to make my first planes and tunnels DMs, just with the help of the easy to understand explantions by UnConeD. Due to my bad math skill I can make more complex objects. So I simply copied the "k" for a sphere from one of UnConeD's tuts.
What I don't understand is how to move the camera out of the shere.
when the cam coords are something like oz=1 it's inside and distorts the sphere. in discoball the z-coord is oz=sin(t)+1.9 or something.
who can explain me how to the camera outside of and object in general? (also for cylinders)

UnConeD
28th January 2004, 14:17
The problem is that you need to pick the closest intersection point to the camera: for a sphere, there are usually two. If your camera only stays outside or inside, you can always use the same formula, otherwise you need to calculate both and compare them.

Copying k codes is pretty dumb though: the equation for a sphere around the origin is: x^2 + y^2 + z^2 = radius^2
If you've read my little raytracing intro, this should be enough to get you started and derive the k formula yourself.

your-dentist
30th January 2004, 07:48
thx.
got it now, my own in and out sphere.