Shader Gallery

Gallery of Shaders
by David Cornette
Computer Science Department
University of Southern Maine
Faculty Advisor: Dr. Bruce MacLeod

This shader is a blue marble pattern.  It is based on a shader given on pages 87-88 in Texturing and Modelling: A Procedural Approach.
Vertex shader: lambert01vert.glsl
Fragment shader: marblelambfrag.glsl

Blue marble dragon

This shader is a granite pattern.  Based on a shader given on page 308 of OpenGL Shading Language.  It was modified from the shader given in the text, since I used a GLSL implementation of noise, while the shaders in the book passed a texture with a precomputed noise to the shader.
Vertex shader: lambert01vert.glsl
Fragment shader: granitefrag.glsl

Granite dragon

The next two examples show a wood patttern.  They were both created with the same shader, but with different colors.  The shader is based on one given on pages 308-312 in OpenGL Shading Language.  Again, changes were made to use the GLSL implementation of noise instead of the texture.
Vertex shader: lambert01vert.glsl
Fragment shader: woodfrag.glsl
Wodden dragonWooden dragon variation

This next example is a displacement shader.  In the vertex shader, it calls the noise function, and uses that value to displace the vertex.  This causes a couple of issues.  First, because the vertices have been moved, the normal vectors are not going to be correct.  This means that any lighting model which uses the norma is going to give incorrect results.  It may be possible to recalculate the correct normal by passing the locations of  adjoining vertices (this would require that the topology of thr mesh be restricted so that only some fixed maximum number of faces may meet at a certain vertex).  The other problem is that this shader runs incredibly slow, since so much computation is done in the vertex shader.  Fragment shaders are parallelized, while it seems that vertex shaders are not.  Depending on the size of the window, this shader took as long as 15 seconds per frame to render.  Click on the image to view an animation of the shader.
Vertex shader: displacevert.glsl
Fragment shader: dispfrag.glsl
Displacement shader