Question: Modify Program 8.2 to replace the hardcoded values 0.001 in the lookup() function, with the more accurate values of 1.0/shadowbufferwidth and 1.0/shadowbufferheight. Observe to what

Modify Program 8.2 to replace the hardcoded values 0.001 in the lookup() function, with the more accurate values of 1.0/shadowbufferwidth and 1.0/shadowbufferheight. Observe to what degree this change makes a difference (or not) for various window sizes.

Program 8.2Fragment Shader #version 430 // all variable declarations are unchanged // Returns the shadow depth value forvoid main(void) { float shadowFactor = 0.0; vec3 L = normalize(vLightDir); vec3 N = normalize(vNormal); vec3shadowFactor shadowFactor shadowFactor += lookup(-1.5*swidth += lookup(0.5*swidth += lookup(0.5*swidth +

Fragment Shader #version 430 // all variable declarations are unchanged // Returns the shadow depth value for a texel at distance (x,y) from shadow_coord. Recall that // shadow_coord is the location in the shadow map corresponding to the current pixel being rendered. float lookup (float ox, float oy) { float t = texture Proj(shadow Tex, shadow_coord + vec4(ox * 0.001 * shadow_coord.w, oy * 0.001 * shadow_coord.w, -0.01, 0.0)); // the third parameter (-0.01) is an offset to counteract shadow acne return t;

Step by Step Solution

3.33 Rating (147 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!