1/** 2 * Shader to visualize normals 3 * @author Xoppa 4 */ 5[VS] 6#include "g_attributes.glsl:VS" 7#include "u_uniforms.glsl" 8#include "skinning.glsl" 9#include "common.glsl:VS" 10 11void main() { 12 g_position = u_worldTrans * applySkinning(g_position); 13 gl_Position = u_projViewTrans * g_position; 14 15#ifdef normalTextureFlag 16 g_binormal = normalize(u_normalMatrix * applySkinning(g_binormal)); 17 g_tangent = normalize(u_normalMatrix * applySkinning(g_tangent)); 18 pushBinormal(); 19 pushTangent(); 20 pushTexCoord0(); 21#endif 22 23 passNormalValue(normalize(u_normalMatrix * applySkinning(g_normal))); 24} 25 26[FS] 27#ifdef GL_ES 28#define LOWP lowp 29#define MED mediump 30#define HIGH highp 31precision mediump float; 32#else 33#define MED 34#define LOWP 35#define HIGH 36#endif 37 38#include "g_attributes.glsl:FS" 39#include "u_uniforms.glsl" 40#include "common.glsl:FS" 41 42void main() { 43 pullNormal(); 44 45#ifdef normalTextureFlag 46 pullBinormal(); 47 pullTangent(); 48 49 vec3 normal = normalize(texture2D(u_normalTexture, g_texCoord0).xyz * 2.0 - 1.0); 50 g_normal = normalize((g_tangent * normal.x) + (g_binormal * normal.y) + (g_normal * normal.z)); 51#endif 52 53 gl_FragColor = vec4( normalize( g_normal * vec3( 0.5 ) + vec3( 0.5 ) ), 1.0 ); 54} 55