Question: In Program 8.1, experiment with different settings for glPolygonOffset(), and observe the effects on shadow artifacts such as Peter Panning. Program 8.1 // Much is

In Program 8.1, experiment with different settings for glPolygonOffset(), and observe the effects on shadow artifacts such as Peter Panning.

Program 8.1// Much is the same as we have seen before. New sections to support shadows are highlighted. // The importsprivate float[] lightAmbient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; private float[] lightDiffuse = new// shadow-related variables private int screen SizeX, screenSizeY; private int [] shadow Tex = new int [1];rendering Program1= Utils.createShaderProgram("code/vert1shader.gisl", rendering Program2=setupVertices(); setupShadowBuffers(); b.set( 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f,gl.glBind Texture(GL_TEXTURE_2D, shadow Tex[0]); gl.glTexlmage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32,// set up perspective matrix for the camera, either here or in init() // set up view and perspective matrix} // make the custom frame buffer current, and associate it with the shadow texture// What follows now are the methods for the first and second passes. // They are largely identical to things// we are drawing from the light's point of view, so we use the light's P and V matrices} gl.glClear(GL_DEPTH_BUFFER_BIT); gl.glEnable(GL_CULL_FACE); gl.glFrontFace(GL_CCW);public void pass Two() { GL4 gl = (GL4) GLContext.getCurrentGL(); // rendering Program2 includes the pass twovMat.identity().setTranslation (-cameraLoc.x(), -cameraLoc.y(), -cameraLoc.z());shadowMVP2.mul(b); shadowMVP2.mul(lightPmat); shadowMVP2.mul(lightVmat); shadowMVP2.mul(mMat); // put the MV} gl.glClear(GL_DEPTH_BUFFER_BIT); gl.glEnable(GL_CULL_FACE); gl.glFrontFace(GL_CCW);


// Much is the same as we have seen before. New sections to support shadows are highlighted. // The imports necessary for lighting, etc., would be included at the start, are the same as before, // and are not shown here. public class Code extends JFrame implements GLEventListener { // variable declarations for rendering programs, buffers, shader sources, etc., would go here. private ImportedModel pyramid = new Imported Model("pyr.obj"); // define the pyramid private Torus myTorus = new Torus (0.6f, 0.4f, 48); // define the torus private int numPyramidVertices, num Torus Vertices, num TorusIndices; // locations of torus, pyramid, camera, and light private Vector3f torusLoc = new Vector3f(1.6, 0.0, -0.3); private Vector3f pyrLoc = new Vector3f(-1.0, 0.1, 0.3); private Vector3f cameraLoc = new Vector3f(0.0, 0.2, 6.0); private Vector3f lightLoc= new Vector3f(-3.8f, 2.2f, 1.1f); // properties of white light (global and positional) used in this scene private float[] globalAmbient = new float[] { 0.7f, 0.7f, 0.7f, 1.0f};

Step by Step Solution

3.28 Rating (154 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!