Package ca.eandb.jmist.framework.shader

Examples of ca.eandb.jmist.framework.shader.MinimalShadingContext


    Ray3 ray = sr.getRay();
    SceneElement root = scene.getRoot();
    Intersection x = NearestIntersectionRecorder
        .computeNearestIntersection(ray, root);
    if (x != null) {
      ShadingContext context = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(context);
      context.getModifier().modify(context);
      return new SurfaceNode(this, sr, context, ru, rv, rj);
    } else {
      return new BackgroundNode(this, sr, ru, rv, rj);
    }
  }
View Full Code Here


      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
View Full Code Here

      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
View Full Code Here

      private static final long serialVersionUID = -4977755592893506132L;

      public void illuminate(SurfacePoint x, WavelengthPacket lambda,
          Random rng, Illuminable target) {
        ShadingContext context = new MinimalShadingContext(rng);

        int index = rnd.next(rng);
        int primitive = primIndex[index];

        generateImportanceSampledSurfacePoint(primitive, x, context, rng.next(), rng.next(), rng.next());
        context.getModifier().modify(context);

        Point3 p = context.getPosition();
        Material mat = context.getMaterial();
        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);
      }

      public LightNode sample(PathInfo pathInfo, double ru, double rv, double rj) {
        ShadingContext context = new MinimalShadingContext(null);

        SeedReference ref = new SeedReference(rj);
        int index = rnd.next(ref);
        int primitive = primIndex[index];

        generateRandomSurfacePoint(primitive, context, ru, rv, ref.seed);
        context.getModifier().modify(context);

        return ScaledLightNode.create(1.0 / totalWeight,
            new SurfaceLightNode(pathInfo, context, ru, rv, ref.seed), rj);
      }

View Full Code Here

  private Strand createStrand(int index) {
    Random tempRnd = new Random(index);
    Random rnd = new Random(tempRnd.nextLong());
    RandomAdapter adapter = new RandomAdapter(rnd);
    MinimalShadingContext context = new MinimalShadingContext(adapter);
    emitter.generateRandomSurfacePoint(context, rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble());
    Strand strand = new Strand();
    strand.vertices = new Point3[2 * (segments + 1)];
    strand.emitterContext = context;
    strand.strandIndex = index;

    Point3 pos = context.getPosition();
    Vector3 vel = context.getBasis().toStandard(meanInitialVelocity).plus(
        RandomUtil.uniformInsideSphere(randomInitialVelocity, adapter)
            .toCartesian());
    double dt = 1.0 / (double) segments;
    double orientation = 2.0 * Math.PI * rnd.nextDouble();
    double co = Math.cos(orientation);
    double so = Math.sin(orientation);
    Basis3 basis = Basis3.fromWU(vel, context.getTangent());

    int segment = 0;
    int i = 0;
    while (true) {
      double t = (double) segment / (double) segments;
View Full Code Here

      private static final long serialVersionUID = -2578460152471816304L;

      public void illuminate(SurfacePoint x, WavelengthPacket lambda, Random rng, Illuminable target) {

        ShadingContext context = new MinimalShadingContext(rng);
        generateImportanceSampledSurfacePoint(x, context, rng.next(), rng.next(), rng.next());
        context.getModifier().modify(context);

        Point3 p = context.getPosition();
        Material mat = material;//context.getMaterial();
        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) * surfaceArea / (4.0 * Math.PI * d2);
        Color ri = mat.emission(context, v, lambda).times(atten);

        LightSample sample = new PointLightSample(x, p, ri);

        target.addLightSample(sample);

      }

      public LightNode sample(PathInfo pathInfo, double ru, double rv, double rj) {
        ShadingContext context = new MinimalShadingContext(null);
        generateRandomSurfacePoint(context, ru, rv, rj);
        context.getModifier().modify(context);

        return ScaledLightNode.create(1.0 / surfaceArea,
            new SurfaceLightNode(pathInfo, context, ru, rv, rj), rj);
      }

View Full Code Here

    return new AbstractLight() {

      private static final long serialVersionUID = -8364217558705142738L;

      public void illuminate(SurfacePoint x, WavelengthPacket lambda, Random rng, Illuminable target) {
        ShadingContext context = new MinimalShadingContext(rng);

        int index = rnd.next(rng);
        int primitive = primIndex[index];

        generateImportanceSampledSurfacePoint(primitive, x, context, rng.next(), rng.next(), rng.next());
        context.getModifier().modify(context);

        Point3 p = context.getPosition();
        Material mat = context.getMaterial();
        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);
      }

      public LightNode sample(PathInfo pathInfo, double ru, double rv, double rj) {
        ShadingContext context = new MinimalShadingContext(null);

        SeedReference ref = new SeedReference(rj);
        int index = rnd.next(ref);
        int primitive = primIndex[index];

        generateRandomSurfacePoint(primitive, context, ru, rv, ref.seed);
        context.getModifier().modify(context);

        return ScaledLightNode.create(1.0 / totalWeight,
            new SurfaceLightNode(pathInfo, context, ru, rv, ref.seed), rj);
      }

View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.shader.MinimalShadingContext

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.