예제 #1
0
        public override void compute(Texture tex_color_front, Texture tex_color_back)
        {
            Depth.setMask(false);
            Depth.disableTest();
            Blend.enable();

            _fbo_blend.bind();
            Buffer.draw(DrawBufferMode.ColorAttachment0);
            Blend.equation(BlendEquationMode.FuncAdd);
            Blend.funcSeparate(BlendingFactorSrc.DstAlpha, BlendingFactorDest.One, BlendingFactorSrc.Zero, BlendingFactorDest.OneMinusSrcAlpha);
            {
                Texture.rendering.use();
                {
                    Texture.active(TextureUnit.Texture0); tex_color_front.bind();
                    Texture.image.draw();
                }
                Shading.close();
            }

            Buffer.draw(DrawBufferMode.ColorAttachment1);
            Blend.equation(BlendEquationMode.FuncAdd);
            Blend.func(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha);
            {
                Texture.rendering.use();
                {
                    Texture.active(TextureUnit.Texture0); tex_color_back.bind();
                    Texture.image.draw();
                }
                Shading.close();
            }

            Blend.disable();
            Depth.enableTest();
            Depth.setMask(true);
        }
예제 #2
0
        public override void draw(bool useTexture)
        {
            _fbo_color.bind();
            Depth.clear();
            Buffer.draw(DrawBufferMode.ColorAttachment0);
            Buffer.clear(0, 0, 0, 0);

            _rendering.use();
            {
                Texture.active(TextureUnit.Texture0); _tex_blend.bind();
                if (useTexture)
                {
                    Texture.active(TextureUnit.Texture1);
                    Example._scene.backgroundTexture.bind();
                    Texture.sampler.bind(1);
                }
                else
                {
                    _rendering.bindUniform4("color_background", Example._scene.backgroundColor);
                }
                _rendering.bindUniform1("useTexture", useTexture ? 1 : 0);
                Texture.image.draw();
            }
            Shading.close();

            FrameBuffer.unbind();
            Buffer.draw(DrawBufferMode.Back);

            Depth.clear();
            Buffer.clear(0, 0, 0, 0);
            _tex_color.draw();
        }
예제 #3
0
        public void compute()
        {
            _fbo.bind();
            Buffer.draw(DrawBufferMode.ColorAttachment0);
            Buffer.setMask(0, true, false, false, false);
            Buffer.clear(0, 0, 0, 0);

            Depth.disableTest();
            Depth.setMask(false);
            Blend.equation(BlendEquationMode.FuncAdd);
            Blend.func(BlendingFactorSrc.One, BlendingFactorDest.One);
            Blend.enable();

            Example._scene.thickComputing.use();
            {
                Matrix4 tr = Example._scene.meshAnimation.pose.transformation_matrix;
                Example._scene.thickComputing.bindUniformMatrix4("transformation_matrix", false, ref tr);
                Example._scene.meshAnimation.pose.drawElements();
            }
            Shading.close();

            Blend.disable();
            Depth.enableTest();
            Depth.setMask(true);
            Buffer.setMask(0, true, true, true, true);

            FrameBuffer.unbind();
            Buffer.draw(DrawBufferMode.Back);
        }
예제 #4
0
 public void updateShaders(ref Shading rendering)
 {
     rendering.use();
     {
         // Depth
         //   if (_camera.inverseZ)
         {
             //     rendering.bindUniform1("zNear", _camera.zFar);
             //   rendering.bindUniform1("zFar", _camera.zNear);
         }
         //else
         {
             rendering.bindUniform1("zNear", _camera.zNear);
             rendering.bindUniform1("zFar", _camera.zFar);
         }
         // Clipping
         rendering.bindUniform1("cappingPlane", _multiFragmentRendering.cappingPlane);
         rendering.bindUniform1("cappingAngle", _multiFragmentRendering.cappingAngle);
         // Gamma
         rendering.bindUniform1("gamma", _gamma);
         // Light
         rendering.bindBuffer(1, "Light", _light.buffer.index, BufferRangeTarget.UniformBuffer);
         rendering.bindUniform1("IlluminationMode", (int)_illuminationMode);
     }
     Shading.close();
 }
예제 #5
0
 public void draw()
 {
     Texture._rendering.use();
     {
         Texture.active(TextureUnit.Texture0); bind();
         Texture._image.draw();
         unbind();
     }
     Shading.close();
 }
예제 #6
0
 public void drawB()
 {
     Texture._rendering_background.use();
     {
         Texture.active(TextureUnit.Texture0);
         bind();
         Texture.sampler.bind(0);
         Texture._image.draw();
         unbind();
     }
     Shading.close();
 }
