Question: Modify Program 9.3 so that the object in the scene blends environment mapping with a texture. Use a weighted sum in the fragment shader, as

Modify Program 9.3 so that the object in the scene blends environment mapping with a texture. Use a weighted sum in the fragment shader, as described in Chapter 7.

Program 9.3public void display(GLAuto Drawable drawable) { // the code for drawing the cube map is unchanged. // the// build the MODEL-VIEW matrix, as before mvMat.identity(); mvMat.mul(vMat); mvMat.mul (mMat);} BUFFER_BIT); // drawing the torus is otherwise unchanged gl.glClear(GL_DEPTH gl.glEnable(GL_CULL_FACE);Vertex shader #version 430 layout (location = 0) in vec3 position; layout (location = 1) in vec3 normal; outvoid main(void) { varyingVertPos } = (mv_matrix * vec4(position, 1.0)).xyz; varying Normal = (norm_matrix *Fragment shader #version 430 in vec3 varyingNormal; in vec3 varyingVertPos; out vec4 fragColor; uniform mat4

public void display(GLAutoDrawable drawable) { // the code for drawing the cube map is unchanged. // the changes are all in drawing the torus: gl.glUse Program (rendering Program); // uniform locations for matrix transforms, including the transform for normals mvLoc = gl.glGetUniform Location (rendering Program, "mv_matrix"); pLoc = gl.glGetUniform Location (rendering Program, "p_matrix"); nLoc - gl.gl GetUniform Location (rendering Program, "norm_matrix"); // build the MODEL matrix, as before mMat.identity(); mMat.translate(torusLoc.x(), torusLoc.y(), torusLoc.z());

Step by Step Solution

3.46 Rating (153 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!