Esempio n. 1
0
 public void DrawStep2(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (!m_enemiesPaused)
     {
         camera.Draw(m_bgRenderTarget, Vector2.Zero, Color.White);
     }
 }
Esempio n. 2
0
        private void ProcessBloomStep(RenderStep step, DrawDevice drawDevice)
        {
            ContentRef <RenderTarget> outputTarget = drawDevice.Target;
            Vector2 imageSize    = drawDevice.TargetSize;
            Rect    viewportRect = drawDevice.ViewportRect;

            this.SetupTargets((Point2)drawDevice.TargetSize);

            // Extract bright spots from the rendered image
            {
                BatchInfo material = drawDevice.RentMaterial();
                material.Technique   = this.techFilterBrightness;
                material.MainTexture = step.Input.MainTexture;
                material.SetValue("minBrightness", this.minBrightness);
                material.SetValue("bloomStrength", this.bloomStrength);
                this.Blit(drawDevice, material, this.targetPingPongA[0]);
            }

            // Downsample to lowest target
            for (int i = 1; i < this.targetPingPongA.Length; i++)
            {
                BatchInfo material = drawDevice.RentMaterial();
                material.Technique   = this.techDownsample;
                material.MainTexture = this.targetPingPongA[i - 1].Targets[0];
                this.Blit(drawDevice, material, this.targetPingPongA[i]);
            }

            // Blur all targets, separating horizontal and vertical blur
            for (int i = 0; i < this.targetPingPongA.Length; i++)
            {
                BatchInfo material;
                material           = drawDevice.RentMaterial();
                material.Technique = this.techBlur;

                material.MainTexture = this.targetPingPongA[i].Targets[0];
                material.SetValue("blurDirection", new Vector2(1.0f, 0.0f));
                this.Blit(drawDevice, material, this.targetPingPongB[i]);

                material           = drawDevice.RentMaterial();
                material.Technique = this.techBlur;

                material.MainTexture = this.targetPingPongB[i].Targets[0];
                material.SetValue("blurDirection", new Vector2(0.0f, 1.0f));
                this.Blit(drawDevice, material, this.targetPingPongA[i]);
            }

            // Combine all targets into the final image using the draw device's original target
            {
                BatchInfo material = drawDevice.RentMaterial();
                material.Technique   = this.techCombineFinal;
                material.MainTexture = step.Input.MainTexture;
                material.SetTexture("blurFullTex", this.targetPingPongA[0].Targets[0]);
                material.SetTexture("blurHalfTex", this.targetPingPongA[1].Targets[0]);
                material.SetTexture("blurQuarterTex", this.targetPingPongA[2].Targets[0]);
                material.SetTexture("blurEighthTex", this.targetPingPongA[3].Targets[0]);
                this.Blit(drawDevice, material, outputTarget.Res, imageSize, viewportRect);
            }
        }
Esempio n. 3
0
 public void PrepareFinal(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (CurrentRoom.Name != "Ending" && (Game.PlayerStats.Traits.X == 1f || Game.PlayerStats.Traits.Y == 1f) && Game.PlayerStats.SpecialItem != 8)
     {
         step.Effect = Game.HSVEffect;
         step.Effect.Parameters["Saturation"].SetValue(0);
         step.Effect.Parameters["Brightness"].SetValue(0);
         step.Effect.Parameters["Contrast"].SetValue(0);
     }
 }
Esempio n. 4
0
        private void PrepareRippleRender(Camera2D camera, RenderStep step, GameTime gameTime)
        {
            Vector2 position = Game.Player.Instance.GameObject.Position - camera.TopLeftCorner;
            var     effect   = Shaders.Ripple;

            effect.Parameters["width"].SetValue(Magnitude);
            effect.Parameters["xcenter"].SetValue(position.X / 1320f);
            effect.Parameters["ycenter"].SetValue(position.Y / 720f);
            step.Effect = effect;
        }
