Ejemplo n.º 1
0
        protected override void InitializeService()
        {
            if (RenderStack.Graphics.Configuration.canUseFramebufferObject)
            {
                framebuffer = FramebufferFactory.Create(size, size);
                framebuffer.AttachTexture(
                    FramebufferAttachment.ColorAttachment0,
                    PixelFormat.Red,
                    PixelInternalFormat.Rgb8
                    //PixelInternalFormat.R8
                    //PixelInternalFormat.Rgb32f
                    );
                framebuffer.AttachRenderBuffer(
                    FramebufferAttachment.DepthAttachment,
                    //PixelFormat.DepthComponent,
                    RenderbufferStorage.DepthComponent24,
                    0
                    );
                framebuffer.Begin();
                framebuffer.Check();
                framebuffer.End();
            }

            camera.Projection.ProjectionType  = ProjectionType.Other;
            camera.Projection.NearParameter.X = 0.01f;
        }
Ejemplo n.º 2
0
        public void CreateWindowSizeResources()
        {
            System.Diagnostics.Debug.WriteLine("CreateWindowSizeResources()");
            @default = FramebufferFactory.Create(window);

            if (Configuration.gammaCorrect)
            {
                bool sRgbEnable = GL.IsEnabled(EnableCap.FramebufferSrgb);

                linear = FramebufferFactory.Create(window.Width, window.Height);

                int samples = 4;

                linear.AttachRenderBuffer(
                    FramebufferAttachment.ColorAttachment0,
                    PixelFormat.Rgb,
                    RenderbufferStorage.Rgb32f,
                    samples
                    );
                linear.AttachRenderBuffer(
                    FramebufferAttachment.DepthAttachment,
                    PixelFormat.DepthComponent,
                    RenderbufferStorage.DepthComponent32,
                    samples
                    );
                linear.Begin();
                linear.Check();
                linear.End();

                multisampleResolve = FramebufferFactory.Create(window.Width, window.Height);
                multisampleResolve.AttachTexture(
                    FramebufferAttachment.ColorAttachment0,
                    PixelFormat.Rgb,
                    PixelInternalFormat.Rgb32f
                    );
                multisampleResolve.Begin();
                multisampleResolve.Check();
                multisampleResolve.End();
            }
            System.Diagnostics.Debug.WriteLine("CreateWindowSizeResources() done");
        }
Ejemplo n.º 3
0
        public void SetLightCount(int n)
        {
            if (n == currentLightCount)
            {
                return;
            }

            currentLightCount = n;

            // \todo if n < currentLightCount ?

            if (RenderStack.Graphics.Configuration.useGl1 == true)
            {
                return;
            }

            if (shadow != null)
            {
                shadow.Dispose();
            }
            shadow = FramebufferFactory.Create(Configuration.shadowResolution, Configuration.shadowResolution);

            if (example.Renderer.Configuration.hardwareShadowPCF)
            {
                shadowAttachment = FramebufferAttachment.DepthAttachment;
                var texture = shadow.AttachTextureArray(
                    FramebufferAttachment.DepthAttachment,
                    PixelFormat.DepthComponent,
                    PixelInternalFormat.DepthComponent,
                    n
                    );
            }
            else
            {
                shadowAttachment = FramebufferAttachment.ColorAttachment0;
                if (
                    (RenderStack.Graphics.Configuration.canUseTextureArrays) &&
                    (RenderStack.Graphics.Configuration.glslVersion >= 330)
                    )
                {
                    shadow.AttachTextureArray(
                        FramebufferAttachment.ColorAttachment0,
                        PixelFormat.Red,
                        //PixelInternalFormat.R16f,
                        PixelInternalFormat.R32f,
                        n
                        );
                }
                else
                {
                    shadow.AttachTexture(
                        FramebufferAttachment.ColorAttachment0,
                        PixelFormat.Red,
                        //PixelInternalFormat.R16f,
                        PixelInternalFormat.R32f
                        );
                }
                shadow.AttachRenderBuffer(
                    FramebufferAttachment.DepthAttachment,
                    //PixelFormat.DepthComponent,
                    RenderbufferStorage.DepthComponent32,
                    0
                    );
            }
            shadow.Begin();
            shadow.Check();
            shadow.End();

            var noShadow = materialManager.Textures["NoShadow"] = new TextureGL(
                1, 1, PixelFormat.Red, PixelInternalFormat.R16f, n
                );

            System.Single[] whiteData = new System.Single[n];
            for (int i = 0; i < n; ++i)
            {
                whiteData[i] = 1.0f;
            }
            noShadow.Upload(whiteData, 0);
        }