示例#1
0
        public static void Init()
        {
            ShadowFilter.Init();

            GFXStateBlockData BL_ProjectedShadowSBData = new GFXStateBlockData("BL_ProjectedShadowSBData")
            {
                BlendDefined      = true,
                BlendEnable       = true,
                BlendSrc          = GFXBlend.GFXBlendDestColor,
                BlendDest         = GFXBlend.GFXBlendZero,
                ZDefined          = true,
                ZEnable           = true,
                ZWriteEnable      = false,
                SamplersDefined   = true,
                SamplerStates     = { [0] = CommonMaterialData.SamplerClampLinear },
                VertexColorEnable = true
            };

            BL_ProjectedShadowSBData.registerSingleton();

            new ShaderData("BL_ProjectedShadowShaderData")
            {
                DXVertexShaderFile  = "data/shaders/common/projectedShadowV.hlsl",
                DXPixelShaderFile   = "data/shaders/common/projectedShadowP.hlsl",
                OGLVertexShaderFile = "data/shaders/common/gl/projectedShadowV.glsl",
                OGLPixelShaderFile  = "data/shaders/common/gl/projectedShadowP.glsl",

                SamplerNames = { [0] = "inputTex" },

                PixVersion = 2.0f
            }.registerSingleton();

            CustomMaterial BL_ProjectedShadowMaterial = new CustomMaterial("BL_ProjectedShadowMaterial")
            {
                Shader     = "BL_ProjectedShadowShaderData",
                StateBlock = BL_ProjectedShadowSBData,
                Version    = 2.0f,
                ForwardLit = true
            };

            BL_ProjectedShadowMaterial.setFieldValue("sampler[inputTex]", "$miscbuff");
            BL_ProjectedShadowMaterial.registerSingleton();
        }
示例#2
0
        public static void Init()
        {
            ShaderData AL_ShadowVisualizeShader = new ShaderData("AL_ShadowVisualizeShader")
            {
                DXVertexShaderFile  = "data/shaders/common/guiMaterialV.hlsl",
                DXPixelShaderFile   = "data/shaders/common/lighting/advanced/dbgShadowVisualizeP.hlsl",
                OGLVertexShaderFile = "data/shaders/common/gl/guiMaterialV.glsl",
                OGLPixelShaderFile  = "data/shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl",
                SamplerNames        =
                {
                    [0] = "$shadowMap",
                    [1] = "$depthViz"
                },
                PixVersion = 2.0f
            };

            AL_ShadowVisualizeShader.registerSingleton();

            CustomMaterial AL_ShadowVisualizeMaterial = new CustomMaterial("AL_ShadowVisualizeMaterial")
            {
                Shader     = "AL_ShadowVisualizeShader",
                StateBlock = AL_DepthVisualize.AL_DepthVisualizeState,
                //todo PixVersion = 2.0
            };

            AL_ShadowVisualizeMaterial.setFieldValue("sampler[shadowMap]", "#AL_ShadowVizTexture");
            AL_ShadowVisualizeMaterial.setFieldValue("sampler[depthViz]", "depthviz");
            AL_ShadowVisualizeMaterial.registerSingleton();

            GuiControlProfile AL_ShadowLabelTextProfile = new GuiControlProfile("AL_ShadowLabelTextProfile")
            {
                FontColor      = ColorI.BLACK,
                AutoSizeWidth  = true,
                AutoSizeHeight = true,
                Justify        = GuiAlignmentType.Left,
                FontSize       = 14,
            };

            AL_ShadowLabelTextProfile.registerSingleton();
        }
