Package ca.eandb.jmist.framework.color

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


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Shader#shade(ca.eandb.jmist.framework.ShadingContext)
   */
  public Color shade(ShadingContext sc) {
    Color result = sc.getColorModel().getBlack(sc.getWavelengthPacket());
    for (Shader shader : shaders) {
      Color color = shader.shade(sc);
      result = result.plus(color);
    }
    return result;
  }
View Full Code Here


   */
  public Color shade(ShadingContext sc) {
    Material mat = sc.getMaterial();
    WavelengthPacket lambda = sc.getWavelengthPacket();
    Vector3 normal = sc.getShadingNormal();
    Color sum = sc.getColorModel().getBlack(lambda);
    for (LightSample sample : sc.getLightSamples()) {
      if (!sample.castShadowRay(sc)) {
        Vector3 in = sample.getDirToLight().opposite();
        Vector3 out = sc.getIncident().opposite();
        Color bsdf = mat.bsdf(sc, in, out, lambda);
        double dot = Math.abs(in.dot(normal));
        sum = sum.plus(sample.getRadiantIntensity().times(bsdf.times(dot)));
      }
    }
    return sum;
  }
View Full Code Here

   */
  public Color shadeAt(Point2 p, WavelengthPacket lambda) {
    ScatteredRay sr = lens.rayAt(p, lambda, Random.DEFAULT);
    if (sr != null) {
      Ray3 ray = sr.getRay();
      Color scale = sr.getColor();
      Color shade = rayShader.shadeRay(ray, lambda);
      return shade.times(scale);
    } else {
      return ColorUtil.getBlack(lambda);
    }
  }
View Full Code Here

    WavelengthPacket lambda = sc.getWavelengthPacket();
    double d = sc.getDistance();
    if (distanceInterval.contains(d)) {
      double t = (d - distanceInterval.minimum()) / distanceInterval.length();
      Color ncol = getColorWhiteDefault(minDistanceValue, lambda);
      Color fcol = getColorBlackDefault(maxDistanceValue, lambda);
      return ncol.times(1.0 - t).plus(fcol.times(t));
    } else if (d < distanceInterval.minimum()) {
      return getColorWhiteDefault(nearValue, lambda);
    } else {
      return getColorBlackDefault(farValue, lambda);
    }
View Full Code Here

        local.importance = lambda.getColorModel().getWhite(lambda);

        stack.push(local);
        x.prepareShadingContext(this);

        Color color = shade();

        stack.pop();
        return color;
      } else {
        return background.shadeRay(ray, lambda);
View Full Code Here

        local.importance = sr.getColor().times(stack.peek().importance);

        stack.push(local);
        x.prepareShadingContext(this);

        Color color = shade();
        color = color.times(medium.transmittance(local.ray,
            local.distance, color.getWavelengthPacket()));

        if (popped != null) {
          media.push(popped);
        }
View Full Code Here

    Vector3  source = RandomUtil.uniformOnUpperHemisphere(rng).toCartesian(Basis3.fromW(zenith));

    if (source.dot(x.getNormal()) > 0.0) {
      double sdotn = source.dot(x.getShadingNormal());
      Color radiance = lambda.getColorModel().getContinuous(new SkyRadianceSpectrum(source)).sample(lambda);
      target.addLightSample(new DirectionalLightSample(x, source, radiance.times(sdotn), shadows));
    }

    if (daytime && sun.dot(x.getNormal()) > 0.0) {
      double sdotn = sun.dot(x.getShadingNormal());
      target.addLightSample(new DirectionalLightSample(x, sun, solarRadiance.sample(lambda).times(sdotn), shadows));
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      = refractiveIndex.sample(lambda);
    Vector3    normal    = x.getShadingNormal();
    boolean    fromSide  = x.getNormal().dot(v) < 0.0;
    Color    R      = MaterialUtil.reflectance(v, n1, k1, n2, null, 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 (false && 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));
//        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);
      Complex    eta1  = new Complex(n1avg, k1avg);
      Complex    eta2  = new Complex(n2avg);
      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);
      }
    }
    }

    return null;
View Full Code Here

            return ScatteredRay.select(sr, w);
          } else {
            Ray3 ray = sr.getRay();
            Vector3 v = ray.direction();
            double pdf = w * sr.getPDF() + (1.0 - w) * inner.getEmissionPDF(x, v, lambda);
            Color edf = inner.emission(x, sr.getRay().direction(), lambda);
            return new ScatteredRay(ray, edf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
          }
        }
      } else {
        ScatteredRay sr = inner.emit(x, lambda, ru, rv, ref.seed);
        if (sr != null) {
          if (sr.getType() == Type.SPECULAR) {
            return ScatteredRay.select(sr, 1.0 - w);
          } else {
            Ray3 ray = sr.getRay();
            Vector3 v = ray.direction();
            double pdf = w * strategy.getEmissionPDF(x, v, lambda) + (1.0 - w) * sr.getPDF();
            Color edf = inner.emission(x, sr.getRay().direction(), lambda);
            return new ScatteredRay(ray, edf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
          }
        }
      }
    }
    return null;
View Full Code Here

          Ray3 ray = sr.getRay();
          Vector3 r = ray.direction();
          Vector3 in = adjoint ? r.opposite() : v;
          Vector3 out = adjoint ? v.opposite() : r;
          double pdf = w * sr.getPDF() + (1.0 - w) * inner.getScatteringPDF(x, v, r, adjoint, lambda);
          Color bsdf = inner.bsdf(x, in, out, lambda);
          return new ScatteredRay(ray, bsdf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
        }
      }
    } else {
      ScatteredRay sr = inner.scatter(x, v, adjoint, lambda, ru, rv, ref.seed);
      if (sr != null) {
        if (sr.getType() == Type.SPECULAR) {
          return ScatteredRay.select(sr, 1.0 - w);
        } else {
          Ray3 ray = sr.getRay();
          Vector3 r = ray.direction();
          Vector3 in = adjoint ? r.opposite() : v;
          Vector3 out = adjoint ? v.opposite() : r;
          double pdf = w * strategy.getScatteringPDF(x, v, r, adjoint, lambda) + (1.0 - w) * sr.getPDF();
          Color bsdf = inner.bsdf(x, in, out, lambda);
          return new ScatteredRay(ray, bsdf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
        }
      }
    }


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.