Question: Modify Program 7.2 so that it incorporates TWO positional lights, placed in different locations. The fragment shader will need to blend the diffuse and specular

Modify Program 7.2 so that it incorporates TWO positional lights, placed in different locations. The fragment shader will need to blend the diffuse and specular contributions of each of the lights. Try using a weighted sum, similar to the one shown in Section 7.6. You can also try simply adding them and clamping the result so it doesn’t exceed the maximum light value.

Program 7.2Vertex Shader #version 430 layout (location=0) in vec3 vertPos; layout (location=1) in vec3 vertNormal; outFragment Shader #version 430 in vec3 varying Normal; in vec3 varyingLightDir; in vec3 varyingVertPos; outvoid main(void) { // normalize the light, normal, and view vectors: vec3 L = normalize(varying LightDir);

Vertex Shader #version 430 layout (location=0) in vec3 vertPos; layout (location=1) in vec3 vertNormal; out vec3 varying Normal; out vec3 varyingLightDir; out vec3 varying VertPos; // structs and uniforms same as for Gouraud shading //eye-space vertex normal // vector pointing to the light // vertex position in eye space void main(void) { // output vertex position, light direction, and normal to the rasterizer for interpolation varyingVertPos=(m_matrix * vec4(vertPos, 1.0)).xyz; varyingLightDir - light.position - varying VertPos; varying Normal (norm_matrix * vec4(vertNormal, 1.0)).xyz; gl_Position=p_matrix * v_matrix * m_matrix * vec4(vertPos, 1.0); }

Step by Step Solution

3.42 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Graphics Programming Questions!