Notes for February 26-28

 

What we discussed on Tuesday Feb 26:
  • Zipfiles
    To copy an entire directory from your local computer to your CIMS account:

    1. In a local terminal window, in the parent directory of the one you want to copy:
      zip -r DIR DIR
      where "DIR" is the name of the directory you want to copy.

      scp DIR.zip YOUR_ID@access.cims.nyu.edu:public-html/DIR.zip

    2. In a terminal window logged into CIMS:
      cd public_html
      unzip DIR
  • Built-in reflect() function: negative of the R() function we implemented in class
  • Using matrix types to store lighting and materials data: example code is included in zipfile
  • Shadows: covered again in more detail on Thursday
  • Reflections: covered again in more detail on Thursday
  • Indexing arrays:
    The most important take-away is that array indices must be constant. The looping variable in a for loop is ok to use as an array index, because it is known at compile time (since loops are unrolled by the compiler).

What we discussed on Thursday Feb 28:

  • Moving data from Javascript to GLSL
    The code we wrote in class is all included in this week's zipfile shader4.zip.
  • Shadow algorithm
       Shadow algorithm, given surface pt P and dir vector L toward light:
          for all shapes S[i]
             if ray_trace_to_shape(P, L, S[i]) > 0.001
    	    return true;
          return false;
    
       You can call your shadow function right inside your phong algorithm.
          When looping over lights in your phong-computing function:
             Don't add Diffuse or Specular component for
             any light source that is in shadow.
    
  • Reflection algorithm
       Reflection algorithm for shape j, given surface pt P and ray reflection dir vector R:
          alpha = M[j][3].a // store mirror reflectivity somewhere in material properties
          if alpha > 0
             t = 1000
             for all shapes S[i]
                _t = ray_trace_to_shape(P, R, S[i])
                if _t > 0.001 && _t < t
    	       t = _t
    	       Si = S[i]
    	       Mi = M[i]
             if t < 1000
                color = mix(color, phong(P, N, Si, Mi), alpha)
    
    
Homework due before class on Thursday March 7:

Add shadows and reflections (first ray bounce only is fine) to your ray tracer.

Important note: In my library file shader4/lib2.js I added an implementation of function ray_sphere() [see lines 51-57] so that I could show you working examples.

You should remove those lines or comment them out, so that the compiler won't complain that there are two declarations of ray_sphere() -- that one and the one you implemented.

There are many opportunities here for extra credit, including adding procedural textures to various places, and doing interesting things on the Javascript side before you pass data down to the GPU.


At the end of the lecture we watched RYAN