private void updatePointShadows(PointLightRenderer r, FrustumCullerView[] views)
        {
            int num = 0;

            r.UpdateShadowMap(delegate(CustomCamera lightCamera)
            {
                var view = views[num];
                num++;
                var oldCam  = game.Camera;
                game.Camera = lightCamera;
                //TODO: fix culling+removing of elements
                //view.UpdateVisibility(lightCamera.ViewProjection);
                //setMeshRendererVisibles(view);
                meshesRenderer.DrawShadowCastersDepth();
                game.Camera = oldCam;
            });
        }
예제 #2
0
        public void TestPointLightRendererShadowing()
        {
            var game = new DX11Game();

            game.InitDirectX();
            var device  = game.Device;
            var context = device.ImmediateContext;

            var filledGBuffer = new TestFilledGBuffer(game, 800, 600);

            var light = new PointLightRenderer(game, filledGBuffer.GBuffer);

            light.LightRadius *= 2;

            light.ShadowsEnabled = true;

            var toggle = false;


            game.GameLoopEvent += delegate
            {
                filledGBuffer.DrawUpdatedGBuffer();

                light.UpdateShadowMap(delegate(CustomCamera lightCamera)
                {
                    game.Camera = lightCamera;

                    filledGBuffer.Draw();

                    game.Camera = game.SpectaterCamera;
                });


                game.SetBackbuffer();

                if (game.Keyboard.IsKeyPressed(Key.C))
                {
                    toggle = !toggle;
                }

                if (toggle)
                {
                    light.LightPosition = game.SpectaterCamera.CameraPosition;
                }


                if (game.Keyboard.IsKeyDown(Key.I))
                {
                    GBufferTest.DrawGBuffer(game, filledGBuffer.GBuffer);
                }
                else
                {
                    light.Draw();
                    //game.TextureRenderer.Draw(light.ShadowCubeMapRv, new Vector2(10, 10), new Vector2(300, 300));
                    for (int i = 0; i < 6; i++)
                    {
                        game.LineManager3D.AddViewFrustum(light.LightCameras[i].ViewProjection,
                                                          new Color4(0, 1, 0));
                    }
                }
            };

            game.Run();
        }