Package ca.eandb.jmist.framework.color

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


    double vdotn = -v.dot(x.getNormal());
//    if (vdotn < 0.0) {
//      return null;
//    }

    Color kd = kdPainter.getColor(x, lambda);
    Color ks = ksPainter.getColor(x, lambda);
    double kdY = ColorUtil.getMeanChannelValue(kd);
    double rhod = kdY;

    double ksY = ColorUtil.getMeanChannelValue(ks);
    double rhos = Math.min(1.0, ksY * Math.abs(vdotn) * (n + 2.0) / (n + 1.0));

    if (rj < rhod) {
      Vector3 out = RandomUtil.diffuse(ru, rv).toCartesian(x.getBasis());
      Ray3 ray = new Ray3(x.getPosition(), out);
      return ScatteredRay.diffuse(ray, kd.divide(rhod), getScatteringPDF(x, v, out, adjoint, lambda));
    } else if (rj < rhod + rhos) {
      Vector3 r = Optics.reflect(v, x.getNormal());
      Vector3 out = new SphericalCoordinates(Math.acos(Math.pow(ru, 1.0 / (n + 1.0))), 2.0 * Math.PI * rv).toCartesian(Basis3.fromW(r));
      double ndoto = x.getNormal().dot(out);
      Color weight = ks.times(((n + 2.0) / (n + 1.0)) * Math.abs(ndoto) / rhos);
      //double rdoto = r.dot(out);
      double pdf = getScatteringPDF(x, v, out, adjoint, lambda);//rhod / Math.PI + rhos * (Math.pow(rdoto, n) / ndoto) * (n + 1.0) / (2.0 * Math.PI);
      Ray3 ray = new Ray3(x.getPosition(), out);
      return ScatteredRay.glossy(ray, weight, pdf);
    }
View Full Code Here


    public int numPathSeeds;
  };

  private final Path generatePath(long seed) {
    Random rnd = new RandomAdapter(new java.util.Random(seed));
    Color sample = colorModel.sample(rnd);
    WavelengthPacket lambda = sample.getWavelengthPacket();
    PathNode lightTail = generateLightPath(rnd, lambda);
    PathNode eyeTail = generateEyePath(rnd, lambda);

    if (lightTail != null && lightTail.getDepth() > 0 && lightTail.isAtInfinity()) {
      lightTail = lightTail.getParent();
View Full Code Here

      PathNode lightNode = lightTail;
      while (true) {

        PathNode eyeNode = eyeTail;
        while (true) {
          Color c = pathMeasure.evaluate(lightNode, eyeNode);
          weights.add(colorMeasure.evaluate(c));

          if (eyeNode == null) {
            break;
          }
View Full Code Here

          Math.max(1, mutations / 100));
      int nextCallback = 0;

      Path x = generatePath(seed);
      Path y;
      Color c = null;

      for (int i = 0; i < mutations; i++) {
        if (--nextCallback <= 0) {
          if (!monitor.notifyProgress(i, mutations)) {
            monitor.notifyCancelled();
View Full Code Here

      return Math.min(1.0, (fy * tyx) / (fx * txy));
    }

    private double f(Path x) {
      Color c = x.measure(pathMeasure);
      return colorMeasure.evaluate(c);
    }
View Full Code Here

      Vector3 n = x.getNormal();
      Point3 p = x.getPosition();
      Ray3 ray = new Ray3(p, r);

      Color color = colorModel.getWhite(lambda);

      if (r.dot(n) > 0.0) {
        return ScatteredRay.specular(ray, color, 0.0);
      } else {
        return ScatteredRay.transmitSpecular(ray, color, 0);
View Full Code Here

        if (MathUtil.equal(alpha, 1.0)) {
          return cm.fromRGB(pixel[0]/255.0, pixel[1]/255.0, pixel[2]/255.0).sample(lambda);
        } else if (MathUtil.equal(alpha, 0.0)) {
          return background.evaluate(p, lambda);
        } else {
          Color bg = background.evaluate(p, lambda);
          Color fg = cm.fromRGB(pixel[0]/255.0, pixel[1]/255.0, pixel[2]/255.0).sample(lambda);
          return fg.times(alpha).plus(bg.times(1.0 - alpha));
        }
      }
      default:
        throw new RuntimeException("Raster has unrecognized number of bands.");
      }
View Full Code Here

  @Override
  public Vector3 scatter(final SurfacePointGeometry x, Vector3 v, boolean adjoint,
      double wavelength, Random rnd) {

    ColorModel cm = new MonochromeColorModel(wavelength);
    Color white = cm.sample(rnd);
    SurfacePoint surf = new SurfacePoint() {
      public Medium getAmbientMedium() {
        return ambientMedium;
      }
      public Material getMaterial() {
        return material;
      }
      public Basis3 getBasis() {
        return x.getBasis();
      }
      public Vector3 getNormal() {
        return x.getNormal();
      }
      public Point3 getPosition() {
        return x.getPosition();
      }
      public int getPrimitiveIndex() {
        return x.getPrimitiveIndex();
      }
      public Basis3 getShadingBasis() {
        return x.getShadingBasis();
      }
      public Vector3 getShadingNormal() {
        return x.getShadingNormal();
      }
      public Vector3 getTangent() {
        return x.getTangent();
      }
      public Point2 getUV() {
        return x.getUV();
      }
    };
    ScatteredRay sr = material.scatter(surf, v, adjoint, white.getWavelengthPacket(), rnd.next(), rnd.next(), rnd.next());
    return sr != null ? sr.getRay().direction() : null;

  }
View Full Code Here

          Math.sin(theta),
          (0.5 - p.y()) * height,
          -Math.cos(theta));
      double r = v.length();
      Ray3 ray = new Ray3(Point3.ORIGIN, v.divide(r));
      Color color = getWhite();
      double pdf = (r * r * r * r) / (hfov * height);
      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here

    int w = pixels.getWidth();
    int h = pixels.getHeight();
    for (int ry = 0; ry < h; ry++, y++) {
      int index = (y * width + x) * 3;
      for (int rx = 0; rx < w; rx++) {
        Color pixel = pixels.getPixel(rx, ry);
        CIEXYZ c = pixel.toXYZ();
        array[index++] = c.X();
        array[index++] = c.Y();
        array[index++] = c.Z();
      }
    }
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.