<- back
hw7 upload hw.cpp to glow codebase bare bones reference solution | ✨ extra bits

I recommend doing all the green questions first; I will help debug any of the questions this week. NOTE: Moreso than any other week, our code this week does _not_ represent good practice for writing fast graphics code. It is written to be clear for helping you learn the concepts. It's not necessarily terrible, but it's also not great.
a. (30 pts) mandelbrodt In this problem I give you a square mesh (two triangles). 🟢 (20 pts) Complete the fragment (pixel) shader to draw the Mandelbrot set (it should match roughly the bare bones reference solution linked at the top of the hw). NOTE: I recommend not thinking about color yet; instead implement some basic map from iteration to a shade of gray. ✨ NOTE: to start, i would color like so: - if iteration == max_iteration (i.e., the point is _in_ the mandelbrodt set), color the point black - else color the point white - ⚠ NOTE: use col += ... _not_ code = ... (otherwise, e.g., your white will appear dark gray) Then look into more fancy approaches to coloring ⚠ NOTE: please ignore AA, m, n for now; just assume that p0 = (x0, y0) is the pixel position from the wikipedia article (if you're interested, AA, m, n are used to do sub-pixel sampling for anti-aliasing (i.e. for each pixels we do the calculation n*m times, add up the resulting colors and divide the result by (m*n); we'll cover this in class at some point 🙂) ⚠ NOTE: use col += ... _not_ code = ... HINT: pseudocode NOTE: GLSL documentation 🟦 (10 pts) Color it to match (as close as you can) the extra bits reference solution HINT: You will need a color map HINT: You will need to introduce a uniform variable for time - declare it before the hw7a while loop as double time = 0; - update it inside of the if (playing) { ... } block - pass it to the shader program as shader_set_uniform_double(shader_program, "time", time); - declare a uniform float time; at the top of the fragment shader - ^ all of this is actually already done in hw7c, so you can look there if you get stuck NOTE: Once you're done with the problem, here is iq's beautiful shadertoy solution for reference; "by Inigo Quilez, @iquilezles and iquilezles.org" b. (20 pts) do or dough nut In this problem, I give you a grid mesh (2*S*S triangles). 🟢 (15 pts) Complete the vertex shader to fold the mesh into a doughnut. README: parametric equation 🟦 (5 pts) Modify the vertex shader to match (as close as you can) the extra bits reference solution. HINT: you will need to introduce a uniform variable for time (see above) HINT: you will need to make a variety of changes to the code 🟢 c. (20 pts) blinn-phong lighting Complete the fragment shader to implement world space Blinn-Phong point lights. Also add sliders for the ambient, diffuse, specular, and shininess coefficients (you will have to pass these to the shader as uniforms). README: Phong lighting README: Blinn's modification NOTE: I've set up the model matrix so if you press the P key the mesh will stretch up and down. d. (20 pts) creative coding 🟢 Copy your solution to hw7c into hw7d. Modify the vertex and/or fragment shaders to do something *cool*. E.g., in the extra bits refernce solution you can see I added a twist. You could also, e.g., implement toon shading.
🐄