Beispiel #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;
        }
Beispiel #2
0
        public void Render(Matrix4 cameraTransform, Group renderGroup)
        {
            renderer.Requested.Viewport = framebuffer.Viewport;

            framebuffer.Begin();
            framebuffer.Check();

            //  \todo Use render state
            GL.Disable(EnableCap.PolygonOffsetFill);

            Vector3 positionInWorld = cameraTransform.TransformPoint(new Vector3(0.0f, 0.0f, 0.0f));

            camera.Frame.Parent = null;
            camera.Frame.LocalToParent.Set(cameraTransform);
            camera.Frame.LocalToWorld.Set(cameraTransform);
            renderer.Requested.Camera = camera;
            //camera.Frame.UpdateHierarchical();

            GL.Viewport(
                (int)renderer.Requested.Viewport.X,
                (int)renderer.Requested.Viewport.Y,
                (int)renderer.Requested.Viewport.Width,
                (int)renderer.Requested.Viewport.Height
                );
            GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);

            /*GL.ClearStencil(0);
             * GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);*/
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            //Renderer.RenderGroupBasic(Renderer.RenderGroup, Renderer.Programs.Hemispherical, MeshMode.PolygonFill);
            renderer.CurrentGroup       = renderGroup;
            renderer.Requested.Program  = null; // \todo fixme renderer.Programs["EqualArea"];
            renderer.Requested.MeshMode = MeshMode.PolygonFill;
            renderer.RenderGroup();

            framebuffer.End();

            Texture.GenerateMipmap();

            //  Area of disk, radius r :  Pi * r * r     =      edge * edge * 0.25 * Pi
            //  Area of texture        :                        edge * edge
            //
            //  Hemispherical disc covers ~0.78 of the texture.
        }
Beispiel #3
0
 private void CreateFramebuffers()
 {
     framebuffer = FramebufferFactory.Create(renderer.Width, renderer.Height);
     framebuffer.AttachRenderBuffer(
         FramebufferAttachment.ColorAttachment0,
         //PixelFormat.RedInteger,
         RenderbufferStorage.R16f,
         0
         );
     framebuffer.AttachRenderBuffer(
         FramebufferAttachment.DepthAttachment,
         //PixelFormat.DepthComponent,
         RenderbufferStorage.DepthComponent32,
         0
         );
     framebuffer.Begin();
     framebuffer.Check();
     framebuffer.End();
 }
Beispiel #4
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");
        }
Beispiel #5
0
        private void CreateFramebuffers()
        {
            if (useFramebuffer == false)
            {
                return;
            }

            framebuffer = FramebufferFactory.Create(renderer.Width, renderer.Height);
            if (RenderStack.Graphics.Configuration.useIntegerPolygonIDs)
            {
                framebuffer.AttachRenderBuffer(
                    FramebufferAttachment.ColorAttachment0,
                    //PixelFormat.RedInteger,
                    RenderbufferStorage.R32ui,
                    0
                    );
            }
            else
            {
                framebuffer.AttachRenderBuffer(
                    FramebufferAttachment.ColorAttachment0,
                    //PixelFormat.Rgb,
                    RenderbufferStorage.Rgb8,
                    0
                    );
            }
            framebuffer.AttachRenderBuffer(
                FramebufferAttachment.DepthAttachment,
                //PixelFormat.DepthComponent,
                RenderbufferStorage.DepthComponent32,
                0
                );
            framebuffer.Begin();
            framebuffer.Check();
            framebuffer.End();
        }
        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);
        }