bump mapping with 2 normal maps
- by DorkMonstuh
I was wondering if its actually possible to do bump mapping with 2 normal maps... I have tried doing it this way however I get a function overload on max and dot.
uniform sampler2D n_mapTex;
uniform sampler2D n_mapTex2;
uniform sampler2D refTex;
varying mediump vec2 TexCoord;
varying mediump float vTime;
void main()
{
mediump vec4 wave = texture2D(n_mapTex, TexCoord - vTime);
mediump vec4 wave2 = texture2D(n_mapTex2, TexCoord + vTime);
mediump vec4 bump = mix(wave2, wave, 0.5);
//this extracts the normals from the combined normal maps
mediump vec4 normal = normalize(bump.xyzw * 2.0 - 1.0);
//determines light position
mediump vec3 lightPos = normalize(vec3(0.0, 1.0, 3.0));
mediump float diffuse = max(dot(normal, lightPos),0.0);
gl_FragColor = mix(texture2D(refTex, TexCoord), bump, 0.5);
}