Exemplo n.º 1
0
 public ShadingState getRadiance(float rx, float ry, float time, int i, int d, Ray r, IntersectionState istate, ShadingCache cache)
 {
     istate.time = time;
     scene.trace(r, istate);
     if (istate.hit())
     {
         ShadingState state = ShadingState.createState(istate, rx, ry, time, r, i, d, this);
         state.getInstance().prepareShadingState(state);
         IShader shader = getShader(state);
         if (shader == null)
         {
             state.setResult(Color.BLACK);
             return(state);
         }
         if (cache != null)
         {
             Color c = cache.lookup(state, shader);
             if (c != null)
             {
                 state.setResult(c);
                 return(state);
             }
         }
         state.setResult(shader.GetRadiance(state));
         if (cache != null)
         {
             cache.add(state, shader, state.getResult());
         }
         checkNanInf(state.getResult());
         return(state);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public ShadingState getRadiance(float rx, float ry, int i, Ray r, IntersectionState istate)
 {
     lock (lockObj)
     {
         scene.trace(r, istate);
         if (istate.hit())
         {
             ShadingState state = ShadingState.createState(istate, rx, ry, r, i, this);
             state.getInstance().prepareShadingState(state);
             IShader shader = getShader(state);
             if (shader == null)
             {
                 state.setResult(Color.BLACK);
                 return(state);
             }
             if (_shadingCache != null)
             {
                 Color c = lookupShadingCache(state, shader);
                 if (c != null)
                 {
                     state.setResult(c);
                     return(state);
                 }
             }
             state.setResult(shader.getRadiance(state));
             if (_shadingCache != null)
             {
                 addShadingCache(state, shader, state.getResult());
             }
             return(state);
         }
         else
         {
             return(null);
         }
     }
 }