Hello, I’m learning about bump mapping and I’ve made this code in a DOJO class:
uniform sampler2D sampler2d0;
uniform sampler2D sampler2d1;
uniform sampler2D sampler2d2;
void main()
{
vec2 coordTex = (gl_Vertex.xy + 1.0) / 2.0;
vec4 color = texture2D(sampler2d0, coordTex);
vec4 normalMap = texture2D(sampler2d1, coordTex);
vec4 heightMap = texture2D(sampler2d2, coordTex);
vec4 modelVertex = gl_Vertex;
modelVertex.z = 0.05*heightMap.z;
vec4 eyeVertex = gl_ModelViewMatrix * modelVertex;
vec3 normal = gl_NormalMatrix * normalMap.xyz;
normal = normalize(2*(normal-0.5));
vec3 lightDir = gl_LightSource[0].position.xyz - eyeVertex.xyz;
lightDir = normalize(lightDir);
float diffuse = dot(lightDir, normal);
gl_Position = gl_ProjectionMatrix * eyeVertex;
gl_FrontColor.rgb = diffuse * color.rgb;
gl_FrontColor.a = 1.0;
}
It works pretty well. Now, I would like to try it in the fragment shader. I have no idea how to do it. How can I start?