Hello!
My problem starts when I use this way to load a shader:
sf::Shader miShader;
miShader.loadFromFile("shader/bumpmap.vert","shader/bumpmap.frag");
Vertex Shader:
void main(){
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Fragment Shader:
// Textura y Bumpmap
uniform sampler2D normalTexture;
uniform sampler2D texture;
//variables internas
uniform vec3 position;
void main()
{
// El color del pixel actual en el Normal Map
vec4 normColor = texture2D(normalTexture, gl_TexCoord[0].st);
// El color del pixel actual en la Textura
vec4 texColor = texture2D(texture, gl_TexCoord[0].st );
// El vector normal al Normal Map
vec3 normalMapVector = 2.0 *(normColor.rgb - 0.5);
// Calculamos el vector de la Luz
vec3 light = normalize(gl_LightSource[0].position.xyz - position);
// Calculamos el vector del Ojo
vec3 E = normalize(-position); // we are in Eye Coordinates, so EyePos is (0,0,0)
// Calculamos el vector ??
vec3 R = normalize(-reflect(light,normalMapVector));
// Calculamos el efecto de diffuse
vec4 Idiff = gl_LightSource[0].diffuse * max(dot(normalMapVector,light), 0.0);
Idiff = clamp(Idiff, 0.0, 1.0);
// Calculamos el efecto de ambient
vec4 Iamb = gl_LightSource[0].ambient;
// calculate Specular Term:
vec4 Ispec = gl_LightSource[0].specular * pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess);
Ispec = clamp(Ispec, 0.0, 1.0);
//
gl_FragColor = Idiff*texColor + Iamb + Ispec;
}
If i only use the fragment shader, no problem, but if i use both then only paints a rectangle of a color similar to the diffuse map.