コード例 #1
0
    Renderer(int line) {
      startLine = line;

      if (!scene.antiAliasing) {
        sampled = false;

        samples = Math.max(scene.raysPerPixel, DEBUG_samples);
        // Force it to be a perfect square
        samples = (int) Math.sqrt(samples);
        samples = samples * samples;

        imageSamples = new Double3D[samples];
        for (int i = 0; i < samples; i++) imageSamples[i] = new Double3D(0, 0, 0);

        // Make samples are in the range [0,1]
        Sample.multiJitter(imageSamples, samples);
        // Make samples are in the range [-2,2]
        Sample.cubicSplineFilter(imageSamples, samples);
        // Scale image samples to [-.5,.5] and adjust to worldCoords this should be +-.5 pixels
        // since we're in the middle of a pixel to begin with
        for (int i = 0; i < samples; i++) {
          imageSamples[i].x = widthRatio / 2 * (imageSamples[i].x / 4.0);
          imageSamples[i].y = heightRatio / 2 * (imageSamples[i].y / 4.0);
          // System.out.println("Jitter by: " + imageSamples[i] + " Pixel width: " + widthRatio + "
          // Pixel height: " + heightRatio );
        }
        imageSamples[0].x++;
        imageSamples[0].x--;
      }
    }
コード例 #2
0
    Renderer() {
      xMin = scene.camera.viewportLeft + 0.5;
      xMax = scene.camera.viewportRight;
      yMin = scene.camera.viewportBottom + 0.5;
      yMax = scene.camera.viewportTop;

      if (scene.antiAliasing) {
        samples = Math.max(scene.raysPerPixel, DEBUG_samples);
        // Force it to be a perfect square
        samples = (int) Math.sqrt(samples);
        samples = samples * samples;

        imageSamples = new Double3D[samples];
        for (int i = 0; i < samples; i++) imageSamples[i] = new Double3D(0, 0, 0);

        Sample.multiJitter(imageSamples, samples);

        // Samples are in the range [-2,2]
        Sample.cubicSplineFilter(imageSamples, samples);

        // Scale image samples to [-1,1]
        for (int i = 0; i < samples; i++) {
          imageSamples[i].x = widthRatio * imageSamples[i].x / 2.0;
          imageSamples[i].y = heightRatio * imageSamples[i].y / 2.0;
        }
      }
    }