bump mapping with 2 normal maps
Posted
by
DorkMonstuh
on Game Development
See other posts from Game Development
or by DorkMonstuh
Published on 2013-04-28T02:16:05Z
Indexed on
2013/06/27
16:30 UTC
Read the original article
Hit count: 242
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);
}
© Game Development or respective owner