예제 #7
0
        protected override void initShaders()
        {
            _init = new Shader("rendering/transparency/wsum/init", ShaderType.FragmentShader);
            _init.complile(ShaderType.FragmentShader);

            _initing = new Shading();
            _initing.create();
            if (Example._scene.tessellation)
            {
                _initing.attachShader(Example._scene.renderVertexTess.id);
                _initing.attachShader(Example._scene.renderTessellationControl.id);
                _initing.attachShader(Example._scene.renderTessellationEvaluation.id);
            }
            else
            {
                _initing.attachShader(Example._scene.renderVertex.id);
            }

            _initing.attachShader(Example._scene.renderGeometry.id);
            _initing.attachShader(Example._scene.phongFragment.id);
            _initing.attachShader(Example._scene.computePixelColor.id);
            _initing.attachShader(_init.id);
            _initing.link();

            _initing.use();
            {
                _initing.bindBuffer(0, "Camera", Example._scene.camera.buffer.index, BufferRangeTarget.UniformBuffer);
                _initing.bindBuffer(1, "Light", Example._scene.light.buffer.index, BufferRangeTarget.UniformBuffer);
            }
            Shading.close();

            _render = new Shader("rendering/transparency/wsum/render", ShaderType.FragmentShader);
            _render.complile(ShaderType.FragmentShader);

            _rendering = new Shading();
            _rendering.create();
            _rendering.attachShader(Texture.vertex.id);
            _rendering.attachShader(_render.id);
            _rendering.link();

            _rendering.use();
            {
                _rendering.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);

                _rendering.bindUniform1("width", Example._scene.width);
                _rendering.bindUniform1("height", Example._scene.height);
            }
            Shading.close();
        }
예제 #8
0
        protected override void initShaders()
        {
            _render = new Shader("rendering/transparency/wsum/dual/render", ShaderType.FragmentShader);
            _render.complile(ShaderType.FragmentShader);

            _rendering = new Shading();
            _rendering.create();
            _rendering.attachShader(Texture.vertex.id);
            _rendering.attachShader(_render.id);
            _rendering.link();

            _rendering.use();
            {
                _rendering.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
            }
            Shading.close();
        }
예제 #9
0
        public void computeDUAL(ref Texture tex_depth)
        {
            _fbo_dual.bind();
            Buffer.draw(DrawBufferMode.ColorAttachment0 + _currID);
            Buffer.setMask(_currID, true, true, true, false);
            Buffer.clear(0, 0, 0, 0);

            Example._scene.thickComputing_dual.use();
            {
                Example._scene.thickComputing_dual.bindUniform1("layers", _currID);
                Texture.active(TextureUnit.Texture0); tex_depth.bind();
                Texture.active(TextureUnit.Texture1); _tex_dual[1 - _currID].bind();
                Texture.image.draw();
            }
            Shading.close();

            Buffer.setMask(_currID, true, true, true, true);
            _currID = 1 - _currID;
        }
예제 #10
0
 public void computeK_Buffer(ref Texture tex_depth, bool stencil, bool k_multi)
 {
     if (stencil)
     {
         Example._scene.thickComputing_k_stencil_buffer.use();
     }
     else if (k_multi)
     {
         Example._scene.thickComputing_k_multi_buffer_Z.use();
     }
     else
     {
         Example._scene.thickComputing_k_buffer.use();
     }
     {
         Texture.active(TextureUnit.Texture0);
         tex_depth.bind();
         Texture.image.draw();
     }
     Shading.close();
 }
예제 #11
0
        public override void draw(bool useTexture)
        {
            _fbo_color.bind();
            Depth.clear();
            Buffer.draw(DrawBufferMode.ColorAttachment0);
            Buffer.clear(0, 0, 0, 0);

            _rendering.use();
            {
                Texture.active(TextureUnit.Texture0); _tex_blend.bind();
                Texture.active(TextureUnit.Texture1); _tex_back.bind();
                Texture.image.draw();
            }
            Shading.close();

            FrameBuffer.unbind();
            Buffer.draw(DrawBufferMode.Back);

            Depth.clear();
            Buffer.clear(0, 0, 0, 0);
            _tex_color.draw();
        }
