Package ca.eandb.jmist.framework.color

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


          new Point3(
            (p.x() - 0.5) * width,
            (0.5 - p.y()) * height,
            0.0),
          Vector3.NEGATIVE_K);
      Color color = getWhite();
      return ScatteredRay.specular(ray, color, 1.0);
    }
View Full Code Here


      Vector3    n    = LENS_SPHERE.center().vectorTo(init.pointAt(I.minimum()));
      Vector3    r    = Optics.reflect(init.direction(), n);

      Ray3    ray    = new Ray3(Point3.ORIGIN, r);
      Color    color  = getWhite();
      double    pdf    = 1.0 / 16.0;

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

        Vector3 v = x.getPosition().unitVectorFrom(p);
        Vector3 n = context.getShadingNormal();
        double d2 = x.getPosition().squaredDistanceTo(p);
        double atten = Math.max(n.dot(v), 0.0) * totalWeight
            / (4.0 * Math.PI * d2);
        Color ri = mat.emission(context, v, lambda).times(atten);
        LightSample sample = new PointLightSample(x, p, ri);

        target.addLightSample(sample);
      }

View Full Code Here

     * @see ca.eandb.jmist.framework.path.PathNode#sample(double, double, double)
     */
    @Override
    public ScatteredRay sample(double ru, double rv, double rj) {
      Vector3 v = ray.direction();
      Color color = getWhite();
      double pdf = (focusDistance * focusDistance)
          / (v.z() * v.z() * v.z() * v.z() * objPlaneWidth * objPlaneHeight);
      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here

      Vector3 v = new Vector3(
          width * (p.x() - 0.5),
          height * (0.5 - p.y()),
          -1.0);
      Ray3 ray = new Ray3(Point3.ORIGIN, v.unit());
      Color color = getWhite();
      double z = v.x() * v.x() + v.y() * v.y() + 1.0;
      double pdf = z * z / (width * height);
      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here

     */
    public Object performTask(Object task, ProgressMonitor monitor) {

      Cell  cell        = (Cell) task;
      int    numPixels      = cell.width * cell.height;
      Color  pixel;
      Box2  bounds;
      double  x0, y0, x1, y1;
      double  w          = width;
      double  h          = height;
      Raster  raster        = colorModel.createRaster(cell.width, cell.height);
View Full Code Here

  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint, WavelengthPacket lambda, double ru, double rv, double rj) {

    ColorModel  cm      = lambda.getColorModel();
    Point3    p      = x.getPosition();
    Medium    medium    = x.getAmbientMedium();
    Color    n1      = medium.refractiveIndex(p, lambda);
    Color    k1      = medium.extinctionIndex(p, lambda);
    Color    n2      = n.sample(lambda);
    Color    k2      = k.sample(lambda);
    Vector3    normal    = x.getShadingNormal();
    boolean    fromSide  = x.getNormal().dot(v) < 0.0;
    Color    R      = MaterialUtil.reflectance(v, n1, k1, n2, k2, normal);
    Color    T      = cm.getWhite(lambda).minus(R);
    double    r      = ColorUtil.getMeanChannelValue(R);

    if (RandomUtil.bernoulli(r, rj)) {
      Vector3    out    = Optics.reflect(v, normal);
      boolean    toSide  = x.getNormal().dot(out) >= 0.0;

      if (fromSide == toSide) {
        return ScatteredRay.specular(new Ray3(p, out), R.divide(r), r);
      }
    } else {

      if (alpha != null) {
//        if (disperse) {
//          for (int i = 0, channels = cm.getNumChannels(); i < channels; i++) {
//            Complex    eta1  = new Complex(n1.getValue(i), k1.getValue(i));
//            Complex    eta2  = new Complex(n2.getValue(i), k2.getValue(i));
//            Vector3    out    = Optics.refract(v, eta1, eta2, normal);
//            boolean    toSide  = x.getNormal().dot(out) >= 0.0;
//
//            if (fromSide != toSide) {
//              recorder.add(ScatteredRay.transmitSpecular(new Ray3(p, out), T.disperse(i), 1.0));
//            }
//          }
//        } else { // !disperse
          double    n1avg  = ColorUtil.getMeanChannelValue(n1);
          double    k1avg  = ColorUtil.getMeanChannelValue(k1);
          double    n2avg  = ColorUtil.getMeanChannelValue(n2);
          double    k2avg  = ColorUtil.getMeanChannelValue(k2);
          Complex    eta1  = new Complex(n1avg, k1avg);
          Complex    eta2  = new Complex(n2avg, k2avg);
          Vector3    out    = Optics.refract(v, eta1, eta2, normal);
          boolean    toSide  = x.getNormal().dot(out) >= 0.0;

          if (fromSide != toSide) {
            return ScatteredRay.transmitSpecular(new Ray3(p, out), T.divide(1 - r), 1 - r);
          }
//        }
      }

    }
View Full Code Here

    double[] c = new double[k + 2];

    for (int s = -1, t = k; s <= k; s++, t--) {
      Path y = x.slice(s, t);
      if (y != null) {
        Color color = importance.evaluate(y.getLightTail(), y.getEyeTail());
        c[s + 1] = color != null ? color.luminance() : 0.0; // FIXME use a ColorMeasure
      }
    }

    return c;
  }
View Full Code Here

  public Color shade(ShadingContext sc) {

    WavelengthPacket lambda = sc.getWavelengthPacket();
    ColorModel cm = sc.getColorModel();

    Color kd = diffuse.getColor(sc, lambda);
    Color ks = specular.getColor(sc, lambda);
    Color ka = ambient.getColor(sc, lambda);
    Color n = exponent.getColor(sc, lambda);

    Vector3 N = sc.getShadingNormal();
    Vector3 V = sc.getIncident().opposite();

    Color d = cm.getBlack(lambda);
    Color s = d;
    Color a = sc.getAmbientLight();

    for (LightSample sample : sc.getLightSamples()) {
      Vector3 L = sample.getDirToLight();
      Vector3 H = L.plus(V).unit();
      Color I = sample.getRadiantIntensity();

      d = d.plus(I.times(N.dot(L)));
      s = s.plus(I.times(cm.getGray(N.dot(H), lambda).pow(n)));
    }

    d = d.times(kd);
    s = s.times(ks);
    a = a.times(ka);
View Full Code Here

  public Color shade(ShadingContext sc) {

    if (firstBounceRays > 0 && sc.getPathDepth() < 1) {
      Random sampler = firstBounceSampler.get();
      WavelengthPacket lambda = sc.getWavelengthPacket();
      Color shade = sc.getColorModel().getBlack(lambda);
      for (int i = 0; i < firstBounceRays; i++) {
        ScatteredRay ray = sc.getMaterial().scatter(sc, sc.getIncident(), true, sc.getWavelengthPacket(), sampler.next(), sampler.next(), sampler.next());
        if (ray != null) {
          shade = shade.plus(sc.castRay(ray).times(ray.getColor()));
        }
      }
      return shade.divide(firstBounceRays);
    } else if (sc.getPathDepth() < maxDepth) {
      ScatteredRay ray = sc.getScatteredRay();
      if (ray != null) {
        double prob = ColorUtil.getMeanChannelValue(ray.getColor());
        if (prob < 1.0) {
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.