Beispiel #1
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);// TODO: This is how point light works. I need to deal with directional light, etc.
                program.SetUniform("farAway", false);
            }

            fillFarOffsetState.On();
            method.Render();
            fillFarOffsetState.Off();
        }
Beispiel #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("vpMat", projection * view);
            program.SetUniform("modelMat", model);
            if (arg.Light is DirectionalLight)
            {
                var light = arg.Light as DirectionalLight;
                program.SetUniform("lightPosition", light.Direction);
                program.SetUniform("farAway", true);
            }
            else
            {
                program.SetUniform("lightPosition", 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);

            fillFarOffsetState.On();
            method.Render();
            fillFarOffsetState.Off();
        }