Learn the basics of how to use Terragen [TE16] to create a simple cube map. This generally

Question:

Learn the basics of how to use Terragen [TE16] to create a simple cube map. This generally entails making a “world” with the desired terrain and atmospheric patterns (in Terragen), and then positioning Terragen’s synthetic camera to save six images representing the front, back, right, left, top, and bottom views. Use your images in Programs 9.2 and 9.3 to see how they appear as cube maps and with environment mapping. The free version of Terragen is quite sufficient for this exercise.

Program 9.2Java/JOGL application public void init(GLAutoDrawable drawable) { GL4 gl= (GL4) GLContext.getCurrentGL(); //public void display(GLAutoDrawable drawable) { // clear color and depth buffers, projection and camera view} // set up vertices buffer for cube (buffer for texture coordinates not necessary)public int loadCubeMap(String dirName) {GL4 gl = (GL4) GLContext.getCurrentGL(); // assumes that the six file// getRGBAPixel is from Chapter 5. This time image NOT flipped because OpenGL does it for us byte[] topRGBA =Byte Buffer topWrapped RGBA = ByteBuffer.wrap(topRGBA); Byte Buffer leftWrapped RGBA =gl.glBind Texture(GL_TEXTURE_CUBE_MAP, textureID); gl.gl TexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1024,} // to help reduce seams gl.glTexParameteri(GL_TEXTURE_CUBE_MAP, gl.g|TexParameteri(GL_TEXTURE_CUBE_MAP,void main(void) { } tc = position; mat4 vrot_matrix = mat4(mat3(v_matrix)); gl_Position=p_matrix *vrot_matrix

Program 9.3public void display(GLAutoDrawable 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); mMat.invert(inv} // drawing the torus is otherwise unchanged gl.glClear(GL_DEPTH_BUFFER_BIT); 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

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Graphics Programming In OpenGL With JAVA

ISBN: 9781683922193

2nd Edition

Authors: V. Scott Gordon PhD, John L. Clevenger PhD

Question Posted: