Beispiel #1
0
        public SpecularRefraction()
        {
            // ior = new ConstWavelengthDependentValue(1.5f);
            ior = ColorFactory.CreateRegular(SPD_Data.FromFile(@"F:\3D\spds\IndexOfRefraction\dense_flint_glass.txt").Select(i => (float)i).ToArray());
            //ior = ColorFactory.CreateRegular(SPD_Data.FromFile(@"F:\3D\spds\IndexOfRefraction\light_crown_glass.txt", SampledSpectrum.sampledLambdaStart).Select(i => (float)i).ToArray());



        }
Beispiel #2
0
 public SPD16(IWavelengthDependentValue spd, float lmin, float lmax)
 {
     delta = (lmax - lmin)/16;
     lambdaMin = lmin;
     lambdaMax = lmax;
     float l = lmin;
     for (int i = 0; i < 16; i++)
     {
         this[i] = spd.Sample(l);
         l += delta;
     }
 }
Beispiel #3
0
        protected BaseMaterial(MaterialInfo mi, RayEngineScene scene)
        {
            this.mi = mi;

            this.Exponent = mi.Exponent;
            this.IndexOfRefraction = (ConstWavelengthDependentValue)mi.MediumInfo.IoR;

            if (mi.DiffuseTexture != null)
            {
                Diffuse =
                    TextureFactory.Instance.CreateImageTexture(
                        (RgbSpectrumTexture)scene.Query(mi.MaterialName, TextureType.Diffuse));
            }
            else
            {
                Diffuse = TextureFactory.Instance.CreateConstTexture(ref mi.Kd);
            }

            if (mi.Specular != null)
            {
                Specular =
                    TextureFactory.Instance.CreateImageTexture(
                        (RgbSpectrumTexture)scene.Query(mi.MaterialName, TextureType.Specular));
            }
            else
            {
                Specular = TextureFactory.Instance.CreateConstTexture(ref mi.Kr);
            }

            if (mi.AlphaTexture != null)
            {
                Alpha =
                    TextureFactory.Instance.CreateImageTexture(
                        (RgbSpectrumTexture)scene.Query(mi.MaterialName, TextureType.Alpha));            
            }

            var zeroSpectrum = RgbSpectrum.ZeroSpectrum();
            var zeroTex = TextureFactory.Instance.CreateConstTexture(ref zeroSpectrum);

            if (mi.BumpTexture != null && scene.OptTextures.Contains(mi.BumpTexture))
            {
                Bump =
                    TextureFactory.Instance.CreateImageTexture(
                        (RgbSpectrumTexture)scene.Query(mi.MaterialName, TextureType.Bump));
            }
            //else
            //{
            //    Bump = zeroTex;
            //}

            if (!mi.GlossReflectance.IsBlack())
            {
                Glossy = TextureFactory.Instance.CreateConstTexture(ref mi.Ks);
            }
            //else
            //{
            //    Glossy = zeroTex;
            //}

            if (!mi.Kt.IsBlack())
            {
                Transmission = TextureFactory.Instance.CreateConstTexture(ref mi.Kt);
            }
            //else
            //{
            //    Transmission = zeroTex;
            //}

            if (!mi.Reflectance.IsBlack())
            {
                Reflectance = TextureFactory.Instance.CreateConstTexture(ref mi.Reflectance);
            }
            //else
            //{
            //    Reflectance = zeroTex;
            //}
        }