VisExercises

Exercise 9

Exercise 8 |

MPR with Windowing

This exercise is based on the previous one.

In the following, we need to use the glVertex (LGL) frame work in this exercise, meaning that we have to use the “qlglwindow.cpp” module and the “lgl” option of the frame work:

./myqtapp --lgl

Exercise (9a)

  • Use the GLSL Shader Editor (./myqtapp --glsled) to write a shader, which starts with the simplest shader possible and passes the per-vertex color attributes from the vertex shader to the fragment shader using a so-called varying and then writes the colors into the fragment shader’s output register.
    • Have a look at the GLSL example and modify it for the LGL framework:
      • gl_Vertex → vertex_position
      • gl_Color → vertex_color
      • gl_ModelViewProjectionMatrix → mvp

Exercise (9b)

  • Use the GLSL Shader Editor to write a shader, which modifies the red channel
    • For example by multiplying it with 0.5
    • For example offsetting it with 0.5
      • Or a combination of the above
    • For example by setting it to zero above a certain sc

reen-space elevation (gl_FragCoord.y > 100)

  • For example by setting it to zero above a certain object-space elevation
    • How do you get the object space coordinate in the fragment shader (using a varying)?

Exercise (9c)

accordingly.

  • Full documentation of the glVertex library is available in the README.
  • Next, perform a 3D texture lookup in the shader and modulate the vertex color with the texture color (you need another varying for the texture coordinates).

Exercise (9d)

  • Write a shader that maps the range of scalar values in the range [s,1] to red (s=0.5) as shown in the lecture.
  • Apply the above shader to the MPR rendering of the previous exercise.

Home work (9e)

  • Make voxels with a scalar value of zero completely transparent by using alpha blending or an alpha test (via lglBlendMode resp. lglAlphaTest).
  • Get the mouse coordinates by overriding the mouseMoveEvent(QMouseEvent *event) method of the QLGLWidget.
    • When the mouse is pressed (MousePressedEvent/MouseReleasedEvent), map the vertical mouse coordinate to s-values in the range [0,1].
    • Use lglUniform to pass the s-parameter to your GLSL shader, so that you can interactively modify the threshold.


Exercise 8 |

Options: