コード例 #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);
     }
 }