Practical Exercise 4.
Hand in ONLY the {@link de.rwth_aachen.graphics.Main Main.java} source file and the shader source file texture.frag which is located in "res/shaders/" until 14.12.2009 13:30h to cg1@informatik.rwth-aachen.de.
Please note: We will only take into account the code in the designated areas!
Description:
In this exercise, you will learn to use textures in shaders and as render target. Since the Java documentation does not include the glSlang files we have put the tasks here.
GLSL task:
Task 1.a: res/shaders/texture.frag
The basis of this fragment shader is the phong model. Extend this by using textures for the diffuse color and the specularity. Additionally, you have to use a cube map for an environment reflection. This should be dependent on the specularity value.
Hint: OpenGL does not distinguish between a model and a view matrix and only provides the modelview matrix. In our implementation, we use eye coordinates in the fragment shader. In order to get back to the model space you can use the {@link de.rwth_aachen.graphics.Camera#getInverseViewMatrix() inverse view matrix} that is provided by our camera class.
Java tasks:
{@link de.rwth_aachen.graphics.Main#init() Task 1.b Upload rusty metal textures.}
{@link de.rwth_aachen.graphics.Main#loop() Task 1.c Setting rusty metal uniforms and textures.}
{@link de.rwth_aachen.graphics.Main#init() Task 2.b Initialize the render target.}
{@link de.rwth_aachen.graphics.Main#loop() Task 2.c/d Render to the screen.}
General notes: As in the previous exercises we already provide some interactivity which provides changing the current shader by pressing "s" and changing the current geometry by pressing "g". The "space" key will switch the camera mode. You can also switch the lights on and off by using the keys 1, 2 and 3.