Esempio n. 5
0
 public void PreparePausedEnemies(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (!(step.Skip = !m_enemiesPaused))
     {
         if (step.Effect == Game.HSVEffect)
         {
             step.Effect.Parameters["Saturation"].SetValue(0);
             step.Effect.Parameters["UseMask"].SetValue(true);
         }
     }
 }
Esempio n. 6
0
    void OnEnable()
    {
        _frameBlendMaterial = new Material(FrameBlendShader);

        MainCamera         = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        MainCamera.enabled = false;

        _renderStep = RenderStep.Rt0;

        _thisEmptyShellCamera.enabled = true;
    }
Esempio n. 7
0
 public void DrawStep9(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (!LevelEV.SAVE_FRAMES)
     {
         camera.Draw(m_shadowRenderTarget, Vector2.Zero, Color.White);
     }
     else
     {
         camera.Draw(m_shadowRenderTarget, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, new Vector2(2f, 2f), SpriteEffects.None, 1f);
     }
 }
Esempio n. 8
0
        public void DrawStep8(Camera2D camera, RenderStep step, GameTime gameTime)
        {
            m_textManager.Draw(camera);

            if (CurrentRoom.LevelType == GameTypes.LevelType.TOWER)
            {
                m_gardenParallaxFG.Draw(camera);
            }

            m_whiteBG.Draw(camera);
        }
Esempio n. 9
0
 protected override void OnRenderSingleStep(RenderStep step, Scene scene, DrawDevice drawDevice)
 {
     if (step.Id == "Resize")
     {
         ProcessResizeStep(drawDevice);
     }
     else
     {
         base.OnRenderSingleStep(step, scene, drawDevice);
     }
 }
Esempio n. 10
0
 protected override void OnRenderSingleStep(RenderStep step, Scene scene, DrawDevice drawDevice)
 {
     if (step.Id == "Bloom")
     {
         this.ProcessBloomStep(step, drawDevice);
     }
     else
     {
         base.OnRenderSingleStep(step, scene, drawDevice);
     }
 }
Esempio n. 11
0
 public void PrepareNostalgiaDesaturate(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (CurrentRoom.Name == "Ending" || Game.PlayerStats.TutorialComplete && Game.PlayerStats.Traits.X != 29f && Game.PlayerStats.Traits.Y != 29f)
     {
         step.Skip = true;
     }
     else if (step.Effect == Game.HSVEffect)
     {
         step.Effect.Parameters["Saturation"].SetValue(0.2f);
         step.Effect.Parameters["Brightness"].SetValue(0.1f);
     }
 }
Esempio n. 12
0
        public void DrawStep4(Camera2D camera, RenderStep step, GameTime gameTime)
        {
            CurrentRoom.Draw(camera);

            if (LevelEV.SHOW_ENEMY_RADII)
            {
                foreach (var enemyList in m_currentRoom.EnemyList)
                {
                    enemyList.DrawDetectionRadii(camera);
                }
            }

            m_projectileManager.Draw(camera);
        }
Esempio n. 13
0
 public void DrawStep1(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     m_backgroundSprite.Draw(camera);
     if (CurrentRoom == null || camera.Zoom != 1f || m_inputMap.Pressed(2) && (!m_inputMap.Pressed(2) || !LevelEV.RUN_DEMO_VERSION && !LevelEV.CREATE_RETAIL_VERSION))
     {
         foreach (RoomObj mRoomList in m_roomList)
         {
             mRoomList.DrawBGObjs(camera);
         }
     }
     else
     {
         CurrentRoom.DrawBGObjs(camera);
     }
 }
