Ejemplo n.º 1
0
 public InfiniteLight(RgbSpectrumTexture tx)
 {
     tex = tx;
     shiftU = 0f;
     shiftV = 0f;
     gain = new RgbSpectrum(1.0f);
 }
        public ImportanceSampledInfiniteLight(RgbSpectrumTexture tx, RgbSpectrumTexture tx_l)
        {
            Sampler = new LatLongMap(tx, tx_l);

            shiftU = 0f;
            shiftV = 0f;
            gain = GlobalConfiguration.Instance.SpectralRendering ? RgbSpectrum.UnitSpectrum() : new RgbSpectrum(0.1f);
        }
Ejemplo n.º 3
0
 public CubeMap(string up, string down, string left, string right, string fwd, string back)
 {
     Top = LoadTexture(up);
     Left = LoadTexture(left);
     Right = LoadTexture(right);
     Bottom = LoadTexture(down);
     Forward = LoadTexture(fwd);
     Backward = LoadTexture(back);
 }
Ejemplo n.º 4
0
        public static RgbSpectrumTexture FreeImageLoadExrBitmap(string fileName)
        {

            Console.WriteLine("..Loading hdr bitmap {0}", fileName);
            using (var bmp = new FreeImageBitmap(fileName))
            {
                //bmp.AdjustGamma(2.2);
                var pdata = new RgbSpectrumInfo[bmp.Width * bmp.Height];
                for (int i = 0; i < bmp.Height; i++)
                {
                    Scanline<FIRGBF> s = bmp.GetScanline<FIRGBF>(i);
                    for (int j = 0; j < bmp.Width; j++)
                    {
                        pdata[j + i * bmp.Width] = new RgbSpectrumInfo(s[j].red, s[j].green, s[j].blue);
                        //pdata[j + i * bmp.Width] .DeGamma();
                    }
                }
                Console.WriteLine("... Converted size {0:F5} MBytes", (bmp.Width * bmp.Height * 12.0f) / (1024f * 1024f));
                MemoryOccupied += (ulong)(bmp.Width * bmp.Height * 12u);
                var tex = new RgbSpectrumTexture(fileName, pdata, bmp.Width, bmp.Height);
                return tex;
            }
        }
Ejemplo n.º 5
0
        public static RgbSpectrumTexture FreeImageLoadBitmap(string fileName)
        {
            Console.WriteLine("..Loading ldr bitmap {0}", fileName);
            using (var bmp = new FreeImageBitmap(fileName))
            {
                //bmp.AdjustGamma(2.2);

                var pdata = new RgbSpectrumInfo[bmp.Width * bmp.Height];
                for (int i = 0; i < bmp.Height; i++)
                {

                    if (bmp.ColorDepth == 24)
                    {
                        Scanline<RGBTRIPLE> s = bmp.GetScanline<RGBTRIPLE>(i);
                        for (int j = 0; j < bmp.Width; j++)
                        {
                            pdata[j + i * bmp.Width] =
                                RgbSpectrumInfo.Create(s[j].rgbtRed, s[j].rgbtGreen, s[j].rgbtBlue, false).Abs();
                        }
                    }

                    if (bmp.ColorDepth == 32)
                    {
                        Scanline<RGBQUAD> s = bmp.GetScanline<RGBQUAD>(i);
                        for (int j = 0; j < bmp.Width; j++)
                        {
                            pdata[j + i * bmp.Width] =
                                RgbSpectrumInfo.Create(s[j].rgbRed, s[j].rgbGreen, s[j].rgbBlue, false).Abs();
                        }
                    }

                    if (bmp.ColorDepth == 8)
                    {

                        Scanline<byte> s = bmp.GetScanline<byte>(i);
                        for (int j = 0; j < bmp.Width; j++)
                        {
                            pdata[j + i * bmp.Width] =
                                RgbSpectrumInfo.Create(bmp.Palette[s[j]].rgbRed, bmp.Palette[s[j]].rgbGreen, bmp.Palette[s[j]].rgbBlue, false).Abs();
                        }
                    }

                }
                Console.WriteLine("... Converted size {0:F5} MBytes", (bmp.Width * bmp.Height * 12.0f) / (1024f * 1024f));
                MemoryOccupied += (ulong)(bmp.Width * bmp.Height * 12u);

                var tex = new RgbSpectrumTexture(fileName, pdata, bmp.Width, bmp.Height);
                return tex;
            }
        }
Ejemplo n.º 6
0
 public BasicInfiniteLight(RgbSpectrumTexture tx, RgbSpectrumTexture tx_l, LightMaterial mt) : base(mt)
 {
     Sampler = new LatLongMap(tx, tx_l);
 }
Ejemplo n.º 7
0
 private void Sample(RgbSpectrumTexture t, ref Vector dir, out RgbSpectrumInfo outputColor)
 {
     float shiftU = 0f, shiftV = 0f;
     float theta = Vector.SphericalTheta(ref dir);
     outputColor = t.Sample(Vector.SphericalPhi(ref dir) * MathLab.INVTWOPI + shiftU, theta * MathLab.INVPI + shiftV);
 }
Ejemplo n.º 8
0
 public LatLongMap(RgbSpectrumTexture tex, RgbSpectrumTexture ltex)
 {
     this.tex = tex;
     this.lightMap = ltex;
 }
Ejemplo n.º 9
0
 public LatLongMap(RgbSpectrumTexture tex)
 {
     this.tex = tex;
 }
Ejemplo n.º 10
0
 public LatLongMap(string path)
 {
     tex = LoadTexture(path);
 }