Package ca.eandb.jmist.framework.path

Examples of ca.eandb.jmist.framework.path.PathNode


   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceEyePath(ca.eandb.jmist.framework.Lens, ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceEyePath(Lens lens, Point2 p, PathInfo pathInfo,
      Random rnd) {
    if (eyeDepth > 0) {
      PathNode head = lens.sample(p, pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, eyeDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceLightPath(ca.eandb.jmist.framework.Light, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceLightPath(Light light, PathInfo pathInfo, Random rnd) {
    if (lightDepth > 0) {
      PathNode head = light.sample(pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, lightDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceEyePath(ca.eandb.jmist.framework.Lens, ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceEyePath(Lens lens, Point2 p, PathInfo pathInfo,
      Random rnd) {
    PathNode head = lens.sample(p, pathInfo, rnd.next(), rnd.next(), rnd.next());
    return PathUtil.expand(head, maxDepth - 1, rnd);
  }
View Full Code Here

   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceEyePath(ca.eandb.jmist.framework.Lens, ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceEyePath(Lens lens, Point2 p, PathInfo pathInfo,
      Random rnd) {
    if (maxEyeDepth > 0) {
      PathNode head = lens.sample(p, pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, maxEyeDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceLightPath(ca.eandb.jmist.framework.Light, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceLightPath(Light light, PathInfo pathInfo, Random rnd) {
    if (maxLightDepth > 0) {
      PathNode head = light.sample(pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, maxLightDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here

          //if (ratio < 0.0) bp();
          pdf[s + 1] = pdf[s] * Math.max(ratio, 0.0);
        }
      }

      PathNode zjp2 = lightNode;
      PathNode zjp1 = eyeNode; // z_{j+1}, j == k - i
      for (int i = s + 1; i <= k; i++) {
        if (i + 1 > maxLightDepth) {
          break;
        }

        PathNode zj = zjp1.getParent();
        double rpdf = 0.0;
        if (zjp2 != null) {
          Vector3 v = PathUtil.getDirection(zjp2, zjp1);
          rpdf = zjp2.isSpecular() ? zjp2.getPDF() : zjp1.getReversePDF(v);
        } else if (zjp1 instanceof ScatteringNode) {
          ScatteringNode scatNode = (ScatteringNode) zjp1;
          Vector3 v = PathUtil.getDirection(zjp1, zj);
          rpdf = scatNode.getSourcePDF(v);
        }
        double ratio = (rpdf * zjp1.getGeometricFactor())
            / (zj.getPDF() * zj.getGeometricFactor());

        if (ratio < 0.0) bp();

        pdf[i + 1] = pdf[i] * Math.max(ratio, 0.0);

        zjp2 = zjp1;
        zjp1 = zj;
      }

      PathNode zj = eyeNode;
      boolean specular = false;
      for (int i = s; i <= k; i++) {
        if (specular) {
          pdf[i + 1] = 0.0;
        }
        specular = zj.isSpecular();
        if (specular) {
          pdf[i + 1] = 0.0;
        }
        zj = zj.getParent();
      }
    }

    // Shorter light path, longer eye path
    if (lightNode != null) {
      if (t < maxEyeDepth) {
        if (eyeNode != null) {
          Vector3 v = PathUtil.getDirection(eyeNode, lightNode);
          double ratio = (eyeNode.getPDF(v) * gle)
              / (lightNode.getPDF() * lightNode.getGeometricFactor());
          //if (ratio < 0.0) bp();
          pdf[s - 1] = pdf[s] * Math.max(ratio, 0.0);
        } else {
          /* Here the ratio has in the numerator the probability density
           * of selecting the node at the end of the light path (i.e.,
           * lightNode) as the starting point for an eye path.  Since we
           * do not currently support intersections with the aperture,
           * this probability is zero.  Therefore pdf[s - 1] == 0.0, so
           * we have nothing to do here.
           */
        }
      }

      PathNode yip1 = eyeNode;
      PathNode yi = lightNode;
      for (int i = s - 1; i > 0; i--) {
        if (k + 2 - i > maxEyeDepth) {
          break;
        }

        PathNode yim1 = yi.getParent();
        double rpdf = yip1 != null
            ? (yip1.isSpecular() ? yip1.getPDF() : yi.getReversePDF(PathUtil.getDirection(yip1, yi)))
            : 0.0;
        double ratio = (rpdf * yi.getGeometricFactor())
            / (yim1.getPDF() * yim1.getGeometricFactor());

        //if (ratio < 0) bp();
        pdf[i - 1] = pdf[i] * Math.max(ratio, 0.0);

        yip1 = yi;
        yi = yim1;
      }

      PathNode yim1 = lightNode;
      boolean specular = false;
      for (int i = s; i > 0; i--) {
        if (specular) {
          pdf[i - 1] = 0.0;
        }
        specular = yim1.isSpecular();
        if (specular) {
          pdf[i - 1] = 0.0;
        }
        yim1 = yim1.getParent();
      }
    }

    pdf[k + 1] = 0.0; // Aperture not modeled as part of the scene
    //pdf[k] = 0.0;
View Full Code Here

   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceEyePath(ca.eandb.jmist.framework.Lens, ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceEyePath(Lens lens, Point2 p, PathInfo pathInfo,
      Random rnd) {
    if (maxEyeDepth > 0) {
      PathNode head = lens.sample(p, pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, maxEyeDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.path.BidiPathStrategy#traceLightPath(ca.eandb.jmist.framework.Light, ca.eandb.jmist.framework.path.PathInfo, ca.eandb.jmist.framework.Random)
   */
  public PathNode traceLightPath(Light light, PathInfo pathInfo, Random rnd) {
    if (maxLightDepth > 0) {
      PathNode head = light.sample(pathInfo, rnd.next(), rnd.next(), rnd.next());
      return PathUtil.expand(head, maxLightDepth - 1, rnd);
    }
    return null;
  }
View Full Code Here

    }

    int sy = y.getLightPathLength();
    int ty = y.getEyePathLength();

    PathNode lightNode = y.getLightTail();
    PathNode eyeNode = y.getEyeTail();
    double p0 = 1.0;
    for (int l1 = sy - slice.s; l1 > 0; l1--) { // FIXME check this
      p0 *= (lightNode.getPDF() * lightNode.getGeometricFactor());
      lightNode = lightNode.getParent();
    }
    for (int m1 = ty - slice.t; m1 > 0; m1--) { // FIXME check this
      p0 *= (eyeNode.getPDF() * eyeNode.getGeometricFactor());
      eyeNode = eyeNode.getParent();
    }

    lightNode = y.getLightTail();
    eyeNode = y.getEyeTail();
    double gle = (lightNode == null || eyeNode == null) ? 1.0
        : PathUtil.getGeometricFactor(lightNode, eyeNode);

    double[] p = new double[ka];

    if (sy - slice.s >= 0 || sy - slice.s < p.length) {
      p[sy - slice.s] = p0;
    }

    PathNode x0, x1, x2;
    double p1;

    x2 = y.getLightTail();
    x1 = y.getEyeTail();

    p1 = p0;
    x0 = x1 != null ? x1.getParent() : null;
    for (int l1 = sy - slice.s - 1; l1 >= 0; l1--) {
      assert(x2 != null);

      double g = (x1 == null || x1.isOnEyePath())
          ? gle : x1.getGeometricFactor();
      double rpdf;

      if (x1 == null) {
        rpdf = 0.0; // Aperture not modeled as part of scene
      } else if (x1.isOnEyePath()) {
        rpdf = x1.getPDF(PathUtil.getDirection(x1, x2));
      } else if (x0 == null) {
        rpdf = 0.0;
      } else if (x0.isOnLightPath() && x0.isSpecular()) {
        rpdf = x0.getPDF();
      } else {
        rpdf = x1.getReversePDF(PathUtil.getDirection(x0, x1));
      }

      double ratio = (rpdf * g) / (x2.getPDF() * x2.getGeometricFactor());
      p1 *= Double.isNaN(ratio) ? 0.0 : ratio;
      if (l1 >= 0 && l1 < p.length) {
        p[l1] = p1;
      }

      x0 = x1;
      x1 = x2;
      x2 = x2.getParent();
    }

    x2 = y.getEyeTail();
    x1 = y.getLightTail();

    p1 = p0;
    x0 = x1 != null ? x1.getParent() : null;
    for (int m1 = ty - slice.t - 1; m1 >= 0; m1--) {
      int l1 = ka - 1 - m1;
      assert(x2 != null);

      double g = (x1 == null || x1.isOnLightPath())
          ? gle : x1.getGeometricFactor();
      double rpdf;

      if (x1 == null) {
        rpdf = x2 instanceof ScatteringNode
            ? ((ScatteringNode) x2).getSourcePDF()
            : 0.0;
      } else if (x1.isOnLightPath()) {
        rpdf = x1.getPDF(PathUtil.getDirection(x1, x2));
      } else if (x0 == null) {
        rpdf = 1.0;
        bp();
      } else if (x0.isOnEyePath() && x0.isSpecular()) {
        rpdf = x0.getPDF();
      } else {
        rpdf = x1.getReversePDF(PathUtil.getDirection(x0, x1));
      }

      double ratio = (rpdf * g) / (x2.getPDF() * x2.getGeometricFactor());
 
View Full Code Here

    CategoricalRandom r = generateDeletedSubpathProbabilities(x);
    IntPair slice = getSlice(x, r.next(rnd));

    //slice = new IntPair(0, 0);

    PathNode newLightTail = x.getLightTail();
    PathNode newEyeTail = x.getEyeTail();

    while (newLightTail != null && newLightTail.getDepth() > slice.s) {
      newLightTail = newLightTail.getParent();
    }
    while (newEyeTail != null && newEyeTail.getDepth() > slice.t) {
      newEyeTail = newEyeTail.getParent();
    }


    int kd = k - (slice.s + slice.t);
    int ka = getAddedSubpathLength(kd, rnd);

    //ka = 2;

    if (ka == 1 && kd == 1) { // mutation has no effect
      return null;
    }

    int l1 = RandomUtil.discrete(0, ka - 1, rnd);
    int m1 = ka - 1 - l1;

    if (newLightTail == null && l1 > 0) {
      PathInfo pi = x.getPathInfo();
      Light light = pi.getScene().getLight();
      newLightTail = light.sample(pi, rnd.next(), rnd.next(), rnd.next());
      l1--;
    }
    while (l1-- > 0) {
      newLightTail = newLightTail.expand(rnd.next(), rnd.next(), rnd.next());
      if (newLightTail == null || newLightTail.isAtInfinity()) {
        return null;
      }
    }

    if (newEyeTail == null && m1 > 0) {
      PathInfo pi = x.getPathInfo();
      Lens lens = pi.getScene().getLens();
      Point2 p = RandomUtil.canonical2(rnd);
      newEyeTail = lens.sample(p, pi, rnd.next(), rnd.next(), rnd.next());
      m1--;
    }
    while (m1-- > 0) {
      newEyeTail = newEyeTail.expand(rnd.next(), rnd.next(), rnd.next());
      if (newEyeTail == null || newEyeTail.isAtInfinity()) {
        return null;
      }
    }

    if (newLightTail == null || newEyeTail == null
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.path.PathNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.