[csu540-f05-rpf] pseudocode for ray tracing

Robert Futrelle futrelle at ccs.neu.edu
Thu Nov 3 12:48:46 EST 2005


Pseudocode for ray tracing:
Prof. Futrelle 11/03/05



for each ray R do

   hitAny = false
   objectHit = null
   t = defaultVal // any will do

   for each object O do
      test for hit of R on O

      if get a hit: set tHit
        if (hitAny == false)
           hitAny = true
           t = tHit
           set objectHit to O

        else // hitAny was true
          set t =  best of t and tHit // often smallest
          if new hit better // t changed
             set objectHit to O

   // do next object

    set pixel color for this ray to O.color

// do next ray



More information about the csu540-f05-rpf mailing list