コード例 #1
0
ファイル: Statistics.cs プロジェクト: Vargol/PhotonPump
 public void accumulate(ShadingCache cache)
 {
     cacheHits      += cache.hits;
     cacheMisses    += cache.misses;
     cacheSumDepth  += cache.sumDepth;
     cacheNumCaches += cache.numCaches;
 }
コード例 #2
0
ファイル: Scene.cs プロジェクト: Vargol/PhotonPump
 public void accumulateStats(ShadingCache cache)
 {
     stats.accumulate(cache);
 }
コード例 #3
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);
     }
 }
コード例 #4
0
ファイル: Scene.cs プロジェクト: Vargol/PhotonPump
        /**
         * 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, int dim, ShadingCache cache)
        {
            istate.numEyeRays++;
            float sceneTime = camera.getTime((float)time);

            if (bakingPrimitives == null)
            {
                Ray r = camera.getRay(rx, ry, imageWidth, imageHeight, lensU, lensV, sceneTime);
                return(r != null?lightServer.getRadiance(rx, ry, sceneTime, instance, dim, r, istate, cache) : 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, sceneTime, r, instance, dim, lightServer);
                bakingPrimitives.prepareShadingState(state);
                if (bakingViewDependent)
                {
                    state.setRay(camera.getRay(state.getPoint(), sceneTime));
                }
                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);
            }
        }