예제 #12
0
        static Texture()
        {
            _image   = new Image();
            _sampler = new Sampler();

            //--- final pass Shader
            _vertex   = new Shader("image/render", ShaderType.VertexShader);
            _fragment = new Shader("image/render", ShaderType.FragmentShader);

            _vertex.complile(ShaderType.VertexShader);
            _fragment.complile(ShaderType.FragmentShader);

            _rendering = new Shading();
            _rendering.create();
            _rendering.attachShader(_vertex.id);
            _rendering.attachShader(_fragment.id);
            _rendering.link();

            modelview_matrix = Matrix4.CreateOrthographicOffCenter(0, 1, 0, 1, -1, 1);

            _rendering.use();
            {
                _rendering.bindUniformMatrix4("modelview_matrix", false, ref modelview_matrix);
                int _multisamples = 8;
                //GL.GetInteger(GetPName.MaxSamples, out _multisamples);
                _rendering.bindUniform1("samples", _multisamples);
            }
            Shading.close();

            _fragment_background = new Shader("image/render_background", ShaderType.FragmentShader);
            _fragment_background.complile(ShaderType.FragmentShader);

            _rendering_background = new Shading();
            _rendering_background.create();
            _rendering_background.attachShader(_vertex.id);
            _rendering_background.attachShader(_fragment_background.id);
            _rendering_background.link();

            _rendering_background.use();
            {
                _rendering_background.bindUniformMatrix4("modelview_matrix", false, ref modelview_matrix);

                _rendering_background.bindUniform1("width", Example._scene.width);
                _rendering_background.bindUniform1("height", Example._scene.height);
            }
            Shading.close();

            _copy = new Shader("image/copy", ShaderType.FragmentShader);
            _copy.complile(ShaderType.FragmentShader);

            _copying = new Shading();
            _copying.create();
            _copying.attachShader(_vertex.id);
            _copying.attachShader(_copy.id);
            _copying.link();

            _copying.use();
            {
                _copying.bindUniformMatrix4("modelview_matrix", false, ref modelview_matrix);
            }
            Shading.close();
        }
