Example #1
0
 /**
  * Get the radiance seen through a particular pixel
  *
  * @param istate intersection state for ray tracing
  * @param rx pixel x coordinate
  * @param ry pixel y coordinate
  * @param lensU DOF sampling variable
  * @param lensV DOF sampling variable
  * @param time motion blur sampling variable
  * @param instance QMC instance seed
  * @return a shading state for the intersected primitive, or
  *         <code>null</code> if nothing is seen through the specifieFd
  *         point
  */
 public ShadingState getRadiance(IntersectionState istate, float rx, float ry, double lensU, double lensV, double time, int instance)
 {
     if (bakingPrimitives == null)
     {
         Ray r = camera.getRay(rx, ry, imageWidth, imageHeight, lensU, lensV, time);
         return(r != null?lightServer.getRadiance(rx, ry, instance, r, istate) : null);
     }
     else
     {
         Ray r = new Ray(rx / imageWidth, ry / imageHeight, -1, 0, 0, 1);
         traceBake(r, istate);
         if (!istate.hit())
         {
             return(null);
         }
         ShadingState state = ShadingState.createState(istate, rx, ry, r, instance, lightServer);
         bakingPrimitives.prepareShadingState(state);
         if (bakingViewDependent)
         {
             state.setRay(camera.getRay(state.getPoint()));
         }
         else
         {
             Point3  p = state.getPoint();
             Vector3 n = state.getNormal();
             // create a ray coming from directly above the point being
             // shaded
             Ray incoming = new Ray(p.x + n.x, p.y + n.y, p.z + n.z, -n.x, -n.y, -n.z);
             incoming.setMax(1);
             state.setRay(incoming);
         }
         lightServer.shadeBakeResult(state);
         return(state);
     }
 }