Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);
share|improve this question
Are you specifically looking for a way to do it in code? Or are you amenable to stacking and normalizing using an external tool? – Casey Wagner Apr 28 '13 at 3:00
I am looking for a way to do it in code, if that is possible. – DorkMonstuh Apr 28 '13 at 9:02

I'm not really sure what exactly you hope to achieve, the proposition sounds sketchy.

In any case, I'm pretty sure you get your error for trying to calculate the dot product between a vec4 and a vec3. The mathematical dot product is only defined for vectors with the same number of dimensions, most programming languages mirror this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.