Package ca.eandb.jmist.framework

Examples of ca.eandb.jmist.framework.ShadingContext


    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


      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 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.ShadingContext

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.