[csu540-f05-rpf] How to do perspective ray tracing

Robert Futrelle futrelle at ccs.neu.edu
Tue Oct 4 21:11:00 EDT 2005


Delighted to hear that someone's done it all.  If you've done the 
perspective view, the harder one, you could just turn in that.  But 
it would be better to turn in code for both approaches - hope you've 
kept them separate.

One screenshot of the orthographic view and two shots of the 
perspective views would be appropriate, since the latter can be 
'shot' with different parameters. Changing the eyepoint and screen 
positions is the easiest. Changing the view screen scale, in 
addition, is more interesting.

The more the merrier.

  -- Prof. Futrelle



>Thanks for the tip, I got the perspective view to work. When we submit
>this hw, do we need to take multiple screen shots of our SS?One with
>the Orthrographic ray trace and the other with the perspective ray trace?
>And the code we submit, do we need to submit the perspective version of
>the code only?
>
>Thank you.
>
>-Philip Lee Lee-
>
>On Tue, 4 Oct 2005, Robert Futrelle wrote:
>
>>  Note on perspective ray tracing for spheres
>>  by Prof. Futrelle, 10/4/05
>>
>>  The trick is to get the geometry of your setup right.
>>  I'll describe an example.  Your initial tests can use
>>  just one sphere at the origin, or in another simple
>>  location, but with different  perspectives,
>>  to make sure things are working.
>>
>>  Here's a typical geometry you'd use for your final
>>  system (larger than for a test system):
>>
>>  Say your solar system is 500 pixels (px) wide and 400 px
>>  tall with a sun of R = 50 px.  Assume your planets are
>>  placed within r = 200 px of the sun and have radii
>>  of the order of 10 to 20 px.  They don't all have
>>  to be in the xz plane.
>>
>>  Set your eyepoint at raye = 0,0,2000.
>>  Have a color array 500x400.
>>
>>  Now comes the important part:
>>
>>  Set up an ViewArray in a "view plane" at z = 1000.
>>  The ViewArray will also be 500x400.
>>  The trick is to put the corner of the ViewArray
>>  at x = -250, y  = -200.
>>
>>  Now you step through i,j, for x and y.
>>  For each i,j, you calculate the coordinates of
>>  a vector rayd from the eyepoint as
>>  x = -250 + i and y = -200 + j and z = 1000 - 2000 = -1000,
>>  so that rayd is directed from the eyepoint into the
>>  scene, along the negative z axis.
>>
>>  For each rayd, you solve to see if it hits any
>>  sphere, and pick the closest hit, if any, and
>>  the color of the planet, or sun, you hit.
>>
>>  The fun begins when you move the eyepoint further
>>  away to get more of a "telephoto" view, or
>>  move the ViewArray closer.
>>
>>  If you want a magnified view, so that a planet
>>  fills your screen, you make the ViewArray smaller
>>  but with the same number of pixels, e.g.,
>>  a 500,400 array with spatial coordinates from
>>  x = - 100 to +100 and y from -80 to +80.
>>  Then the steps for your rayd positions would
>>  be 2/5 i or j, not i or j as i and j range
>>  over the 500x400 array.
>>
>>  N.B. You never actually need to construct the
>>  ViewArray. It's just a way to organize your
>>  computations.  It's a set of parameters,
>>  not an actual 2D array in your Java code.
>>  If you want to construct an actual array
>>  and store your rayd(i,j) values in it, that's OK.
>>  Could be useful if you're using it over and
>>  over as you change the scene - "As the World Turns".
>>
>>  Draw lots of pictures so you can 'see' what
>>  I'm talking about. 2D pictures, with x coming
>>  out of your page and y and z in the page,
>>  should be all you need.
>>
>>  Go for it!
>>
>>     - Prof. Futrelle
>>
>>
>>  _______________________________________________
>>  csu540-f05-rpf mailing list
>>  csu540-f05-rpf at lists.ccs.neu.edu
>>  https://lists.ccs.neu.edu/bin/listinfo/csu540-f05-rpf
>>
>
>_______________________________________________
>csu540-f05-rpf mailing list
>csu540-f05-rpf at lists.ccs.neu.edu
>https://lists.ccs.neu.edu/bin/listinfo/csu540-f05-rpf




More information about the csu540-f05-rpf mailing list