Esempio n. 1
0
 internal static void InitSamplerState(SamplerId id)
 {
     if (SamplerObjects[id.Index] == null)
     {
         SamplerObjects[id.Index] = new SamplerState(MyRender11.Device, SamplerStates.Data[id.Index]);
     }
 }
Esempio n. 2
0
 internal static void ChangeSamplerState(SamplerId id, SamplerStateDescription description)
 {
     SamplerStates.Data[id.Index] = description;
     if (SamplerObjects[id.Index] != null)
     {
         SamplerObjects[id.Index].Dispose();
     }
     SamplerObjects[id.Index] = new SamplerState(MyRender11.Device, description);
 }
Esempio n. 3
0
        internal static SamplerId CreateSamplerState(SamplerStateDescription description)
        {
            var id = new SamplerId {
                Index = SamplerStates.Allocate()
            };

            MyArrayHelpers.Reserve(ref SamplerObjects, id.Index + 1);

            SamplerStates.Data[id.Index] = description;

            InitSamplerState(id);
            SamplerIndices.Add(id);

            return(id);
        }
        private static void InitilizeSamplerStates()
        {
            SamplerStateDescription description = new SamplerStateDescription();

            description.AddressU   = TextureAddressMode.Clamp;
            description.AddressV   = TextureAddressMode.Clamp;
            description.AddressW   = TextureAddressMode.Clamp;
            description.Filter     = Filter.MinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            m_defaultSamplerState  = MyPipelineStates.CreateSamplerState(description);

            description.AddressU    = TextureAddressMode.Border;
            description.AddressV    = TextureAddressMode.Border;
            description.AddressW    = TextureAddressMode.Border;
            description.Filter      = Filter.MinMagMipLinear;
            description.MaximumLod  = System.Single.MaxValue;
            description.BorderColor = new Color4(0, 0, 0, 0);
            m_alphamaskSamplerState = MyPipelineStates.CreateSamplerState(description);

            description.AddressU   = TextureAddressMode.Clamp;
            description.AddressV   = TextureAddressMode.Clamp;
            description.AddressW   = TextureAddressMode.Clamp;
            description.Filter     = Filter.MinMagMipPoint;
            description.MaximumLod = System.Single.MaxValue;
            m_pointSamplerState    = MyPipelineStates.CreateSamplerState(description);

            description.Filter     = Filter.MinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            m_linearSamplerState   = MyPipelineStates.CreateSamplerState(description);

            description.AddressU           = TextureAddressMode.Clamp;
            description.AddressV           = TextureAddressMode.Clamp;
            description.AddressW           = TextureAddressMode.Clamp;
            description.Filter             = Filter.ComparisonMinMagMipLinear;
            description.MaximumLod         = System.Single.MaxValue;
            description.ComparisonFunction = Comparison.LessEqual;
            m_shadowmapSamplerState        = MyPipelineStates.CreateSamplerState(description);

            m_textureSamplerState        = MyPipelineStates.CreateSamplerState(description);
            m_alphamaskarraySamplerState = MyPipelineStates.CreateSamplerState(description);

            UpdateTextureSampler(m_textureSamplerState, TextureAddressMode.Wrap);
            UpdateTextureSampler(m_alphamaskarraySamplerState, TextureAddressMode.Clamp);
        }
        private static void InitilizeSamplerStates()
        {
            SamplerStateDescription description = new SamplerStateDescription();
            description.AddressU = TextureAddressMode.Clamp;
            description.AddressV = TextureAddressMode.Clamp;
            description.AddressW = TextureAddressMode.Clamp;
            description.Filter = Filter.MinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            m_defaultSamplerState = MyPipelineStates.CreateSamplerState(description);

            description.AddressU = TextureAddressMode.Border;
            description.AddressV = TextureAddressMode.Border;
            description.AddressW = TextureAddressMode.Border;
            description.Filter = Filter.MinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            description.BorderColor = new Color4(0, 0, 0, 0);
            m_alphamaskSamplerState = MyPipelineStates.CreateSamplerState(description);

            description.AddressU = TextureAddressMode.Clamp;
            description.AddressV = TextureAddressMode.Clamp;
            description.AddressW = TextureAddressMode.Clamp;
            description.Filter = Filter.MinMagMipPoint;
            description.MaximumLod = System.Single.MaxValue;
            m_pointSamplerState = MyPipelineStates.CreateSamplerState(description);

            description.Filter = Filter.MinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            m_linearSamplerState = MyPipelineStates.CreateSamplerState(description);

            description.AddressU = TextureAddressMode.Clamp;
            description.AddressV = TextureAddressMode.Clamp;
            description.AddressW = TextureAddressMode.Clamp;
            description.Filter = Filter.ComparisonMinMagMipLinear;
            description.MaximumLod = System.Single.MaxValue;
            description.ComparisonFunction = Comparison.LessEqual;
            m_shadowmapSamplerState = MyPipelineStates.CreateSamplerState(description);

            m_textureSamplerState = MyPipelineStates.CreateSamplerState(description);
            m_alphamaskarraySamplerState = MyPipelineStates.CreateSamplerState(description);

            UpdateTextureSampler(m_textureSamplerState, TextureAddressMode.Wrap);
            UpdateTextureSampler(m_alphamaskarraySamplerState, TextureAddressMode.Clamp);
        }
