Esempio n. 1
0
 public GraphicsSettings()
 {
     ShadowMap = new ShadowMap.Settings();
     Sssm = new Sssm.Settings();
     Ssao = new Ssao.Settings();
     Edge = new Edge.Settings();
     Bloom = new Bloom.Settings();
     Dof = new Dof.Settings();
 }
Esempio n. 2
0
        public Sssm(SpriteBatch spriteBatch, ShadowMap.Settings shadowMapSettings, Settings sssmSettings,
            Effect shadowSceneEffect, Effect sssmEffect, Effect blurEffect)
            : base(spriteBatch)
        {
            if (shadowMapSettings == null) throw new ArgumentNullException("shadowMapSettings");
            if (sssmSettings == null) throw new ArgumentNullException("sssmSettings");
            if (shadowSceneEffect == null) throw new ArgumentNullException("shadowSceneEffect");
            if (sssmEffect == null) throw new ArgumentNullException("sssmEffect");
            if (blurEffect == null) throw new ArgumentNullException("blurEffect");

            this.shadowMapSettings = shadowMapSettings;
            this.sssmSettings = sssmSettings;
            this.sssmEffect = sssmEffect;

            //================================================================
            // シャドウ シーン

            //----------------------------------------------------------------
            // エフェクト

            this.shadowSceneEffect = new ShadowSceneEffect(shadowSceneEffect);
            this.shadowSceneEffect.DepthBias = shadowMapSettings.DepthBias;
            this.shadowSceneEffect.SplitCount = shadowMapSettings.SplitCount;
            this.shadowSceneEffect.ShadowMapSize = shadowMapSettings.Size;
            this.shadowSceneEffect.ShadowMapTechnique = shadowMapSettings.Technique;

            //----------------------------------------------------------------
            // レンダ ターゲット

            var pp = GraphicsDevice.PresentationParameters;
            var width = (int) (pp.BackBufferWidth * sssmSettings.MapScale);
            var height = (int) (pp.BackBufferHeight * sssmSettings.MapScale);

            // メモ: ブラーをかける場合があるので RenderTargetUsage.PreserveContents で作成。
            shadowSceneMap = new RenderTarget2D(GraphicsDevice, width, height,
                false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);

            //================================================================
            // スクリーン スペース シャドウ マッピング

            //----------------------------------------------------------------
            // エフェクト

            shadowColorParameter = sssmEffect.Parameters["ShadowColor"];
            shadowSceneMapParameter = sssmEffect.Parameters["ShadowSceneMap"];
            currentPass = sssmEffect.CurrentTechnique.Passes[0];

            //----------------------------------------------------------------
            // ブラー

            if (sssmSettings.BlurEnabled)
            {
                var blurSettings = sssmSettings.Blur;
                blur = new GaussianBlur(blurEffect, spriteBatch, width, height, SurfaceFormat.Vector2,
                    blurSettings.Radius, blurSettings.Amount);
            }
        }
Esempio n. 3
0
        public Sssm(SpriteBatch spriteBatch, ShadowMap.Settings shadowMapSettings, Settings sssmSettings,
                    Effect shadowSceneEffect, Effect sssmEffect, Effect blurEffect)
            : base(spriteBatch)
        {
            if (shadowMapSettings == null)
            {
                throw new ArgumentNullException("shadowMapSettings");
            }
            if (sssmSettings == null)
            {
                throw new ArgumentNullException("sssmSettings");
            }
            if (shadowSceneEffect == null)
            {
                throw new ArgumentNullException("shadowSceneEffect");
            }
            if (sssmEffect == null)
            {
                throw new ArgumentNullException("sssmEffect");
            }
            if (blurEffect == null)
            {
                throw new ArgumentNullException("blurEffect");
            }

            this.shadowMapSettings = shadowMapSettings;
            this.sssmSettings      = sssmSettings;
            this.sssmEffect        = sssmEffect;

            //================================================================
            // シャドウ シーン

            //----------------------------------------------------------------
            // エフェクト

            this.shadowSceneEffect                    = new ShadowSceneEffect(shadowSceneEffect);
            this.shadowSceneEffect.DepthBias          = shadowMapSettings.DepthBias;
            this.shadowSceneEffect.SplitCount         = shadowMapSettings.SplitCount;
            this.shadowSceneEffect.ShadowMapSize      = shadowMapSettings.Size;
            this.shadowSceneEffect.ShadowMapTechnique = shadowMapSettings.Technique;

            //----------------------------------------------------------------
            // レンダ ターゲット

            var pp     = GraphicsDevice.PresentationParameters;
            var width  = (int)(pp.BackBufferWidth * sssmSettings.MapScale);
            var height = (int)(pp.BackBufferHeight * sssmSettings.MapScale);

            // メモ: ブラーをかける場合があるので RenderTargetUsage.PreserveContents で作成。
            shadowSceneMap = new RenderTarget2D(GraphicsDevice, width, height,
                                                false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);

            //================================================================
            // スクリーン スペース シャドウ マッピング

            //----------------------------------------------------------------
            // エフェクト

            shadowColorParameter    = sssmEffect.Parameters["ShadowColor"];
            shadowSceneMapParameter = sssmEffect.Parameters["ShadowSceneMap"];
            currentPass             = sssmEffect.CurrentTechnique.Passes[0];

            //----------------------------------------------------------------
            // ブラー

            if (sssmSettings.BlurEnabled)
            {
                var blurSettings = sssmSettings.Blur;
                blur = new GaussianBlur(blurEffect, spriteBatch, width, height, SurfaceFormat.Vector2,
                                        blurSettings.Radius, blurSettings.Amount);
            }
        }