Esempio n. 14
0
 public void PrepareHUD(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     if (CurrentRoom.Name != "Ending")
     {
         if ((Game.PlayerStats.Traits.X == 3f || Game.PlayerStats.Traits.Y == 3f) && Game.PlayerStats.SpecialItem != 8)
         {
             Game.GaussianBlur.InvertMask = true;
             Game.GaussianBlur.Draw(m_finalRenderTarget, camera, m_traitAuraRenderTarget);
         }
         else if ((Game.PlayerStats.Traits.X == 4f || Game.PlayerStats.Traits.Y == 4f) && Game.PlayerStats.SpecialItem != 8)
         {
             Game.GaussianBlur.InvertMask = false;
             Game.GaussianBlur.Draw(m_finalRenderTarget, camera, m_traitAuraRenderTarget);
         }
     }
 }
Esempio n. 15
0
        public void DrawStep7(Camera2D camera, RenderStep step, GameTime gameTime)
        {
            camera.Draw(Game.GenericTexture, new Rectangle((int)camera.TopLeftCorner.X, (int)camera.TopLeftCorner.Y, 1320, 720), Color.Black * BackBufferOpacity);

            if (!m_player.IsKilled)
            {
                m_player.Draw(camera);
            }

            if (!LevelEV.CREATE_RETAIL_VERSION)
            {
                DebugTextObj.Position = new Vector2(camera.X, camera.Y - 300f);
                DebugTextObj.Draw(camera);
            }

            m_itemDropManager.Draw(camera);
            m_impactEffectPool.Draw(camera);
        }