Esempio n. 6
0
        private static void UpdateTextureSampler(SamplerId samplerState, TextureAddressMode addressMode)
        {
            SamplerStateDescription description = new SamplerStateDescription();

            description.AddressU   = addressMode;
            description.AddressV   = addressMode;
            description.AddressW   = addressMode;
            description.MaximumLod = System.Single.MaxValue;

            if (MyRender11.RenderSettings.AnisotropicFiltering == MyTextureAnisoFiltering.NONE)
            {
                description.Filter = Filter.MinMagMipLinear;
            }
            else
            {
                description.Filter = Filter.Anisotropic;

                switch (MyRender11.RenderSettings.AnisotropicFiltering)
                {
                case MyTextureAnisoFiltering.ANISO_1:
                    description.MaximumAnisotropy = 1;
                    break;

                case MyTextureAnisoFiltering.ANISO_4:
                    description.MaximumAnisotropy = 4;
                    break;

                case MyTextureAnisoFiltering.ANISO_8:
                    description.MaximumAnisotropy = 8;
                    break;

                case MyTextureAnisoFiltering.ANISO_16:
                    description.MaximumAnisotropy = 16;
                    break;

                default:
                    description.MaximumAnisotropy = 1;
                    break;
                }
            }

            MyPipelineStates.ChangeSamplerState(samplerState, description);
        }
        internal static void UpdateTextureSampler(SamplerId samplerState, TextureAddressMode addressMode)
        {
            SamplerStateDescription description = new SamplerStateDescription();
            description.AddressU = addressMode;
            description.AddressV = addressMode;
            description.AddressW = addressMode;
            description.MaximumLod = System.Single.MaxValue;

            if(MyRender11.RenderSettings.AnisotropicFiltering == MyTextureAnisoFiltering.NONE)
            {
                description.Filter = Filter.MinMagMipLinear;
            }
            else
            {
                description.Filter = Filter.Anisotropic;

                switch(MyRender11.RenderSettings.AnisotropicFiltering)
                {
                    case MyTextureAnisoFiltering.ANISO_1:
                        description.MaximumAnisotropy = 1;
                        break;
                    case MyTextureAnisoFiltering.ANISO_4:
                        description.MaximumAnisotropy = 4;
                        break;
                    case MyTextureAnisoFiltering.ANISO_8:
                        description.MaximumAnisotropy = 8;
                        break;
                    case MyTextureAnisoFiltering.ANISO_16:
                        description.MaximumAnisotropy = 16;
                        break;
                    default:
                        description.MaximumAnisotropy = 1;
                        break;
                }
            }

            MyPipelineStates.ChangeSamplerState(samplerState, description);
        }
Esempio n. 8
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                                               new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                                               new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                                               new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("clouds.hlsl", new [] { new ShaderMacro("NUMTHREADS", m_numFogThreads) });

            SamplerStateDescription description = new SamplerStateDescription
            {
                AddressU   = TextureAddressMode.Wrap,
                AddressV   = TextureAddressMode.Wrap,
                AddressW   = TextureAddressMode.Wrap,
                Filter     = Filter.MinMagMipLinear,
                MaximumLod = System.Single.MaxValue
            };

            m_textureSampler = MyPipelineStates.CreateSamplerState(description);
        }
Esempio n. 9
0
 internal static SamplerState GetSampler(SamplerId id)
 {
     return SamplerObjects[id.Index];
 }
Esempio n. 10
0
 internal static void InitSamplerState(SamplerId id)
 {
     SamplerObjects[id.Index] = new SamplerState(MyRender11.Device, SamplerStates.Data[id.Index]);
 }
Esempio n. 11
0
 internal static void ChangeSamplerState(SamplerId id, SamplerStateDescription description)
 {
     SamplerStates.Data[id.Index] = description;
     if(SamplerObjects[id.Index] != null)
     {
         SamplerObjects[id.Index].Dispose();
     }
     SamplerObjects[id.Index] = new SamplerState(MyRender11.Device, description);
 }
Esempio n. 12
0
        internal static SamplerId CreateSamplerState(SamplerStateDescription description)
        {
            var id = new SamplerId { Index = SamplerStates.Allocate() };
            MyArrayHelpers.Reserve(ref SamplerObjects, id.Index + 1);

            SamplerStates.Data[id.Index] = description;

            InitSamplerState(id);
            SamplerIndices.Add(id);

            return id;
        }
Esempio n. 13
0
        internal static void Init()
        {
            m_proxyVs = MyShaders.CreateVs("clouds.hlsl");
            m_cloudPs = MyShaders.CreatePs("clouds.hlsl");
            m_proxyIL = MyShaders.CreateIL(m_proxyVs.BytecodeId, MyVertexLayouts.GetLayout(
                    new MyVertexInputComponent(MyVertexInputComponentType.POSITION_PACKED, 0),
                    new MyVertexInputComponent(MyVertexInputComponentType.NORMAL, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TANGENT_SIGN_OF_BITANGENT, 1),
                    new MyVertexInputComponent(MyVertexInputComponentType.TEXCOORD0_H, 1)));

            m_fogShader = MyShaders.CreateCs("clouds.hlsl", new [] {new ShaderMacro("NUMTHREADS", m_numFogThreads)});

            SamplerStateDescription description = new SamplerStateDescription
            {
                AddressU = TextureAddressMode.Wrap,
                AddressV = TextureAddressMode.Wrap,
                AddressW = TextureAddressMode.Wrap,
                Filter = Filter.MinMagMipLinear,
                MaximumLod = System.Single.MaxValue
            };
            m_textureSampler = MyPipelineStates.CreateSamplerState(description);
        }
Esempio n. 14
0
 internal static SamplerState GetSampler(SamplerId id)
 {
     return(SamplerObjects[id.Index]);
 }