示例#1
0
        /// <summary>
        /// Called when starting the scene
        /// </summary>
        public override void OnStart()
        {
            Current            = this;
            TriangleRenderPass = new BasicRenderPass(Graphics);
            ClearEffect        = new ClearEffect(Graphics, TriangleRenderPass);
            ClearEffect.Start();
            ClearEffect.ClearColor = new ClearColorValue(0.5f, 0.7f, 0.9f);
            TimerHandler           = new TimerHandler(this);
            PlayerHandler          = new PlayerInterfaceHandler(1);
            BulletHandler          = new BulletHandler(this, 200000, ClearEffect);
            BulletHandler.Start();
            EnemyHandler = new EnemyHandler(this, 10000, BulletHandler.SpriteEffect);
            EnemyHandler.Start();

            ScriptHandler.ExecuteFile("demo.nut");
            ScriptHandler.CallGlobal("main");
        }
示例#2
0
        public DeferredColoredChunkRenderer(EngineConfiguration config, ContentLibrary contentLibrary, GraphicsDevice device, CameraManager cameraManager, IChunkManager chunkManager)
        {
            _device = device;
            _sb     = new SpriteBatch(_device);

            _halfPixel = new Vector2(0.5f / _device.PresentationParameters.BackBufferWidth, 0.5f / _device.PresentationParameters.BackBufferHeight);

            _quadRenderer = new QuadRenderer(_device);

            _clearEffect            = new ClearEffect(contentLibrary.ClearEffect);
            _renderGBufferEffect    = new RenderGBufferColorEffect(contentLibrary.RenderGBufferColorEffect);
            _renderCombineEffect    = new RenderCombineEffect(contentLibrary.RenderCombineEffect);
            _directionalLightEffect = new DirectionalLightEffect(contentLibrary.DirectionalLightEffect);
            _pointLightEffect       = new PointLightEffect(contentLibrary.PointLightEffect);
            _ssaoEffect             = new SSAOEffect(contentLibrary.SSAOEffect);

            _camManager = cameraManager;
            _chunks     = chunkManager;

            _debugOptions = ChunkRendererDebugOptions.NONE;

            basicEffect = contentLibrary.BasicEffect;

            _uiFontTiny = contentLibrary.UIFontTiny;

            _albedoTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
            _lightTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _normalTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _depthTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8);

            _randomMap = new Texture2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight);
            CreateRandomNormalTexture(_randomMap);

            _debugRasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.None, FillMode = Microsoft.Xna.Framework.Graphics.FillMode.WireFrame
            };
            _rasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.CullCounterClockwiseFace
            };
        }
示例#3
0
        /// <summary>
        /// Called when starting the scene
        /// </summary>
        public override void OnStart()
        {
            // Create render pass
            TriangleRenderPass = new BasicRenderPass(Graphics);
            // Create and start a clear effect
            ClearEffect = new ClearEffect(Graphics, TriangleRenderPass);
            ClearEffect.Start();
            ClearEffect.ClearColor = new ClearColorValue(0.5f, 0.7f, 0.9f);
            // Create and start triangle effect
            SpriteEffect = new SpriteEffect(
                Graphics,
                TriangleRenderPass,
                2000,
                ClearEffect.FinalLayout,
                ClearEffect.FinalAccess,
                ClearEffect.FinalStage
                );
            SpriteEffect.Start();
            var rand  = new Random();
            var tex   = Content["TriangleTexture"] as Texture2D;
            var anims = new[] {
                new Animation(new[] {
                    Animation.Instruction.SetRotation(0f, 0f),
                    Animation.Instruction.SetScale(0f, new Vector2(12f, 12f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(30f, 10f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(1f, 1f, new Vector2(8f, 20f)),
                    Animation.Instruction.LerpRotation(1f, 1f, 1f),
                    Animation.Instruction.SetRectangle(1f, new Vector2(0.6f, 0.6f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(2f, 1f, new Vector2(12f, 12f)),
                    Animation.Instruction.LerpRotation(2f, 1f, 0f),
                    Animation.Instruction.None(3f)
                }),
                new Animation(new[] {
                    Animation.Instruction.SetScale(0f, new Vector2(26f, 26f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(8f, 30f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(0.7f, 1f, new Vector2(20f, 8f)),
                    Animation.Instruction.SetRectangle(0.7f, new Vector2(0f, 0f), new Vector2(0.5f, 0.5f)),
                    Animation.Instruction.LerpScale(1.4f, 1f, new Vector2(26f, 26f)),
                    Animation.Instruction.None(2.141f)
                }),
                new Animation(new[] {
                    Animation.Instruction.SetScale(0f, new Vector2(26f, 26f)),
                    Animation.Instruction.LerpScale(0f, 1f, new Vector2(8f, 30f)),
                    Animation.Instruction.SetRectangle(0f, new Vector2(0f, 0f), new Vector2(1f, 1f)),
                    Animation.Instruction.LerpScale(1.861f, 1f, new Vector2(20f, 8f)),
                    Animation.Instruction.SetRectangle(1.861f, new Vector2(0f, 0f), new Vector2(0.5f, 0.5f)),
                    Animation.Instruction.LerpScale(3f, 1f, new Vector2(26f, 26f)),
                    Animation.Instruction.None(5.12f)
                })
            };

            for (var i = 0; i < 2000; i++)
            {
                var vel = new Vector3(
                    -75f + (float)rand.NextDouble() * 150f,
                    -75f + (float)rand.NextDouble() * 150f,
                    0f
                    );
                var pos = new Vector3(
                    -100f + (float)rand.NextDouble() * 200f,
                    -100f + (float)rand.NextDouble() * 200f,
                    -1f + (float)rand.NextDouble() * 2f
                    );
                new SpriteInstance(
                    SpriteEffect,
                    pos,
                    vel,
                    new Vector2(32, 32),
                    tex,
                    new Vector4(0, 0, 32f / tex.Image.Extent.Width, 32f / tex.Image.Extent.Height),
                    anims[i % 3]
                    );
            }
            TransitionEffect = new TransitionEffect(
                Graphics,
                SpriteEffect.FinalLayout,
                SpriteEffect.FinalAccess,
                SpriteEffect.FinalStage,
                ImageLayout.ColorAttachmentOptimal,
                Accesses.MemoryRead,
                PipelineStages.BottomOfPipe
                );
            TransitionEffect.Start();
        }
示例#4
0
 private void Start()
 {
     clearEffect = new ClearEffect(AreaClearEffect, StageClearEffect, StageClearText);
 }