Ejemplo n.º 1
0
        public ShadowMapper()
        {
            CubeHighQuality   = new CubeMapDepthFramebuffer(1024, 1024);
            CubeMediumQuality = new CubeMapDepthFramebuffer(512, 512);
            CubeLowQuality    = new CubeMapDepthFramebuffer(256, 256);

            SpotHighQuality   = new Framebuffer(1024, 1024, true);
            SpotMediumQuality = new Framebuffer(1024, 1024, true);
            SpotLowQuality    = new Framebuffer(512, 512, true);

            SingleCamera = new Camera(Vector3.Zero, Vector3.One, Vector2.One, 0.01f, 100.0f);
        }
Ejemplo n.º 2
0
        public void MapCube(ShadowMapQuality quality, TransformationManager transformation, float cutoff)
        {
            Camera last = Camera.Current;
            CubeMapDepthFramebuffer cfb = null;

            if (quality == ShadowMapQuality.High)
            {
                cfb = CubeHighQuality;
            }
            if (quality == ShadowMapQuality.Medium)
            {
                cfb = CubeMediumQuality;
            }
            if (quality == ShadowMapQuality.Low)
            {
                cfb = CubeLowQuality;
            }
            cfb.UpdateFarPlane(cutoff);

            cfb.Use();
            cfb.Clear();
            cfb.SetPosition(transformation.Position);

            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapPositiveX);
            RenderWorld();
            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapPositiveY);
            RenderWorld();
            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapPositiveZ);
            RenderWorld();

            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapNegativeX);
            RenderWorld();
            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapNegativeY);
            RenderWorld();
            cfb.SwitchCameraAndFace(OpenTK.Graphics.OpenGL4.TextureTarget.TextureCubeMapNegativeZ);
            RenderWorld();

            Camera.Current = last;
        }