Exemple #1
0
        private void SetRasterizerState(Material meshMaterial, MatlAttribute a)
        {
            // TODO: There's a cleaner way to do this.
            var rasterizerState = (MatlAttribute.MatlRasterizerState)a.DataObject;

            meshMaterial.DepthBias = rasterizerState.DepthBias;
            meshMaterial.CullMode  = MatlToGl.GetCullMode(rasterizerState.CullMode);
        }
Exemple #2
0
        private void SetSamplerInformation(Material material, MatlAttribute a)
        {
            // TODO: This could be cleaner.
            SamplerObject sampler = null;

            switch ((long)a.ParamId)
            {
            case (long)ParamId.ColSampler:
                sampler = material.colSampler;
                break;

            case (long)ParamId.NorSampler:
                sampler = material.norSampler;
                break;

            case (long)ParamId.PrmSampler:
                sampler = material.prmSampler;
                break;

            case (long)ParamId.EmiSampler:
                sampler = material.emiSampler;
                break;
            }

            if (sampler != null)
            {
                var samplerStruct = (MatlAttribute.MatlSampler)a.DataObject;
                sampler.TextureWrapS = MatlToGl.GetWrapMode(samplerStruct.WrapS);
                sampler.TextureWrapT = MatlToGl.GetWrapMode(samplerStruct.WrapT);
                sampler.TextureWrapR = MatlToGl.GetWrapMode(samplerStruct.WrapR);
                sampler.MagFilter    = MatlToGl.GetMagFilter(samplerStruct.MagFilter);
                sampler.MinFilter    = MatlToGl.GetMinFilter(samplerStruct.MinFilter);

                GL.SamplerParameter(sampler.Id, SamplerParameterName.TextureLodBias, samplerStruct.LodBias);

                if (samplerStruct.Unk6 == 2 && RenderSettings.Instance.EnableExperimental)
                {
                    GL.SamplerParameter(sampler.Id, SamplerParameterName.TextureMaxAnisotropyExt, (float)samplerStruct.MaxAnisotropy);
                }
                else
                {
                    GL.SamplerParameter(sampler.Id, SamplerParameterName.TextureMaxAnisotropyExt, 1.0f);
                }
            }
        }