GPU Programming Lab 3
Due Monday, September 17, and 5:00 PM
If you don't have them already, grab the tutorials with a command like this:
git clone https://gitlab.com/wikibooks-opengl/modern-tutorials
Alternatively, the normal vector demo from today is on isoptera in the examples directory. Start with the cube demo, or the normals demo from today. May have to adjust opengl version to at least 3.2 (GLSL version 150). I suggest just updating to version 450, since we'll have to go to at least 430 for compute shaders anyway.
Determine the middle of the triangle hypotenuse (will have to figure out which side is they hypotenuse)
Add the normal vector to the middle of the hypotenuse to get the bulge point
Draw two triangles, each using two original points plus the bulge point. Keep the winding order consistent with the original.
This is geometry amplification, or tesselation. To see what you're doing, consider drawing with lines_strip instead of triangles_strip. Remember the nature of triangles_strip. You can use EndPrimitive() and just draw two triangles, or embrace the triangle strip nature and only specify 4 vertices.
- Calculate face normal vectors
To get everything to look right, you will probably have to apply the transformation matrix mvp in the geometry shader instead of the vertex shader. Just remove it from the vertex shader, and each time you set gl_Position, set it to mvp multiplied by whatever you were going to set gl_Position to.