Last week in class we learned about three types of shaders: Fragment, Vertex, and Geometry. Zach and Kyle created an example called “Depth Visualizer DOF (Depth of Field)” and today I worked with Matt Ganucheau to experiment with applying shaders to the depth visualizer. We found this helpful reference online, and tried out different shaders in the fragement and vertex files. To keep the openFrameworks example simple, we just changed the existing “DOFCloud.frag” and “DOFCloud.vert” files, versus making new ones and then referencing them. In order to apply the shader to the point cloud in 3D, we needed to map the “varying vec4″ variable to the “gl_Position” in the vertex file, because gl_Position multiplies the gl_Vertex points by the 3D “gl_ModelViewProjectionMatrix”.
I wanted to make the shader change in relation to the depth, so Zach said that I needed to create a “zscale” variable in the fragment file. I tried various formulas with this, but wasn’t getting the results that I wanted. For now, the shader changes color because of the size of the sin wave that I applied to the zscale variable. Check out the attached code. In the testApp file, I commented out “glBlendFunc(GL_SRC_ALPHA, GL_ONE);” line, in order to better see what the shader is doing to the point cloud. (Also to note in the code: in a previous assignment, I wrote some simple code to test whether a cube drawn to screen has been “hit” by a 3D object detected by the Kinect…all of this is commented out in order to focus on the shader.)