Thursday, November 28, 2019
Playing with proportions
Monday, November 18, 2019
Thursday, November 14, 2019
First illustration for Fluffle and Flame
Saturday, August 31, 2019
A book about tongues
Sunday, March 3, 2019
Portrait of my Grandma
Thursday, January 31, 2019
Dominique Medici Workshop
Monday, December 31, 2018
Practice on Magnets
Thursday, December 20, 2018
Second portrait of my daughter
Sunday, July 1, 2018
First Figure Painting Class
Tuesday, May 8, 2018
First Portrait Painting
So I made my first attempt - a 24x24" portrait of my daughter.
Sunday, July 25, 2010
OpenGL ES 2.0 Phong Shaders


Both shaders use the standard Phong shading equation. The die has a normal map applied to make the divets and slightly rough surface. There were two tricky concepts I had to learn to get the normal map to show up properly.
a. I had to put the view and light vectors into "tangent space" because that's the space the normals from the normal map are in. Tangent space is defined for each vertex by the normal, binormal, and tangent. This space is preferrable to world or view space because it preserves the normal map when transformations occur on the model. I defined tangent space with this line of code in the vertex shader: "mat3 tangentMatrix = mat3(a_tangent, a_binormal, a_normal)". Then I multipied the tangent matrix by the view and light vectors. Thus, in the fragment shader, all I had to do was grab the pertinent normal from the normal map and change the range from [0, 1] to [-1, 1] before performing the usual lighting calculations.
b. Some exporters and formats include the binormals and tangents, but the format I was using (3ds) did not so I needed to calculate them. The key is to use the vertex positions and texture coordinates. Both pieces of information are pertinent because you want to take into account significant changes in either one. I found a good website that describes how the calculations are derived: http://www.terathon.com/code/tangent.html. The code I ended up writing is below.










