


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Part A (5 points): Compute the color in a fragment shader using the sinusoidal function:
outputcolor = 0. 5 ∗ (1 + sin(val ∗ x^2 + val ∗ y^2 )). (1)
Use the fragment’s texture coordinate (“gl TexCoord[0].xy”) for the x and y values and val is passed in as the uniform parameter “scaleValue” (i.e. you can access it via “scaleValue.x”), which can change via the ’+’ and ’-’ keys when running the program. This should look like the following two examples (for val = 20 and 300.5, respectively).
Part B (5 points): Now that you can see some cool Moir´e effects on your quadrilateral, lets move the vertices around a bit in the vertex shader. Notice in the OpenGL program, that the one big quad in this program is actually made up of 400 smaller quads. For this problem, we’re going to use the vertex shader to manipulate the location of these quad vertices before the quads are rasterized !! This means, you’ll be changing the displayed geometry without recompiling the program. Based on the uniform parameter “theTime” passed to the vertex shader, change the location of the vertex as follows:
newObjSpaceP osx = oldObjSpaceP osx (2) newObjSpaceP osy = oldObjSpaceP osy (3) newObjSpaceP osz = oldObjSpaceP osz + 5 ∗ theT ime^2 ∗ (oldObjSpaceP os^2 x + oldObjSpaceP os^2 y ) (4)