Esempio n. 16
0
        public void DrawStep10(Camera2D camera, RenderStep step, GameTime gameTime)
        {
            m_projectileIconPool.Draw(camera);
            m_playerHUD.Draw(camera);

            if (m_lastEnemyHit != null && m_enemyHUDCounter > 0f)
            {
                m_enemyHUD.Draw(camera);
            }

            if (m_enemyHUDCounter > 0f)
            {
                ProceduralLevelScreen mEnemyHUDCounter = this;
                mEnemyHUDCounter.m_enemyHUDCounter = mEnemyHUDCounter.m_enemyHUDCounter - (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (CurrentRoom.Name != "Start" && CurrentRoom.Name != "Boss" && CurrentRoom.Name != "ChallengeBoss" && m_miniMapDisplay.Visible)
            {
                m_mapBG.Draw(camera);
                m_miniMapDisplay.Draw(camera);
            }

            if (CurrentRoom.Name != "Boss" && CurrentRoom.Name != "Ending")
            {
                m_compassBG.Draw(camera);
                m_compass.Draw(camera);
            }

            m_objectivePlate.Draw(camera);
            m_roomEnteringTitle.Draw(camera);
            m_roomTitle.Draw(camera);

            if (CurrentRoom.Name != "Ending" && (!Game.PlayerStats.TutorialComplete || Game.PlayerStats.Traits.X == 29f || Game.PlayerStats.Traits.Y == 29f) && Game.PlayerStats.SpecialItem != 8)
            {
                m_filmGrain.Draw(camera);
            }
        }
Esempio n. 17
0
 public void SetCameraTransform(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     step.TransformMatrix = camera.GetTransformation();
 }
Esempio n. 18
0
 public void DrawStep3(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     camera.Draw(CurrentRoom.BGRender, camera.TopLeftCorner, Color.White);
 }
Esempio n. 19
0
 public void DrawStep6(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     camera.Draw(m_bgRenderTarget, Vector2.Zero, Color.White);
 }
Esempio n. 20
0
        /// <summary>
        /// Called when the <see cref="CamViewState"/> is entered.
        /// Use this for overall initialization of the state.
        /// </summary>
        internal protected virtual void OnEnterState()
        {
            this.RestoreActiveLayers();
            this.RestoreObjectVisibility();

            // Create re-usable render passes for editor gizmos
            {
                // A screen overlay that is rendered behind all following gizmos.
                // This is used for the "background plate" to grey out or darken
                // the actual rendered world in order to make custom gizmos more visible.
                this.camPassBg = new RenderStep
                {
                    Id             = "EditorGizmoBackground",
                    Projection     = ProjectionMode.Screen,
                    ClearFlags     = ClearFlag.None,
                    VisibilityMask = VisibilityFlag.ScreenOverlay
                };

                // An in-world rendering step that can make use of the existing depth
                // buffer values, so gizmos can interact with actual world geometry.
                this.camPassEdWorld = new RenderStep
                {
                    Id = "EditorGizmoWorld",
                    DefaultProjection = true,
                    ClearFlags        = ClearFlag.None,
                    VisibilityMask    = VisibilityFlag.None
                };

                // An in-world rendering step where the depth buffer has been cleared.
                // This allows to render gizmos in world coordinates that can occlude
                // each other, while not interacting with world geometry or previously
                // rendered gizmos.
                this.camPassEdWorldNoDepth = new RenderStep
                {
                    Id = "EditorGizmoWorldOverlay",
                    DefaultProjection = true,
                    ClearFlags        = ClearFlag.Depth,
                    VisibilityMask    = VisibilityFlag.None
                };

                // The final screen overlay rendering step after all gizmos have been
                // rendered. This is ideal for most text / status overlays, as well as
                // direct cursor feedback.
                this.camPassEdScreen = new RenderStep
                {
                    Id             = "EditorGizmoScreenOverlay",
                    Projection     = ProjectionMode.Screen,
                    ClearFlags     = ClearFlag.None,
                    VisibilityMask = VisibilityFlag.ScreenOverlay
                };
            }

            Control control = this.RenderableSite.Control;

            control.Paint                          += this.RenderableControl_Paint;
            control.MouseDown                      += this.RenderableControl_MouseDown;
            control.MouseUp                        += this.RenderableControl_MouseUp;
            control.MouseMove                      += this.RenderableControl_MouseMove;
            control.MouseWheel                     += this.RenderableControl_MouseWheel;
            control.MouseLeave                     += this.RenderableControl_MouseLeave;
            control.KeyDown                        += this.RenderableControl_KeyDown;
            control.KeyUp                          += this.RenderableControl_KeyUp;
            control.GotFocus                       += this.RenderableControl_GotFocus;
            control.LostFocus                      += this.RenderableControl_LostFocus;
            control.DragDrop                       += this.RenderableControl_DragDrop;
            control.DragEnter                      += this.RenderableControl_DragEnter;
            control.DragLeave                      += this.RenderableControl_DragLeave;
            control.DragOver                       += this.RenderableControl_DragOver;
            control.Resize                         += this.RenderableControl_Resize;
            this.View.PerspectiveChanged           += this.View_FocusDistChanged;
            this.View.CurrentCameraChanged         += this.View_CurrentCameraChanged;
            DualityEditorApp.UpdatingEngine        += this.DualityEditorApp_UpdatingEngine;
            DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged;

            Scene.Leaving += this.Scene_Changed;
            Scene.Entered += this.Scene_Changed;
            Scene.GameObjectParentChanged += this.Scene_Changed;
            Scene.GameObjectsAdded        += this.Scene_Changed;
            Scene.GameObjectsRemoved      += this.Scene_Changed;
            Scene.ComponentAdded          += this.Scene_Changed;
            Scene.ComponentRemoving       += this.Scene_Changed;

            if (Scene.Current != null)
            {
                this.Scene_Changed(this, EventArgs.Empty);
            }

            this.OnCurrentCameraChanged(new CamView.CameraChangedEventArgs(null, this.CameraComponent));
            this.UpdateFormattedTextRenderers();

            if (this.IsViewVisible)
            {
                this.OnShown();
            }
        }
Esempio n. 21
0
    public void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        int width  = source.width;
        int height = source.height;

        if (DownSample)
        {
            if (source.height > MaxRenderTextureHeight)
            {
                float aspect = 1f * source.width / source.height;
                width  = (int)(MaxRenderTextureHeight * aspect);
                height = MaxRenderTextureHeight;
            }
        }

        if (Rt0 == null || Rt0.width != width || Rt0.height != height)
        {
            DestroyImmediate(Rt0);
            Rt0            = new RenderTexture(width, height, 24, RenderTextureFormat.Default);
            Rt0.filterMode = FilterMode.Bilinear;
        }

        if (Rt1 == null || Rt1.width != width || Rt1.height != height)
        {
            DestroyImmediate(Rt1);
            Rt1            = new RenderTexture(width, height, 24, RenderTextureFormat.Default);
            Rt1.filterMode = FilterMode.Bilinear;
        }


        switch (_renderStep)
        {
        case RenderStep.Rt0:
            //用于blend的texture进行down sample
            //blurbuffer = RenderTexture.GetTemporary(Rt1.width / 4, Rt1.height / 4, 0);
            //Graphics.Blit(Rt1, blurbuffer);

            _frameBlendMaterial.SetTexture("_BlendTex", Rt1);
            _frameBlendMaterial.SetFloat("_BlendRatio", BlendRatio);

            Graphics.Blit(Rt0, destination, _frameBlendMaterial);
            _renderStep = RenderStep.Rt0ToRt1;
            //RenderTexture.ReleaseTemporary(blurbuffer);
            break;

        case RenderStep.Rt0ToRt1:
            //用于blend的texture进行down sample
            //blurbuffer = RenderTexture.GetTemporary(Rt0.width/4, Rt0.height/4, 0);
            //Graphics.Blit(Rt0, blurbuffer);

            _frameBlendMaterial.SetTexture("_BlendTex", Rt0);
            _frameBlendMaterial.SetFloat("_BlendRatio", 1 - BlendRatio);

            Graphics.Blit(Rt1, destination, _frameBlendMaterial);
            _renderStep = RenderStep.Rt1;
            //RenderTexture.ReleaseTemporary(blurbuffer);
            break;

        case RenderStep.Rt1:
            //用于blend的texture进行down sample
            //				blurbuffer = RenderTexture.GetTemporary(Rt0.width / 4, Rt0.height / 4, 0);
            //				Graphics.Blit(Rt0, blurbuffer);

            _frameBlendMaterial.SetTexture("_BlendTex", Rt0);
            _frameBlendMaterial.SetFloat("_BlendRatio", BlendRatio);

            Graphics.Blit(Rt1, destination, _frameBlendMaterial);
            _renderStep = RenderStep.Rt1ToRt0;
            //				RenderTexture.ReleaseTemporary(blurbuffer);
            break;

        case RenderStep.Rt1ToRt0:
            //用于blend的texture进行down sample
            //blurbuffer = RenderTexture.GetTemporary(Rt1.width / 4, Rt1.height / 4, 0);
            //Graphics.Blit(Rt1, blurbuffer);

            _frameBlendMaterial.SetTexture("_BlendTex", Rt1);
            _frameBlendMaterial.SetFloat("_BlendRatio", 1 - BlendRatio);

            Graphics.Blit(Rt0, destination, _frameBlendMaterial);
            _renderStep = RenderStep.Rt0;
            //				RenderTexture.ReleaseTemporary(blurbuffer);
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Esempio n. 22
0
 public void PrepareClearColor(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     step.ClearColor = m_enemiesPaused ? Color.White : Color.Black;
 }
Esempio n. 23
0
 public void PrepareShadowEffect(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     step.Skip = !((CurrentLevelType == GameTypes.LevelType.DUNGEON || Game.PlayerStats.Traits.X == 35f || Game.PlayerStats.Traits.Y == 35f) && (Game.PlayerStats.Class != 13 || Game.PlayerStats.Class == 13 && !Player.LightOn));
 }
Esempio n. 24
0
 public void DrawStep11(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     m_blackBorder1.Draw(camera);
     m_blackBorder2.Draw(camera);
 }
Esempio n. 25
0
 public void DrawStep12(Camera2D camera, RenderStep step, GameTime gameTime)
 {
     camera.Draw(m_finalRenderTarget, Vector2.Zero, new Color(180, 150, 80));
     m_creditsText.Draw(camera);
     m_creditsTitleText.Draw(camera);
 }