Beispiel #1
0
 public virtual void CalculateShadows(FrameBuffer fb, Shader depthShader, Action <Shader> render)
 {
     fb.BindTexture(ShadowMap, GLEnum.DepthAttachment);
     depthShader.SetMat4("lightSpace", LightSpace);
     Util.GLClear();
     render(depthShader);
 }
Beispiel #2
0
        public override void CalculateShadows(FrameBuffer fb, Shader shader, Action <Shader> render)
        {
            shader.SetVec3("lightPos", Position);

            for (int i = 0; i < 6; i++)
            {
                fb.BindTexture(ShadowMap, GLEnum.DepthAttachment, GLEnum.TextureCubeMapPositiveX + i);
                Util.GLClear();
                shader.SetMat4("lightSpace", LightSpace * CubeLookAts[i]);
                render(shader);
            }
        }
Beispiel #3
0
        public FrameBuffer Render(FrameBuffer renderFrameBuffer)
        {
            Texture renderTexture = renderFrameBuffer.BoundTexture;

            if (postProcessShaders.Count <= 0)
            {
                return(renderFrameBuffer);
            }


            var destination = texture2;
            var source      = renderTexture;

            for (int i = 0; i < postProcessShaders.Count; i++)
            {
                Shader shader     = postProcessShaders[i];
                bool   lastShader = i >= postProcessShaders.Count - 1;

                if (!lastShader)
                {
                    postProBuffer.Use();
                    postProBuffer.BindTexture(destination);
                }
                else
                {
                    renderFrameBuffer.Use();
                }

                //Util.GLClear();
                source.BindToUnit(0);
                QuadMesh.ScreenQuad.Draw(shader);

                if (lastShader)
                {
                    break;
                }

                if (i == 0)
                {
                    source = texture1;
                }

                var temp = destination;
                destination = source;
                source      = temp;
            }

            return(renderFrameBuffer);
        }