示例#3
0
        public static void Init()
        {
            // Vector Light State
            GFXStateBlockData AL_VectorLightState = new GFXStateBlockData("AL_VectorLightState")
            {
                BlendDefined    = true,
                BlendEnable     = true,
                BlendSrc        = GFXBlend.GFXBlendOne,
                BlendDest       = GFXBlend.GFXBlendOne,
                BlendOp         = GFXBlendOp.GFXBlendOpAdd,
                ZDefined        = true,
                ZEnable         = false,
                ZWriteEnable    = false,
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = CommonMaterialData.SamplerClampPoint, // G-buffer
                    // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
                    [1] = CommonMaterialData.SamplerClampPoint,
                    [2] = CommonMaterialData.SamplerClampLinear, // SSAO Mask
                    [3] = CommonMaterialData.SamplerWrapPoint    // Random Direction Map
                },
                CullDefined    = true,
                CullMode       = GFXCullMode.GFXCullNone,
                StencilDefined = true,
                StencilEnable  = true,
                StencilFailOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilZFailOp = GFXStencilOp.GFXStencilOpKeep,
                StencilPassOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilFunc    = GFXCmpFunc.GFXCmpLess,
                StencilRef     = 0
            };

            AL_VectorLightState.setFieldValue("mSamplerNames[0]", "prePassBuffer"); //todo not used anywhere
            AL_VectorLightState.setFieldValue("mSamplerNames[1]", "shadowMap");
            AL_VectorLightState.setFieldValue("mSamplerNames[2]", "ssaoMask");
            AL_VectorLightState.registerSingleton();

            // Vector Light Material
            ShaderData AL_VectorLightShader = new ShaderData("AL_VectorLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/vectorLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/vectorLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "$ssaoMask",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_VectorLightShader.registerSingleton();

            CustomMaterial AL_VectorLightMaterial = new CustomMaterial("AL_VectorLightMaterial")
            {
                Shader     = "AL_VectorLightShader",
                StateBlock = AL_VectorLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_VectorLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_VectorLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_VectorLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_VectorLightMaterial.setFieldValue("sampler[ssaoMask]", "#ssaoMask");
            AL_VectorLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_VectorLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_VectorLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_VectorLightMaterial.registerSingleton();

            //------------------------------------------------------------------------------

            // Convex-geometry light states
            GFXStateBlockData AL_ConvexLightState = new GFXStateBlockData("AL_ConvexLightState")
            {
                BlendDefined    = true,
                BlendEnable     = true,
                BlendSrc        = GFXBlend.GFXBlendOne,
                BlendDest       = GFXBlend.GFXBlendOne,
                BlendOp         = GFXBlendOp.GFXBlendOpAdd,
                ZDefined        = true,
                ZEnable         = true,
                ZWriteEnable    = false,
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = CommonMaterialData.SamplerClampPoint, // G-buffer
                    [1] = CommonMaterialData.SamplerClampPoint,
                    // Shadow Map (Do not use linear, these are perspective projections)
                    [2] = CommonMaterialData.SamplerClampLinear, // Cookie Map
                    [3] = CommonMaterialData.SamplerWrapPoint    // Random Direction Map
                },
                CullDefined    = true,
                CullMode       = GFXCullMode.GFXCullCW,
                StencilDefined = true,
                StencilEnable  = true,
                StencilFailOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilZFailOp = GFXStencilOp.GFXStencilOpKeep,
                StencilPassOp  = GFXStencilOp.GFXStencilOpKeep,
                StencilFunc    = GFXCmpFunc.GFXCmpLess,
                StencilRef     = 0
            };

            AL_ConvexLightState.setFieldValue("mSamplerNames[0]", "prePassBuffer");
            AL_ConvexLightState.setFieldValue("mSamplerNames[1]", "shadowMap");
            AL_ConvexLightState.registerSingleton();


            // Point Light Material
            ShaderData AL_PointLightShader = new ShaderData("AL_PointLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/pointLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/pointLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "cookieMap",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_PointLightShader.registerSingleton();

            CustomMaterial AL_PointLightMaterial = new CustomMaterial("AL_PointLightMaterial")
            {
                Shader     = "AL_PointLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_PointLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_PointLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_PointLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_PointLightMaterial.setFieldValue("sampler[cookieMap]", "$dynamiclightmask");
            AL_PointLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_PointLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_PointLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_PointLightMaterial.registerSingleton();


            // Spot Light Material
            ShaderData AL_SpotLightShader = new ShaderData("AL_SpotLightShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/farFrustumQuadV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/spotLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/farFrustumQuadV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/spotLightP.glsl",
                SamplerNames       =
                {
                    [0] = "$prePassBuffer",
                    [1] = "$shadowMap",
                    [2] = "$dynamicShadowMap",
                    [3] = "cookieMap",
                    [4] = "$gTapRotationTex",
                    [5] = "$lightBuffer",
                    [6] = "$colorBuffer",
                    [7] = "$matInfoBuffer"
                },
                PixVersion = 3.0f
            };

            AL_SpotLightShader.registerSingleton();

            CustomMaterial AL_SpotLightMaterial = new CustomMaterial("AL_SpotLightMaterial")
            {
                Shader     = "AL_SpotLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo pixVersion 3.0f
            };

            AL_SpotLightMaterial.setFieldValue("sampler[prepassBuffer]", "#prepass");
            AL_SpotLightMaterial.setFieldValue("sampler[shadowMap]", "$dynamiclight");
            AL_SpotLightMaterial.setFieldValue("sampler[dynamicShadowMap]", "$dynamicShadowMap");
            AL_SpotLightMaterial.setFieldValue("sampler[cookieMap]", "$dynamiclightmask");
            AL_SpotLightMaterial.setFieldValue("sampler[lightBuffer]", "#lightinfo");
            AL_SpotLightMaterial.setFieldValue("sampler[colorBuffer]", "#color");
            AL_SpotLightMaterial.setFieldValue("sampler[matInfoBuffer]", "#matinfo");
            AL_SpotLightMaterial.registerSingleton();

            // This material is used for generating prepass
            // materials for objects that do not have materials.
            Material AL_DefaultPrePassMaterial = new Material("AL_DefaultPrePassMaterial")
            {
                // We need something in the first pass else it
                // won't create a proper material instance.
                //
                // We use color here because some objects may not
                // have texture coords in their vertex format...
                // for example like terrain.
                //
                DiffuseColor = { [0] = ColorF.WHITE }
            };

            AL_DefaultPrePassMaterial.registerSingleton();

            // This material is used for generating shadow
            // materials for objects that do not have materials.
            Material AL_DefaultShadowMaterial = new Material("AL_DefaultShadowMaterial")
            {
                // We need something in the first pass else it
                // won't create a proper material instance.
                //
                // We use color here because some objects may not
                // have texture coords in their vertex format...
                // for example like terrain.
                //
                DiffuseColor = { [0] = ColorF.WHITE },

                // This is here mostly for terrain which uses
                // this material to create its shadow material.
                //
                // At sunset/sunrise the sun is looking thru
                // backsides of the terrain which often are not
                // closed.  By changing the material to be double
                // sided we avoid holes in the shadowed geometry.
                //
                DoubleSided = true
            };

            AL_DefaultShadowMaterial.registerSingleton();

            // Particle System Point Light Material
            ShaderData AL_ParticlePointLightShader = new ShaderData("AL_ParticlePointLightShader")
            {
                DXVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/particlePointLightV.hlsl",
                DXPixelShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/particlePointLightP.hlsl",
                OGLVertexShaderFile =
                    Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/convexGeometryV.glsl",
                OGLPixelShaderFile = Globals.GetString("Core::CommonShaderPath") + "/lighting/advanced/gl/pointLightP.glsl",
                SamplerNames       = { [0] = "$prePassBuffer" }

                //todo pixVersion = 3.0,
            };

            AL_ParticlePointLightShader.registerSingleton();

            CustomMaterial AL_ParticlePointLightMaterial = new CustomMaterial("AL_ParticlePointLightMaterial")
            {
                Shader     = "AL_ParticlePointLightShader",
                StateBlock = AL_ConvexLightState,
                Target     = "lightinfo"

                             //todo PixVersion = 3.0
            };

            AL_ParticlePointLightMaterial.setFieldValue("Sampler[prePassBuffer]", "#prepass");
            AL_ParticlePointLightMaterial.registerSingleton();
        }
示例#4
0
        public static void Init()
        {
            //-----------------------------------------------------------------------------
            // Water
            //-----------------------------------------------------------------------------

            ShaderData WaterShader = new ShaderData("WaterShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/waterV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/water/waterP.hlsl",
                OGLVertexShaderFile = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterV.glsl",
                OGLPixelShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterP.glsl",
                SamplerNames        =
                {
                    [0] = "$bumpMap",     // noise
                    [1] = "$prepassTex",  // #prepass
                    [2] = "$reflectMap",  // $reflectbuff
                    [3] = "$refractBuff", // $backbuff
                    [4] = "$skyMap",      // $cubemap
                    [5] = "$foamMap",     // foam
                    [6] = "$depthGradMap" // depthMap ( color gradient )
                },

                PixVersion = 3.0f
            };

            WaterShader.registerSingleton();

            GFXSamplerStateData WaterSampler = new GFXSamplerStateData("WaterSampler")
            {
                TextureColorOp = GFXTextureOp.GFXTOPModulate,
                AddressModeU   = GFXTextureAddressMode.GFXAddressWrap,
                AddressModeV   = GFXTextureAddressMode.GFXAddressWrap,
                AddressModeW   = GFXTextureAddressMode.GFXAddressWrap,
                MagFilter      = GFXTextureFilterType.GFXTextureFilterLinear,
                MinFilter      = GFXTextureFilterType.GFXTextureFilterAnisotropic,
                MipFilter      = GFXTextureFilterType.GFXTextureFilterLinear,
                MaxAnisotropy  = 4
            };

            WaterSampler.registerSingleton();

            GFXStateBlockData WaterStateBlock = new GFXStateBlockData("WaterStateBlock")
            {
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = WaterSampler,                          // noise
                    [1] = CommonMaterialData.SamplerClampPoint,  // #prepass
                    [2] = CommonMaterialData.SamplerClampLinear, // $reflectbuff
                    [3] = CommonMaterialData.SamplerClampPoint,  // $backbuff
                    [4] = CommonMaterialData.SamplerWrapLinear,  // $cubemap
                    [5] = CommonMaterialData.SamplerWrapLinear,  // foam
                    [6] = CommonMaterialData.SamplerClampLinear  // depthMap ( color gradient )
                },
                CullDefined = true,
                CullMode    = GFXCullMode.GFXCullCCW
            };

            WaterStateBlock.registerSingleton();

            GFXStateBlockData UnderWaterStateBlock = new GFXStateBlockData("UnderWaterStateBlock", WaterStateBlock)
            {
                CullMode = GFXCullMode.GFXCullCCW
            };

            UnderWaterStateBlock.registerSingleton();

            CustomMaterial WaterMat = new CustomMaterial("WaterMat")
            {
                Shader         = "WaterShader",
                StateBlock     = WaterStateBlock,
                Version        = 3.0f,
                UseAnisotropic = { [0] = true }
            };

            WaterMat.setFieldValue("sampler[prepassTex]", "#prepass");
            WaterMat.setFieldValue("sampler[reflectMap]", "$reflectbuff");
            WaterMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            // These samplers are set in code not here.
            // This is to allow different WaterObject instances
            // to use this same material but override these textures
            // per instance.
            //sampler["bumpMap"] = "";
            //sampler["skyMap"] = "";
            //sampler["foamMap"] = "";
            //sampler["depthGradMap"] = "";
            WaterMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Underwater
            //-----------------------------------------------------------------------------

            new ShaderData("UnderWaterShader", WaterShader)
            {
                Defines = "UNDERWATER"
            }.registerSingleton();

            CustomMaterial UnderwaterMat = new CustomMaterial("UnderwaterMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //sampler["foamMap"] = "art/images/water/foam";

                Shader        = "UnderWaterShader",
                StateBlock    = UnderWaterStateBlock,
                Specular      = { [0] = new ColorF(0.75f, 0.75f, 0.75f, 1.0f) },
                SpecularPower = { [0] = 48.0f },
                Version       = 3.0f
            };

            UnderwaterMat.setFieldValue("sampler[prepassTex]", "#prepass");
            UnderwaterMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            UnderwaterMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Basic Water
            //-----------------------------------------------------------------------------

            ShaderData WaterBasicShader = new ShaderData("WaterBasicShader")
            {
                DXVertexShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/waterBasicV.hlsl",
                DXPixelShaderFile   = Globals.GetString("Core::CommonShaderPath") + "/water/waterBasicP.hlsl",
                OGLVertexShaderFile = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterBasicV.glsl",
                OGLPixelShaderFile  = Globals.GetString("Core::CommonShaderPath") + "/water/gl/waterBasicP.glsl",
                SamplerNames        =
                {
                    [0] = "$bumpMap",
                    [2] = "$reflectMap",
                    [3] = "$refractBuff",
                    [4] = "$skyMap",
                    [5] = "$depthGradMap"
                },
                PixVersion = 2.0f
            };

            WaterBasicShader.registerSingleton();

            GFXStateBlockData WaterBasicStateBlock = new GFXStateBlockData("WaterBasicStateBlock")
            {
                SamplersDefined = true,
                SamplerStates   =
                {
                    [0] = WaterSampler,                          // noise
                    [2] = CommonMaterialData.SamplerClampLinear, // $reflectbuff
                    [3] = CommonMaterialData.SamplerClampPoint,  // $backbuff
                    [4] = CommonMaterialData.SamplerWrapLinear   // $cubemap
                },
                CullDefined = true,
                CullMode    = GFXCullMode.GFXCullCCW
            };

            WaterBasicStateBlock.registerSingleton();

            GFXStateBlockData UnderWaterBasicStateBlock = new GFXStateBlockData("UnderWaterBasicStateBlock",
                                                                                WaterBasicStateBlock)
            {
                CullMode = GFXCullMode.GFXCullCCW
            };

            UnderWaterBasicStateBlock.registerSingleton();

            CustomMaterial WaterBasicMat = new CustomMaterial("WaterBasicMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //sampler["skyMap"] = "$cubemap";

                //sampler["prepassTex"] = "#prepass";

                Cubemap    = "NewLevelSkyCubemap",
                Shader     = "WaterBasicShader",
                StateBlock = WaterBasicStateBlock,
                Version    = 2.0f
            };

            WaterBasicMat.setFieldValue("sampler[reflectMap]", "$reflectbuff");
            WaterBasicMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            WaterBasicMat.registerSingleton();

            //-----------------------------------------------------------------------------
            // Basic UnderWater
            //-----------------------------------------------------------------------------

            new ShaderData("UnderWaterBasicShader", WaterBasicShader)
            {
                Defines = "UNDERWATER"
            }.registerSingleton();

            CustomMaterial UnderwaterBasicMat = new CustomMaterial("UnderwaterBasicMat")
            {
                // These samplers are set in code not here.
                // This is to allow different WaterObject instances
                // to use this same material but override these textures
                // per instance.
                //sampler["bumpMap"] = "art/images/water/noise02";
                //samplers["skyMap"] = "$cubemap";

                //sampler["prepassTex"] = "#prepass";

                Shader     = "UnderWaterBasicShader",
                StateBlock = UnderWaterBasicStateBlock,
                Version    = 2.0f
            };

            UnderwaterBasicMat.setFieldValue("sampler[refractBuff]", "$backbuff");
            UnderwaterBasicMat.registerSingleton();
        }