/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="graphics">Graphics device</param>
        /// <param name="effect">Effect code</param>
        /// <param name="compile">Compile code</param>
        public EffectDeferredTerrain(Graphics graphics, byte[] effect, bool compile)
            : base(graphics, effect, compile)
        {
            this.TerrainAlphaMapDeferred = this.Effect.GetTechniqueByName("TerrainAlphaMapDeferred");
            this.TerrainSlopesDeferred   = this.Effect.GetTechniqueByName("TerrainSlopesDeferred");
            this.TerrainFullDeferred     = this.Effect.GetTechniqueByName("TerrainFullDeferred");

            this.worldVar = this.Effect.GetVariableMatrix("gVSWorld");
            this.worldViewProjectionVar = this.Effect.GetVariableMatrix("gVSWorldViewProjection");
            this.textureResolutionVar   = this.Effect.GetVariableScalar("gVSTextureResolution");

            this.diffuseMapLRVar  = this.Effect.GetVariableTexture("gPSDiffuseMapLRArray");
            this.diffuseMapHRVar  = this.Effect.GetVariableTexture("gPSDiffuseMapHRArray");
            this.normalMapVar     = this.Effect.GetVariableTexture("gPSNormalMapArray");
            this.specularMapVar   = this.Effect.GetVariableTexture("gPSSpecularMapArray");
            this.colorTexturesVar = this.Effect.GetVariableTexture("gPSColorTextureArray");
            this.alphaMapVar      = this.Effect.GetVariableTexture("gPSAlphaTexture");
            this.parametersVar    = this.Effect.GetVariableVector("gPSParams");
            this.materialIndexVar = this.Effect.GetVariableScalar("gPSMaterialIndex");

            //Samplers
            this.samplerDiffuseVar  = this.Effect.GetVariableSampler("SamplerDiffuse");
            this.samplerSpecularVar = this.Effect.GetVariableSampler("SamplerSpecular");
            this.samplerNormalVar   = this.Effect.GetVariableSampler("SamplerNormal");

            //Initialize states
            this.samplerPoint       = EngineSamplerState.Point(graphics);
            this.samplerLinear      = EngineSamplerState.Linear(graphics);
            this.samplerAnisotropic = EngineSamplerState.Anisotropic(graphics, 8);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="graphics">Graphics device</param>
        /// <param name="effect">Effect code</param>
        /// <param name="compile">Compile code</param>
        public EffectDefaultTerrain(Graphics graphics, byte[] effect, bool compile)
            : base(graphics, effect, compile)
        {
            this.TerrainAlphaMapForward = this.Effect.GetTechniqueByName("TerrainAlphaMapForward");
            this.TerrainSlopesForward   = this.Effect.GetTechniqueByName("TerrainSlopesForward");
            this.TerrainFullForward     = this.Effect.GetTechniqueByName("TerrainFullForward");

            //Globals
            this.materialPaletteWidthVar = this.Effect.GetVariableScalar("gMaterialPaletteWidth");
            this.materialPaletteVar      = this.Effect.GetVariableTexture("gMaterialPalette");
            this.lodVar = this.Effect.GetVariableVector("gLOD");

            //Per frame
            this.worldVar = this.Effect.GetVariableMatrix("gVSWorld");
            this.worldViewProjectionVar = this.Effect.GetVariableMatrix("gVSWorldViewProjection");
            this.textureResolutionVar   = this.Effect.GetVariableScalar("gVSTextureResolution");

            this.eyePositionWorldVar     = this.Effect.GetVariableVector("gPSEyePositionWorld");
            this.lightCountVar           = this.Effect.GetVariableVector("gPSLightCount");
            this.fogColorVar             = this.Effect.GetVariableVector("gPSFogColor");
            this.fogStartVar             = this.Effect.GetVariableScalar("gPSFogStart");
            this.fogRangeVar             = this.Effect.GetVariableScalar("gPSFogRange");
            this.hemiLightVar            = this.Effect.GetVariable("gPSHemiLight");
            this.dirLightsVar            = this.Effect.GetVariable("gPSDirLights");
            this.pointLightsVar          = this.Effect.GetVariable("gPSPointLights");
            this.spotLightsVar           = this.Effect.GetVariable("gPSSpotLights");
            this.shadowMapDirectionalVar = this.Effect.GetVariableTexture("gPSShadowMapDir");
            this.shadowMapPointVar       = this.Effect.GetVariableTexture("gPSShadowMapPoint");
            this.shadowMapSpotVar        = this.Effect.GetVariableTexture("gPSShadowMapSpot");

            //Per object
            this.parametersVar       = this.Effect.GetVariableVector("gPSParams");
            this.useColorDiffuseVar  = this.Effect.GetVariableScalar("gPSUseColorDiffuse");
            this.useColorSpecularVar = this.Effect.GetVariableScalar("gPSUseColorSpecular");
            this.materialIndexVar    = this.Effect.GetVariableScalar("gPSMaterialIndex");
            this.normalMapVar        = this.Effect.GetVariableTexture("gPSNormalMapArray");
            this.specularMapVar      = this.Effect.GetVariableTexture("gPSSpecularMapArray");
            this.colorTexturesVar    = this.Effect.GetVariableTexture("gPSColorTextureArray");
            this.alphaMapVar         = this.Effect.GetVariableTexture("gPSAlphaTexture");
            this.diffuseMapLRVar     = this.Effect.GetVariableTexture("gPSDiffuseMapLRArray");
            this.diffuseMapHRVar     = this.Effect.GetVariableTexture("gPSDiffuseMapHRArray");

            //Samplers
            this.samplerDiffuseVar  = this.Effect.GetVariableSampler("SamplerDiffuse");
            this.samplerSpecularVar = this.Effect.GetVariableSampler("SamplerSpecular");
            this.samplerNormalVar   = this.Effect.GetVariableSampler("SamplerNormal");

            //Initialize states
            this.samplerPoint       = EngineSamplerState.Point(graphics);
            this.samplerLinear      = EngineSamplerState.Linear(graphics);
            this.samplerAnisotropic = EngineSamplerState.Anisotropic(graphics, 8);
        }
Beispiel #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="graphics">Graphics device</param>
        /// <param name="effect">Effect code</param>
        /// <param name="compile">Compile code</param>
        public EffectDeferredBasic(Graphics graphics, byte[] effect, bool compile)
            : base(graphics, effect, compile)
        {
            this.PositionColor                                 = this.Effect.GetTechniqueByName("PositionColor");
            this.PositionColorSkinned                          = this.Effect.GetTechniqueByName("PositionColorSkinned");
            this.PositionNormalColor                           = this.Effect.GetTechniqueByName("PositionNormalColor");
            this.PositionNormalColorSkinned                    = this.Effect.GetTechniqueByName("PositionNormalColorSkinned");
            this.PositionTexture                               = this.Effect.GetTechniqueByName("PositionTexture");
            this.PositionTextureSkinned                        = this.Effect.GetTechniqueByName("PositionTextureSkinned");
            this.PositionNormalTexture                         = this.Effect.GetTechniqueByName("PositionNormalTexture");
            this.PositionNormalTextureSkinned                  = this.Effect.GetTechniqueByName("PositionNormalTextureSkinned");
            this.PositionNormalTextureTangent                  = this.Effect.GetTechniqueByName("PositionNormalTextureTangent");
            this.PositionNormalTextureTangentSkinned           = this.Effect.GetTechniqueByName("PositionNormalTextureTangentSkinned");
            this.InstancingPositionColor                       = this.Effect.GetTechniqueByName("PositionColorI");
            this.InstancingPositionColorSkinned                = this.Effect.GetTechniqueByName("PositionColorSkinnedI");
            this.InstancingPositionNormalColor                 = this.Effect.GetTechniqueByName("PositionNormalColorI");
            this.InstancingPositionNormalColorSkinned          = this.Effect.GetTechniqueByName("PositionNormalColorSkinnedI");
            this.InstancingPositionTexture                     = this.Effect.GetTechniqueByName("PositionTextureI");
            this.InstancingPositionTextureSkinned              = this.Effect.GetTechniqueByName("PositionTextureSkinnedI");
            this.InstancingPositionNormalTexture               = this.Effect.GetTechniqueByName("PositionNormalTextureI");
            this.InstancingPositionNormalTextureSkinned        = this.Effect.GetTechniqueByName("PositionNormalTextureSkinnedI");
            this.InstancingPositionNormalTextureTangent        = this.Effect.GetTechniqueByName("PositionNormalTextureTangentI");
            this.InstancingPositionNormalTextureTangentSkinned = this.Effect.GetTechniqueByName("PositionNormalTextureTangentSkinnedI");

            this.worldVar = this.Effect.GetVariableMatrix("gWorld");
            this.worldViewProjectionVar   = this.Effect.GetVariableMatrix("gWorldViewProjection");
            this.animationOffsetVar       = this.Effect.GetVariableScalar("gAnimationOffset");
            this.materialIndexVar         = this.Effect.GetVariableScalar("gMaterialIndex");
            this.textureIndexVar          = this.Effect.GetVariableScalar("gTextureIndex");
            this.diffuseMapVar            = this.Effect.GetVariableTexture("gDiffuseMapArray");
            this.normalMapVar             = this.Effect.GetVariableTexture("gNormalMapArray");
            this.specularMapVar           = this.Effect.GetVariableTexture("gSpecularMapArray");
            this.animationPaletteWidthVar = this.Effect.GetVariableScalar("gAnimationPaletteWidth");
            this.animationPaletteVar      = this.Effect.GetVariableTexture("gAnimationPalette");

            //Samplers
            this.samplerDiffuseVar = this.Effect.GetVariableSampler("SamplerDiffuse");
            this.samplerNormalVar  = this.Effect.GetVariableSampler("SamplerNormal");

            //Initialize states
            this.samplerLinear      = EngineSamplerState.Linear(graphics);
            this.samplerAnisotropic = EngineSamplerState.Anisotropic(graphics, 4);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="graphics">Graphics device</param>
        /// <param name="effect">Effect code</param>
        /// <param name="compile">Compile code</param>
        public EffectDefaultBasic(Graphics graphics, byte[] effect, bool compile)
            : base(graphics, effect, compile)
        {
            this.PositionColor                                 = this.Effect.GetTechniqueByName("PositionColor");
            this.PositionColorSkinned                          = this.Effect.GetTechniqueByName("PositionColorSkinned");
            this.PositionNormalColor                           = this.Effect.GetTechniqueByName("PositionNormalColor");
            this.PositionNormalColorSkinned                    = this.Effect.GetTechniqueByName("PositionNormalColorSkinned");
            this.PositionTexture                               = this.Effect.GetTechniqueByName("PositionTexture");
            this.PositionTextureNOALPHA                        = this.Effect.GetTechniqueByName("PositionTextureNOALPHA");
            this.PositionTextureRED                            = this.Effect.GetTechniqueByName("PositionTextureRED");
            this.PositionTextureGREEN                          = this.Effect.GetTechniqueByName("PositionTextureGREEN");
            this.PositionTextureBLUE                           = this.Effect.GetTechniqueByName("PositionTextureBLUE");
            this.PositionTextureALPHA                          = this.Effect.GetTechniqueByName("PositionTextureALPHA");
            this.PositionTextureSkinned                        = this.Effect.GetTechniqueByName("PositionTextureSkinned");
            this.PositionNormalTexture                         = this.Effect.GetTechniqueByName("PositionNormalTexture");
            this.PositionNormalTextureSkinned                  = this.Effect.GetTechniqueByName("PositionNormalTextureSkinned");
            this.PositionNormalTextureTangent                  = this.Effect.GetTechniqueByName("PositionNormalTextureTangent");
            this.PositionNormalTextureTangentSkinned           = this.Effect.GetTechniqueByName("PositionNormalTextureTangentSkinned");
            this.InstancingPositionColor                       = this.Effect.GetTechniqueByName("PositionColorI");
            this.InstancingPositionColorSkinned                = this.Effect.GetTechniqueByName("PositionColorSkinnedI");
            this.InstancingPositionNormalColor                 = this.Effect.GetTechniqueByName("PositionNormalColorI");
            this.InstancingPositionNormalColorSkinned          = this.Effect.GetTechniqueByName("PositionNormalColorSkinnedI");
            this.InstancingPositionTexture                     = this.Effect.GetTechniqueByName("PositionTextureI");
            this.InstancingPositionTextureNOALPHA              = this.Effect.GetTechniqueByName("PositionTextureNOALPHAI");
            this.InstancingPositionTextureRED                  = this.Effect.GetTechniqueByName("PositionTextureREDI");
            this.InstancingPositionTextureGREEN                = this.Effect.GetTechniqueByName("PositionTextureGREENI");
            this.InstancingPositionTextureBLUE                 = this.Effect.GetTechniqueByName("PositionTextureBLUEI");
            this.InstancingPositionTextureALPHA                = this.Effect.GetTechniqueByName("PositionTextureALPHAI");
            this.InstancingPositionTextureSkinned              = this.Effect.GetTechniqueByName("PositionTextureSkinnedI");
            this.InstancingPositionNormalTexture               = this.Effect.GetTechniqueByName("PositionNormalTextureI");
            this.InstancingPositionNormalTextureSkinned        = this.Effect.GetTechniqueByName("PositionNormalTextureSkinnedI");
            this.InstancingPositionNormalTextureTangent        = this.Effect.GetTechniqueByName("PositionNormalTextureTangentI");
            this.InstancingPositionNormalTextureTangentSkinned = this.Effect.GetTechniqueByName("PositionNormalTextureTangentSkinnedI");

            //Globals
            this.animationPaletteWidthVar = this.Effect.GetVariableScalar("gAnimationPaletteWidth");
            this.animationPaletteVar      = this.Effect.GetVariableTexture("gAnimationPalette");
            this.materialPaletteWidthVar  = this.Effect.GetVariableScalar("gMaterialPaletteWidth");
            this.materialPaletteVar       = this.Effect.GetVariableTexture("gMaterialPalette");
            this.lodVar = this.Effect.GetVariableVector("gLOD");

            //Per frame
            this.worldVar = this.Effect.GetVariableMatrix("gVSWorld");
            this.worldViewProjectionVar  = this.Effect.GetVariableMatrix("gVSWorldViewProjection");
            this.eyePositionWorldVar     = this.Effect.GetVariableVector("gPSEyePositionWorld");
            this.hemiLightVar            = this.Effect.GetVariable("gPSHemiLight");
            this.dirLightsVar            = this.Effect.GetVariable("gPSDirLights");
            this.pointLightsVar          = this.Effect.GetVariable("gPSPointLights");
            this.spotLightsVar           = this.Effect.GetVariable("gPSSpotLights");
            this.lightCountVar           = this.Effect.GetVariableVector("gPSLightCount");
            this.fogStartVar             = this.Effect.GetVariableScalar("gPSFogStart");
            this.fogRangeVar             = this.Effect.GetVariableScalar("gPSFogRange");
            this.fogColorVar             = this.Effect.GetVariableVector("gPSFogColor");
            this.shadowMapDirectionalVar = this.Effect.GetVariableTexture("gPSShadowMapDir");
            this.shadowMapPointVar       = this.Effect.GetVariableTexture("gPSShadowMapPoint");
            this.shadowMapSpotVar        = this.Effect.GetVariableTexture("gPSShadowMapSpot");

            //Per object
            this.useColorDiffuseVar  = this.Effect.GetVariableScalar("gPSUseColorDiffuse");
            this.useColorSpecularVar = this.Effect.GetVariableScalar("gPSUseColorSpecular");
            this.diffuseMapVar       = this.Effect.GetVariableTexture("gPSDiffuseMapArray");
            this.normalMapVar        = this.Effect.GetVariableTexture("gPSNormalMapArray");
            this.specularMapVar      = this.Effect.GetVariableTexture("gPSSpecularMapArray");

            //Per instance
            this.animationOffsetVar = this.Effect.GetVariableScalar("gVSAnimationOffset");
            this.materialIndexVar   = this.Effect.GetVariableScalar("gPSMaterialIndex");
            this.textureIndexVar    = this.Effect.GetVariableScalar("gPSTextureIndex");

            //Samplers
            this.samplerDiffuseVar  = this.Effect.GetVariableSampler("SamplerDiffuse");
            this.samplerSpecularVar = this.Effect.GetVariableSampler("SamplerSpecular");
            this.samplerNormalVar   = this.Effect.GetVariableSampler("SamplerNormal");

            //Initialize states
            this.samplerPoint       = EngineSamplerState.Point(graphics);
            this.samplerLinear      = EngineSamplerState.Linear(graphics);
            this.samplerAnisotropic = EngineSamplerState.Anisotropic(graphics, 4);
        }