Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Ray3


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.LightSample#castShadowRay(ca.eandb.jmist.framework.VisibilityFunction3)
   */
  public boolean castShadowRay(VisibilityFunction3 vf) {
    return shadows && !vf.visibility(new Ray3(x.getPosition(), position));
  }
View Full Code Here


      }
    }

    public Color castRay(ScatteredRay sr) {
      ScatteredRay.Type type = sr.getType();
      Ray3 ray = sr.getRay();
      Intersection x = NearestIntersectionRecorder.computeNearestIntersection(ray, root);

      if (x != null) {
        totalDepth++;
        depth.put(type, getPathDepthByType(type) + 1);
View Full Code Here

      return true;
    }

    public ScatteredRay sample(double ru, double rv, double rj) {
      Vector3 v = RandomUtil.uniformOnSphere(ru, rv).toCartesian();
      Ray3 ray = new Ray3(position, v);
      return ScatteredRay.diffuse(ray, sample(emittedPower),
          1.0 / (4.0 * Math.PI));
    }
View Full Code Here

    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

        ScatteredRay sr = strategy.emit(x, lambda, ru, rv, ref.seed);
        if (sr != null) {
          if (sr.getType() == Type.SPECULAR) {
            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());
          }
        }
View Full Code Here

      ScatteredRay sr = strategy.scatter(x, v, adjoint, lambda, ru, rv, ref.seed);
      if (sr != null) {
        if (sr.getType() == Type.SPECULAR) {
          return ScatteredRay.select(sr, 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 * 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

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

    Vector3 out = Optics.reflect(v, x.getShadingNormal());

    return ScatteredRay.specular(new Ray3(x.getPosition(), out),
        reflectance.getColor(x, lambda), 1.0);

  }
View Full Code Here

      Vector3 v = new Vector3(
          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

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    public Point2 project(HPoint3 x) {
      Ray3 ray = new Ray3(Point3.ORIGIN, x);
      Vector3 v = ray.direction();
      double theta = Math.atan2(v.x(), -v.z());
      if (Math.abs(theta) > 0.5 * hfov) {
        return null;
      }
      double h = v.y() / Math.hypot(v.x(), v.z());
View Full Code Here

      double  d2 = nx * nx + ny * ny;

      if (d2 > 1.0)
        return null;

      Ray3 ray = new Ray3(
          Point3.ORIGIN,
          new Vector3(nx, ny,  -Math.sqrt(1.0 - d2)));
      Color color = getWhite();
      double pdf = 0.25;

View Full Code Here

TOP

Related Classes of ca.eandb.jmist.math.Ray3

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.