No announcement yet.

raytracing: inside and outside sphere

  • Filter
  • Time
  • Show
Clear All
new posts

  • raytracing: inside and outside sphere

    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)

  • #2
    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.


    • #3
      got it now, my own in and out sphere.
      it was just one sign in the "k" formula.
      I still need lots of "training".


      • #4
        Hey! What preset (or AVS Pack) of UnConed that explain about ray tracing and not very hard to understand?