For the first project, the goal was to manipulate live video, captured using OpenCV, by utilizing shaders written in GLSL.
When running the program, the following keys can be used: (1) and (2) moves between the first and second pages of effects. On the first page,
there is a background replacement shader which needs to first capture a snapshot of the background. This can be done using the (t) key. (q) (w) (a) and (s) expand the
size of the windows of the 1,2,3 and 4 shader respectively. You can download the source code here: project 1 source code
The first shader is an attempt to mimic a cartoon-like look but with some fog thrown in.
The lines drawn are done using a simple edge detection technique based on the work found at: edge detection.
This next shader is an attempt at a lite brite effect. For each peg in the lite brite, we compute the rgb channels by first computing the 5x5 "block" that it resides in within the video texture. Next, we compute the average color per block (per pixel unfortunately) and apply that as the color. To get the circular effect, we simply compute the distance to the center of the block for each pixel in the fragement shader of course, and then if it resides within the designated radius of the circle, then we color it. Otherwise, we color it black.
Next comes a very poor attempt at superimposing myself infront of a background image. This effect works by taking a snapshot of the frame from the video first and saving that away. It works best by taking this snapshot without your head in the picture. In my program you can do this by selecting the 't' key. Next, that snapshot is sent to the fragment shader which then computes per pixel the similarity between the pixel it is seeing at the snapshot image. If it is highly similar, then it shows the background. Else, it shows the pixel from the video stream. I played around a bit with similarity and I could never get it working all that well.
Here is a bump mapping shader using the same image as the background image above. The bump mapping technique is based on the version from Ozone 3D. In the vertex shader, we compute the lighting vectors and the eye vectors from camera space to tangent space and pass those vectors to the fragment shader. The fragment shader computes the color of the pixel by computing the specular, diffuse and ambient per pixel.
Here we have a shader that does a standard twirl effect. The formula from the twirl was taken from photobooth. For all the effects described in photobooth, the first step is translating from cartesian coordinates to polar space. From there, you can just apply the equations.
This shader works by generating perlin noise inside the fragment shader using the code from here. Once this noise is created we compute some noise value based on the position of the pixel. Half of the pixels are drawn as static (white or black), while the other half are then "washed out" by mixing in some colors to try and make it look vintage.