public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); LightBase light = arg.Light; mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); RenderMethod method = this.RenderUnit.Methods[2]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); program.SetUniform("shadowMat", lightBias * lightProjection * lightView); // light info. light.SetBlinnPhongUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); program.SetUniform("depthTexture", arg.ShadowMap); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); program.SetUniform("useShadow", this.UseShadow); method.Render(); }
public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { if (!this.IsInitialized) { Initialize(); } //this.RotationAngle += this.RotateSpeed; ICamera camera = arg.Camera; mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); mat4 lightBias = glm.translate(mat4.identity(), new vec3(1, 1, 1) * 0.5f); lightBias = glm.scale(lightBias, new vec3(1, 1, 1) * 0.5f); LightBase light = arg.Light; mat4 lightProjection = light.GetProjectionMatrix(); mat4 lightView = light.GetViewMatrix(); var method = this.RenderUnit.Methods[(int)MethodName.renderUnderLight]; ShaderProgram program = method.Program; // matrix. program.SetUniform("mvpMat", projection * view * model); //program.SetUniform("projectionMat", projection); //program.SetUniform("viewMat", view); program.SetUniform("modelMat", model); program.SetUniform("normalMat", glm.transpose(glm.inverse(model))); program.SetUniform("shadow_matrix", lightBias * lightProjection * lightView); // light info. light.SetUniforms(program); // material. program.SetUniform("material.diffuse", this.Color); program.SetUniform("material.specular", this.Color); program.SetUniform("material.shiness", this.Shiness); program.SetUniform("depth_texture", arg.ShadowMap); // eye pos. program.SetUniform("eyePos", camera.Position); // camera's position in world space. // use blinn phong or not? program.SetUniform("blinn", this.BlinnPhong); method.Render(); }
/// <summary> /// Render the node under the specified light. /// </summary> /// <param name="arg"></param> /// <param name="light"></param> public void RenderUnderLight(ShadowMappingUnderLightEventArgs arg) { }