public void RenderAmbientColor(BlinnPhongAmbientEventArgs arg)
        {
            ICamera camera     = arg.Camera;
            mat4    projection = camera.GetProjectionMatrix();
            mat4    view       = camera.GetViewMatrix();
            mat4    model      = this.GetModelMatrix();

            RenderMethod  method  = this.RenderUnit.Methods[0];
            ShaderProgram program = method.Program;

            program.SetUniform("mvpMat", projection * view * model);
            program.SetUniform("ambientColor", arg.Ambient);

            method.Render();
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public void RenderBeforeChildren(RenderEventArgs arg)
        {
            GL.Instance.ClearStencil(0x0);
            GL.Instance.Clear(GL.GL_STENCIL_BUFFER_BIT); // this seems not working. I don't know why.(2017-12-13)
            GL.Instance.Enable(GL.GL_STENCIL_TEST);
            GL.Instance.StencilFunc(GL.GL_ALWAYS, 0, 0xFF);
            GL.Instance.StencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
            GL.Instance.StencilMask(0xFF);
            //GL.Instance.DepthMask(false);
            //GL.Instance.ColorMask(false, false, false, false);

            RenderMethod method = this.RenderUnit.Methods[0];

            method.Render();

            //GL.Instance.ColorMask(true, true, true, true);
            //GL.Instance.DepthMask(true);
        }
Beispiel #3
0
        public void RenderBeforeChildren(RenderEventArgs arg)
        {
            // gets mvpMat.
            ICamera camera        = arg.Camera;
            mat4    projectionMat = camera.GetProjectionMatrix();
            mat4    viewMat       = camera.GetViewMatrix();
            mat4    modelMat      = this.GetModelMatrix();
            mat4    mvpMat        = projectionMat * viewMat * modelMat;
            // a render uint wraps everything(model data, shaders, glswitches, etc.) for rendering.
            ModernRenderUnit unit = this.RenderUnit;
            // gets render method.
            // There could be more than 1 method(vertex shader + fragment shader) to render the same model data. Thus we need an method array.
            RenderMethod method = unit.Methods[0];
            // shader program wraps vertex shader and fragment shader.
            ShaderProgram program = method.Program;

            //set value for 'uniform mat4 mvpMat'; in shader.
            program.SetUniform("mvpMat", mvpMat);
            // render the cube model via OpenGL.
            method.Render();
        }