Package ca.eandb.jmist.framework.color

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


    int w = pixels.getWidth();
    int h = pixels.getHeight();
    for (int ry = 0; ry < h; ry++, y++) {
      int index = (y * width + x) * channels;
      for (int rx = 0; rx < w; rx++) {
        Color pixel = pixels.getPixel(rx, ry);
        for (int ch = 0; ch < channels; ch++) {
          array[index++] = pixel.getValue(ch);
        }
      }
    }
  }
View Full Code Here


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

      Color col = absorptionCoefficient.sample(lambda);
//      double abs = ColorUtil.getMeanChannelValue(col);
//
//      if (abs > MathUtil.EPSILON) {
//        double p = -Math.log(1.0 - rnd.next()) * Math.cos(Math.abs(x.getNormal().dot(v))) / abs;
//
//        col = col.times(-thickness).exp();
//        col = col.divide(ColorUtil.getMeanChannelValue(col));
//
//        if (p > thickness) {
//          return ScatteredRay.transmitSpecular(new Ray3(x.getPosition(), v), col, 1.0);
//        }
//      }
//
//      return null;

      col = col.times(-thickness.get() / Math.cos(Math.abs(x.getNormal().dot(v)))).exp();
      return ScatteredRay.transmitSpecular(new Ray3(x.getPosition(), v), col, 1.0);

    }
View Full Code Here

    int h = pixels.getHeight();
    if (rawPixelType != null) {
      int n = colorModel.getNumChannels();
      for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
          Color color = pixels.getPixel(x, y);
          for (int i = 0; i < n; i++) {
            String name = colorModel.getChannelName(i);
            float value = (float) color.getValue(i);
            image.setFloat(x0 + x, y0 + y, name, value);
          }
        }
      }
    }
View Full Code Here

   * Shades the specified pixel using this shader's image shader.
   * @param p The point on the image plane to shade.
   * @return The shaded pixel.
   */
  protected Color shadeAt(Point2 p) {
    Color        sample = model.sample(Random.DEFAULT);
    WavelengthPacket  lambda = sample.getWavelengthPacket();

    Color        shade = shader.shadeAt(p, lambda);
    return shade.times(sample);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.PixelShader#shadePixel(ca.eandb.jmist.math.Box2)
   */
  public Color shadePixel(Box2 bounds) {
    double x0, x1, y0, y1;
    Color pixel = null;
    Color sample;
    Box2 subpixel;

    for (int i = 0; i < this.rows; i++) {
      x0 = bounds.interpolateX((double) i / (double) this.rows);
      x1 = bounds.interpolateX((double) (i + 1) / (double) this.rows);
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.PixelShader#shadePixel(ca.eandb.jmist.math.Box2)
   */
  public Color shadePixel(Box2 bounds) {
    Color pixel = pixelShader.shadePixel(bounds);
    Color s = null;
    int i;
    int j = 1;

    for (i = 1; i < this.maxSamples; i++) {
      if (i >= minSamples) {
        if (--j <= 0) {
          j = checkInterval;
          if (ColorUtil.getMaxChannelValue(s) < varianceTarget * (double) ((i - 1) * i)) {
            break;
          }
        }
      }

      Color sample = pixelShader.shadePixel(bounds);
      Color oldPixel = pixel;
      pixel = ColorUtil.add(pixel, ColorUtil.div(ColorUtil.sub(sample, pixel), i + 1));
      s = ColorUtil.add(s, ColorUtil.mul(ColorUtil.sub(sample, oldPixel), ColorUtil.sub(sample, pixel)));
    }

    if (testMode) {
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.PixelShader#shadePixel(ca.eandb.jmist.math.Box2)
   */
  public Color shadePixel(Box2 bounds) {
    Color pixel = null;

    for (int i = 0; i < this.numSamples; i++) {
      pixel = ColorUtil.add(pixel, pixelShader.shadePixel(bounds));
    }

    return pixel.divide(numSamples);
  }
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.