Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.