top of page

Normal Map and Toon Shader

Normal mapping is essentially altering the normals based on a texture. Since, the objects are transformed in different ways, the normals from the normal map texture need to go under some transformations. So, we take the normal from the normal map texture to a space where basis is formed by tangent, bi-normals and the normals of the fragment. These 3 are taken as inputs while exporting the files from Maya. Personally, I get my tangent, bi-normal and normals in view space and then make basis out of it. This leads the normal from the normal map texture to be transformed correctly and can be used straight away in the lighting equation.
The next thing that I did was to implement toon shading. Toon shading involves 3 features: darkened silhouette edge, stepped diffuse shading, and stepped specular highlight. First, I did the stepped diffuse shading. For this, I basically clamped values to a minimum threshold. For example, all the diffuse intensity values from 0.9 are all clamped to 0.9, and the values between 0.5 and 0.9 and all clamped to 0.5. Similar idea can be used to make the stepped specular highlights. To make a silhouette edge, I did a very simple technique. So, I render the object counter clockwise with the stepped phong shading, and then render the same object clockwise (so that the back facing polygons are rendered this time). While drawing it clockwise, I use a shader that essentially extends the vertices along the normal.

 

bottom of page