Workbook 9 Gallery
Here are a few cool examples from student assignments for Workbook 9.
Note: we cannot post all cool assignments! What we post is a random selection of good assignments - not necessarily the best.
Box 09-07-01 - Dynamic Environment
Student: Zhihao Yang (A ball that reflects the background and surrounding dynamic objects)
Student: Anonymous
Student: Tudor Popa (I am not totally sure what models I want to use for the final late submission, but I have something that works for the gallery.)
Student: Anonymous
Student: Donghwan Kim (Vertex shader To account for the uniform time variable, the first line of main function #include<common> is replaced by itself + declaration of the uTime variable. Because fragment shader takes uv as inputs, it is easier to modify the uvs in vertex shader than in fragment shader. Also, the uvs, although are identical, did not share the same variable. Thus, all uv variables passed into the fragment that are used as parameter for texture2D method inside the methods I wish to modify had to be modified. These were: vUv, vMapUv, vBumpMapUv, and vMetalnessMapUv. Although vDisplacementMapUv was modified, displacement map was not used because frame drop was so huge when displacement was dynamically altered. Also it wasn't so good to look at without tesselation, which was also very computationally demanding. Fragment shader map_pars_fragment is the portion of fragment shader where the default map texture is first declared. So, the uniform sampler2D for the custom textures were declared here, along with the uniform vec2 fUv variable that modifies the scale of the custom texture. The corresponding textures are : fun_tx.png as uniform sampler2D funMap, and fun_tx_mask.png as uniform sampler2D funMask map_fragment is inside the main function, and is #include-ed earlier than other #include-s that I need to modify later. Declaring variables storing color information of the textures here therefore allows use of the texture without re declaring them in later modification. diffuseColor is the default color that is set by #include <map_framgent>. I used the 'clipping' approach to place the texture 'on top' of the original texture. The areas of the funMap where opacity (w value) is less than or equal to a certain value (clipping value, fixed as 0.0 for 09-03-01), were altered to have opacity of 0, and 1 otherwise. Then, the diffuse Color was updated to be replaced by the funMap when the w value of funMap was 1, and by itself otherwise. metalnessmap_fragment contained code that in the end modified the metalnessFactor using the metalness map. Because perlinNoise.png, the default map texture, is black and white, it is suitable for a metalness map. So, the default metalness map was set to perlinNoise.png as well. To adjust metalness to match that of the replaced portion, the metalness was set to 1 if the current pixel was replaced but had mask value's red channel was lower than 0.1. If the pixel was replaced but had greater red value on the mask, that same red channel value was multiplied by the metalness uniform variable, which is how metalnessFactor is originally computed. Otherwise, the original metalnessFactor was left unchanged. Becuase the mask texture was black/white, only using 1 channel to compare sufficed. bumpmap is actually computed outside the main function, and bumpmap_pars_fragment contained functions that computes the output of using bumpmaps. To modify one function, vec2 dHdxy_fwd(), of that code, the entire #include-ed bumpmap_pars_fragment had to be replaced. Also, becuase it was outside and above the main function, the variables containing color information about the custom textures had to be declared again. If the pixel was replaced by the new texture, the replaced texture itself was used as a bumpmap, but only using the alpha values (w values). Then, the mask texture was used for the replaced pixels to compute the bumpiness of that pixel. Setting metalness and bumpmap mask identical for the replaced fragment almost gives this glossy, beveled sticker-like result.)