Package ca.eandb.jmist.framework.color

Examples of ca.eandb.jmist.framework.color.Color


      ScatteredRay sr;

      if (grandChild != null) {
        double rpdf = grandChild.getReversePDF();
        double pdf = grandChild.getPDF();
        Color color = grandChild.getCumulativeWeight()
            .divide(child.getCumulativeWeight())
            .times(pdf / rpdf);
        sr = grandChild.isSpecular()
            ? ScatteredRay.specular(ray, color, rpdf)
            : ScatteredRay.diffuse(ray, color, rpdf);
      } else { // grandChild == null
        double pdf = newParent.getPDF(v);
        Color color = newParent.scatter(v).divide(pdf);
        sr = ScatteredRay.diffuse(ray, color, pdf);
      }

      return new SurfaceNode(newParent, sr, surf, getRU(), getRV(), getRJ());
    } else { // newParent == null
View Full Code Here


    if (g <= 0.0) {
      return null;
    }

    Color etol = a.scatter(v);
    Color ltoe = b.scatter(v.opposite());
    Color c = etol.times(ltoe);

    if (ColorUtil.getTotalChannelValue(c) > 0.0
        && PathUtil.visibility(a, b)) {

      c = c.times(g);

      c = c.times(a.getCumulativeWeight()).times(
          b.getCumulativeWeight());

      return c;

    } else { // No mutual scattering or nodes not mutually visible
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Painter#getColor(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  @Override
  public Color getColor(SurfacePoint p, WavelengthPacket lambda) {
    Color result = inner.getColor(p, lambda);
    Color min = lambda.getColorModel().getGray(range.minimum(), lambda);
    return min.plus(result.times(range.length()));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Painter#getColor(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  @Override
  public Color getColor(SurfacePoint p, WavelengthPacket lambda) {
    Color sum = null;
    for (Painter child : children()) {
      sum = ColorUtil.add(sum, child.getColor(p, lambda));
    }
    return sum;
  }
View Full Code Here

      ScatteredRay sr;

      if (grandChild != null) {
        double rpdf = grandChild.getReversePDF();
        double pdf = grandChild.getPDF();
        Color color = grandChild.getCumulativeWeight()
            .divide(child.getCumulativeWeight())
            .times(pdf / rpdf);
        sr = grandChild.isSpecular()
            ? ScatteredRay.specular(ray, color, rpdf)
            : ScatteredRay.diffuse(ray, color, rpdf);
      } else { // grandChild == null
        double pdf = newParent.getPDF(v);
        Color color = newParent.scatter(v).divide(pdf);
        sr = ScatteredRay.diffuse(ray, color, pdf);
      }

      return new SurfaceNode(newParent, sr, surf, getRU(), getRV(), getRJ());
    } else { // newParent == null
View Full Code Here

    double    LdotN = L.dot(N);
    double    tanAlpha = Math.tan(Math.acos(HdotN));
    double    cos4Alpha = HdotN * HdotN * HdotN * HdotN;

    Medium    medium = x.getAmbientMedium();
    Color    n1 = medium.refractiveIndex(x.getPosition(), lambda);
    Color    k1 = medium.extinctionIndex(x.getPosition(), lambda);
    Color    n2 = n.sample(lambda);
    Color    k2 = k.sample(lambda);
    Color    F = MaterialUtil.reflectance(E, n1, k1, n2, k2, N);
    double    D = Math.exp(-(tanAlpha * tanAlpha / mSquared)) / (Math.PI * mSquared * cos4Alpha);
    double    G = Math.min(1.0, Math.min(2.0 * HdotN * EdotN / EdotH, 2.0 * HdotN * LdotN / EdotH));

    return F.times(D * G / (4.0 * EdotN * LdotN));
  }
View Full Code Here

    }

    in = in.unit();
    out = out.unit();

    Color d = diffuse.getColor(x, lambda);
    Color s = specular.getColor(x, lambda);

    Vector3 n = x.getShadingNormal();

    Color D = d.divide(Math.PI);

    double ci = -n.dot(in);
    double co = n.dot(out);
    Vector3 h = out.minus(in).unit();

    double ch = n.dot(h);
    double ch2 = ch * ch;
    double sh2 = 1.0 - ch2;
    double th2 = sh2 / ch2;
    double alpha2 = alpha * alpha;

    double k = (1.0 / Math.sqrt(co * ci))
        * Math.exp(-th2 / alpha2) / (4.0 * Math.PI * alpha2);
    Color S = s.times(k);

    return D.plus(S);

  }
View Full Code Here

    Vector3 n = x.getNormal();
    if (n.dot(v) > 0.0) {
      return null;
    }

    Color d = diffuse.getColor(x, lambda);
    Color s = specular.getColor(x, lambda);
    double davg = ColorUtil.getMeanChannelValue(d);
    double savg = ColorUtil.getMeanChannelValue(s);
    double total = davg + savg;

    Basis3 basis = x.getShadingBasis();
    Vector3 out;

    if (RandomUtil.bernoulli(davg / total, rj)) { // diffuse

      do {
        out = RandomUtil.diffuse(ru, rv).toCartesian(basis);
      } while (n.dot(out) <= 0.0);

    } else { // specular

      do {
        SphericalCoordinates sc = new SphericalCoordinates(
            Math.atan(alpha * Math.sqrt(-Math.log(1.0 - ru))),
            2.0 * Math.PI * rv);

        Vector3 h = sc.toCartesian(basis);
        out = Optics.reflect(v, h);
      } while (n.dot(out) <= 0.0);

    }

    Ray3 ray = new Ray3(x.getPosition(), out);
    double pdf = getScatteringPDF(x, v, out, true, lambda);
    Color value = bsdf(x, v, out, lambda).divide(pdf);

    return ScatteredRay.diffuse(ray, value, pdf);

  }
View Full Code Here

      Vector3 v = RandomUtil.diffuse(ru, rv).toCartesian(Basis3.fromW(ns));
      while (ng.dot(v) < 0.0) {
        v = RandomUtil.diffuse(Random.DEFAULT).toCartesian(Basis3.fromW(ns));
      }
      Ray3 ray = new Ray3(o, v);
      Color color = getWhite();
      return ScatteredRay.diffuse(ray, color, 1.0 / Math.PI);
    }
View Full Code Here

      Point2 p = pointOnImagePlane;
      SphericalCoordinates v = new SphericalCoordinates(
          Math.acos(1.0 - 2.0 * p.y()),
          2.0 * Math.PI * p.x());
      Ray3 ray = new Ray3(Point3.ORIGIN, v.toCartesian(BASIS));
      Color color = getWhite();
      double pdf = 1.0 / (4.0 * Math.PI);

      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.color.Color

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.