Package ca.eandb.jmist.framework.random

Examples of ca.eandb.jmist.framework.random.CategoricalRandom


      totalSurfaceArea += weight[i];
    }

    final double scale = totalSurfaceArea / emissive.size();
    final double totalWeight = totalSurfaceArea;
    final CategoricalRandom rnd = new CategoricalRandom(weight);

    return new AbstractLight() {

      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);

View Full Code Here


          }
        };
        mutationType = new ThreadLocal<CategoricalRandom>() {
          final double[] weights = new double[]{ 40, 0, 60 };
          public CategoricalRandom initialValue() {
            return new CategoricalRandom(weights);
          }
        };
      }
    }
View Full Code Here

    }

    final double scale = totalSurfaceArea / emissive.size();
    final double totalWeight = totalSurfaceArea;

    final CategoricalRandom rnd = new CategoricalRandom(weight);

    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);

View Full Code Here

        weight[i] = GeometryUtil.areaOfTriangle(
            vertices.get(indices[0]),
            vertices.get(indices[i + 1]),
            vertices.get(indices[i + 2]));
      }
      rnd = new CategoricalRandom(weight);
    }
View Full Code Here

    double[] weight = new double[children.size()];
    for (int i = 0; i < weight.length; i++) {
      weight[i] = children.get(i).getSurfaceArea();
    }
    rnd = new CategoricalRandom(weight);
  }
View Full Code Here

    return new IntPair(s, t);

  }

  private double getSliceProbability(Path x, IntPair slice) {
    CategoricalRandom r = generateDeletedSubpathProbabilities(x);
    int index = getSliceIndex(x, slice);
    return r.getProbability(index);
  }
View Full Code Here

   * @see ca.eandb.jmist.framework.job.mlt.PathMutator#mutate(ca.eandb.jmist.framework.path.Path, ca.eandb.jmist.framework.Random)
   */
  public Path mutate(Path x, Random rnd) {

    int k = x.getLength();
    CategoricalRandom r = generateDeletedSubpathProbabilities(x);
    IntPair slice = getSlice(x, r.next(rnd));

    //slice = new IntPair(0, 0);

    PathNode newLightTail = x.getLightTail();
    PathNode newEyeTail = x.getEyeTail();
View Full Code Here

        }

        pd[i] = pd1 * pd2;
      }
    }
    return new CategoricalRandom(pd);
  }
View Full Code Here

  private void ensureReady() {
    if (random == null) {
      synchronized (this) {
        if (random == null) {
          random = new CategoricalRandom(weights);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.random.CategoricalRandom

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.