Esempio n. 1
0
        protected override void DoRender(RenderEventArgs arg)
        {
            this.SetUniform("renderWireframe", false);
            base.DoRender(arg);

            polygonModeSwitch.On();
            lineWidthSwitch.On();
            // offsetSwitch.On();
            this.SetUniform("renderWireframe", true);
            base.DoRender(arg);
            //offsetSwitch.Off();
            lineWidthSwitch.Off();
            polygonModeSwitch.Off();
        }
Esempio n. 2
0
        public void ExtrudeShadow(ShadowVolumeExtrudeEventArgs arg)
        {
            ICamera camera     = arg.Camera;
            mat4    projection = camera.GetProjectionMatrix();
            mat4    view       = camera.GetViewMatrix();
            mat4    model      = this.GetModelMatrix();

            var           method  = this.RenderUnit.Methods[(int)MethodName.extrudeShadow];
            ShaderProgram program = method.Program;

            program.SetUniform("gProjectionView", projection * view);
            program.SetUniform("gWorld", model);
            if (arg.Light is DirectionalLight)
            {
                var light = arg.Light as DirectionalLight;
                program.SetUniform("gLightPos", light.Direction);
                program.SetUniform("farAway", true);
            }
            else
            {
                program.SetUniform("gLightPos", arg.Light.Position);
                program.SetUniform("farAway", false);
            }

            // light info.
            directionalLight.SetBlinnPhongUniforms(program);
            // material.
            program.SetUniform("material.diffuse", new vec3(1, 0, 0));  //this.Color);
            program.SetUniform("material.specular", new vec3(1, 0, 0)); //this.Color);
            program.SetUniform("material.shiness", this.Shiness);

            fillFarOffsetSwitch.On();
            program.SetUniform("wireframe", false);
            method.Render();
            fillFarOffsetSwitch.Off();

            polygonModeSwitch.On();
            lineWidthSwitch.On();
            program.SetUniform("wireframe", true);
            method.Render();
            lineWidthSwitch.Off();
            polygonModeSwitch.Off();
        }