예제 #13
0
        public void initShaders()
        {
            // Render Shaders
            {
                _renderVertex          = new Shader("rendering/render", ShaderType.VertexShader);
                _renderVertexRegions   = new Shader("rendering/render_regions", ShaderType.VertexShader);
                _renderGeometry        = new Shader("rendering/render", ShaderType.GeometryShader);
                _renderGeometryRegions = new Shader("rendering/render_regions", ShaderType.GeometryShader);
                _renderFragment        = new Shader("rendering/render", ShaderType.FragmentShader);
                _renderFragmentRegions = new Shader("rendering/render_regions", ShaderType.FragmentShader);
                _phongFragment         = new Shader("rendering/illumination", ShaderType.FragmentShader);
                _computePixelColor     = new Shader("rendering/compute_pixel_color", ShaderType.FragmentShader);

                _renderVertex.complile(ShaderType.VertexShader);
                _renderVertexRegions.complile(ShaderType.VertexShader);
                _renderGeometry.complile(ShaderType.GeometryShader);
                _renderGeometryRegions.complile(ShaderType.GeometryShader);
                _phongFragment.complile(ShaderType.FragmentShader);
                _computePixelColor.complile(ShaderType.FragmentShader);
                _renderFragment.complile(ShaderType.FragmentShader);
                _renderFragmentRegions.complile(ShaderType.FragmentShader);
            }

            // Tessellated Render Shaders
            if (_tessellation)
            {
                GL.PatchParameter(PatchParameterInt.PatchVertices, 3);
                //float PatchInnerLevel = 1.0f;
                //float PatchOuterLevel = 1.0f;
                //GL.PatchParameter(PatchParameterFloat.PatchDefaultInnerLevel, ref PatchInnerLevel);
                //GL.PatchParameter(PatchParameterFloat.PatchDefaultOuterLevel, ref PatchOuterLevel);

                _renderVertexTess = new Shader("rendering/render_tess", ShaderType.VertexShader);
                _renderVertexTess.complile(ShaderType.VertexShader);

                _renderTessellationControl = new Shader("Control/render", ShaderType.TessControlShader);
                _renderTessellationControl.complile(ShaderType.TessControlShader);

                _renderTessellationEvaluation = new Shader("Evaluation/render", ShaderType.TessEvaluationShader);
                _renderTessellationEvaluation.complile(ShaderType.TessEvaluationShader);
            }
            // AABB-ConvexHull Shaders
            {
                _aabb_chVertex   = new Shader("aabb-ch/render", ShaderType.VertexShader);
                _aabb_chFragment = new Shader("aabb-ch/render", ShaderType.FragmentShader);

                _aabb_chVertex.complile(ShaderType.VertexShader);
                _aabb_chFragment.complile(ShaderType.FragmentShader);

                _aabb_chRendering = new Shading();
                _aabb_chRendering.create();
                _aabb_chRendering.attachShader(_aabb_chVertex.id);
                _aabb_chRendering.attachShader(_aabb_chFragment.id);
                _aabb_chRendering.link();
                _aabb_chRendering.use();
                {
                    _aabb_chRendering.bindBuffer(0, "Camera", _camera.buffer.index, BufferRangeTarget.UniformBuffer);
                }
                Shading.close();
            }
            // Sphere Shaders
            {
                _sphereVertex   = new Shader("sphere/render", ShaderType.VertexShader);
                _sphereFragment = new Shader("sphere/render", ShaderType.FragmentShader);

                _sphereVertex.complile(ShaderType.VertexShader);
                _sphereFragment.complile(ShaderType.FragmentShader);

                _sphereRendering = new Shading();
                _sphereRendering.create();
                _sphereRendering.attachShader(_sphereVertex.id);
                _sphereRendering.attachShader(_sphereFragment.id);
                _sphereRendering.link();
                _sphereRendering.use();
                {
                    _sphereRendering.bindBuffer(0, "Camera", _camera.buffer.index, BufferRangeTarget.UniformBuffer);
                }
                Shading.close();
            }

            // Thickness Shaders
            {
                _thickVertex = new Shader("rendering/translucency/compute", ShaderType.VertexShader);
                _thickVertex.complile(ShaderType.VertexShader);
                _thickCompute = new Shader("rendering/translucency/compute", ShaderType.FragmentShader);
                _thickCompute.complile(ShaderType.FragmentShader);

                _thickComputing = new Shading();
                _thickComputing.create();
                _thickComputing.attachShader(_thickVertex.id);
                _thickComputing.attachShader(_thickCompute.id);
                _thickComputing.link();

                _thickComputing.use();
                {
                    _thickComputing.bindBuffer(0, "Camera", _camera.buffer.index, BufferRangeTarget.UniformBuffer);
                }
                Shading.close();
#if peel
                _thickCompute_f2b = new Shader("rendering/translucency/f2b/compute", ShaderType.FragmentShader);
                _thickCompute_f2b.complile(ShaderType.FragmentShader);

                _thickComputing_f2b = new Shading();
                _thickComputing_f2b.create();
                _thickComputing_f2b.attachShader(Texture.vertex.id);
                _thickComputing_f2b.attachShader(_thickCompute_f2b.id);
                _thickComputing_f2b.link();

                _thickComputing_f2b.use();
                {
                    _thickComputing_f2b.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
                }
                Shading.close();

                _thickCompute_dual = new Shader("rendering/translucency/dual/compute", ShaderType.FragmentShader);
                _thickCompute_dual.complile(ShaderType.FragmentShader);

                _thickComputing_dual = new Shading();
                _thickComputing_dual.create();
                _thickComputing_dual.attachShader(Texture.vertex.id);
                _thickComputing_dual.attachShader(_thickCompute_dual.id);
                _thickComputing_dual.link();

                _thickComputing_dual.use();
                {
                    _thickComputing_dual.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
                }
                Shading.close();

                _thickCompute_k_buffer = new Shader("rendering/translucency/k_buffer/compute", ShaderType.FragmentShader);
                _thickCompute_k_buffer.complile(ShaderType.FragmentShader);

                _thickComputing_k_buffer = new Shading();
                _thickComputing_k_buffer.create();
                _thickComputing_k_buffer.attachShader(Texture.vertex.id);
                _thickComputing_k_buffer.attachShader(_thickCompute_k_buffer.id);
                _thickComputing_k_buffer.link();

                _thickComputing_k_buffer.use();
                {
                    _thickComputing_k_buffer.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
                }
                Shading.close();

                _thickCompute_k_multi_buffer_Z = new Shader("rendering/translucency/k_multi_buffer_Z/compute", ShaderType.FragmentShader);
                _thickCompute_k_multi_buffer_Z.complile(ShaderType.FragmentShader);

                _thickComputing_k_multi_buffer_Z = new Shading();
                _thickComputing_k_multi_buffer_Z.create();
                _thickComputing_k_multi_buffer_Z.attachShader(Texture.vertex.id);
                _thickComputing_k_multi_buffer_Z.attachShader(_thickCompute_k_multi_buffer_Z.id);
                _thickComputing_k_multi_buffer_Z.link();

                _thickComputing_k_multi_buffer_Z.use();
                {
                    _thickComputing_k_multi_buffer_Z.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
                }
                Shading.close();

                _thickCompute_k_stencil_buffer = new Shader("rendering/translucency/k_stencil_buffer/compute", ShaderType.FragmentShader);
                _thickCompute_k_stencil_buffer.complile(ShaderType.FragmentShader);

                _thickComputing_k_stencil_buffer = new Shading();
                _thickComputing_k_stencil_buffer.create();
                _thickComputing_k_stencil_buffer.attachShader(Texture.vertex.id);
                _thickComputing_k_stencil_buffer.attachShader(_thickCompute_k_stencil_buffer.id);
                _thickComputing_k_stencil_buffer.link();

                _thickComputing_k_stencil_buffer.use();
                {
                    _thickComputing_k_stencil_buffer.bindUniformMatrix4("modelview_matrix", false, ref Texture.modelview_matrix);
                }
                Shading.close();
#endif
            }
        }