Example #1
0
 public Color lookup(ShadingState state, IShader shader)
 {
     if (state.getNormal() == null)
     {
         return(null);
     }
     // search further
     for (Sample s = first; s != null; s = s.next)
     {
         if (s.i != state.getInstance())
         {
             continue;
         }
         if (s.s != shader)
         {
             continue;
         }
         if (state.getRay().dot(s.dx, s.dy, s.dz) < 0.999f)
         {
             continue;
         }
         if (state.getNormal().dot(s.nx, s.ny, s.nz) < 0.99f)
         {
             continue;
         }
         // we have a match
         hits++;
         return(s.c);
     }
     misses++;
     return(null);
 }
Example #2
0
        public void add(ShadingState state, IShader shader, Color c)
        {
            if (state.getNormal() == null)
            {
                return;
            }
            depth++;
            Sample s = new Sample();

            s.i    = state.getInstance();
            s.s    = shader;
            s.c    = c;
            s.dx   = state.getRay().dx;
            s.dy   = state.getRay().dy;
            s.dz   = state.getRay().dz;
            s.nx   = state.getNormal().x;
            s.ny   = state.getNormal().y;
            s.nz   = state.getNormal().z;
            s.next = first;
            first  = s;
        }