Beispiel #1
0
        /// <summary>
        /// Renders the single pixel of an image (using required super-sampling).
        /// </summary>
        /// <param name="x">Horizontal coordinate.</param>
        /// <param name="y">Vertical coordinate.</param>
        /// <param name="color">Computed pixel color.</param>
        public override void RenderPixel(int x, int y, double[] color)
        {
            Debug.Assert(color != null);
            Debug.Assert(MT.rnd != null);

            // !!!{{ TODO: this is exactly the code inherited from static sampling - make it adaptive!

            int bands = color.Length;
            int b;

            Array.Clear(color, 0, bands);
            double[] tmp = new double[bands];

            int    i, j;
            double step = 1.0 / superXY;
            double amplitude = Jittering * step;
            double origin = 0.5 * (step - amplitude);
            double x0, y0;

            MT.StartPixel(x, y, Supersampling);

            for (j = 0, y0 = y + origin; j++ < superXY; y0 += step)
            {
                for (i = 0, x0 = x + origin; i++ < superXY; x0 += step)
                {
                    ImageFunction.GetSample(x0 + amplitude * MT.rnd.UniformNumber(),
                                            y0 + amplitude * MT.rnd.UniformNumber(),
                                            tmp);
                    MT.NextSample();
                    for (b = 0; b < bands; b++)
                    {
                        color[b] += tmp[b];
                    }
                }
            }

            double mul = step / superXY;

            if (Gamma > 0.001)
            {
                // gamma-encoding and clamping
                double g = 1.0 / Gamma;
                for (b = 0; b < bands; b++)
                {
                    color[b] = Arith.Clamp(Math.Pow(color[b] * mul, g), 0.0, 1.0);
                }
            }
            else
            {
                // no gamma, no clamping (for HDRI)
                for (b = 0; b < bands; b++)
                {
                    color[b] *= mul;
                }
            }

            // !!!}}
        }
Beispiel #2
0
        /// <summary>
        /// Renders the single pixel of an image.
        /// </summary>
        /// <param name="x">Horizontal coordinate.</param>
        /// <param name="y">Vertical coordinate.</param>
        /// <param name="color">Computed pixel color.</param>
        /// <param name="rnd">Shared random generator.</param>
        public override void RenderPixel(int x, int y, double[] color, RandomJames rnd)
        {
            Debug.Assert(color != null);
            Debug.Assert(rnd != null);

            int bands = color.Length;
            int b;

            Array.Clear(color, 0, bands);
            double[] tmp = new double[bands];

            int    i, j, ord;
            double step = 1.0 / superXY;
            double amplitude = Jittering * step;
            double origin = 0.5 * (step - amplitude);
            double x0, y0;

            for (j = ord = 0, y0 = y + origin; j++ < superXY; y0 += step)
            {
                for (i = 0, x0 = x + origin; i++ < superXY; x0 += step)
                {
                    ImageFunction.GetSample(x0 + amplitude * rnd.UniformNumber(),
                                            y0 + amplitude * rnd.UniformNumber(),
                                            ord++, Supersampling, rnd, tmp);
                    for (b = 0; b < bands; b++)
                    {
                        color[b] += tmp[b];
                    }
                }
            }

            double mul = step / superXY;

            if (Gamma > 0.001)
            {                               // gamma-encoding and clamping
                double g = 1.0 / Gamma;
                for (b = 0; b < bands; b++)
                {
                    color[b] = Arith.Clamp(Math.Pow(color[b] * mul, g), 0.0, 1.0);
                }
            }
            else                            // no gamma, no clamping (for HDRI)
            {
                for (b = 0; b < bands; b++)
                {
                    color[b] *= mul;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Renders the single pixel of an image.
        /// </summary>
        /// <param name="x">Horizontal coordinate.</param>
        /// <param name="y">Vertical coordinate.</param>
        /// <param name="color">Computed pixel color.</param>
        /// <param name="rnd">Shared random generator.</param>
        public virtual void RenderPixel(int x, int y, double[] color, RandomJames rnd)
        {
            ImageFunction.GetSample(x + 0.5, y + 0.5, color);

            // gamma-encoding:
            if (Gamma > 0.001)
            {                               // gamma-encoding and clamping
                double g = 1.0 / Gamma;
                for (int b = 0; b < color.Length; b++)
                {
                    color[b] = Arith.Clamp(Math.Pow(color[b], g), 0.0, 1.0);
                }
            }
            // else: no gamma, no clamping (for HDRI)
        }