Hi hakim,
I have made a shader that creates normalmaps out of heighmaps.
Now it lacks the diffuse to heighmap shader ^^
maybe you can need it.
Heighmap to Normalmap Shader
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
uniform sampler2D texture0;
varying vec2 uvVarying;
uniform vec2 agk_resolution;
void main()
{
float x = 1.0 / float(agk_resolution.x);
float y = 1.0 / float(agk_resolution.y);
float right = texture2D(texture0, uvVarying + vec2(x, 0.0)).r;
float left = texture2D(texture0, uvVarying - vec2(x, 0.0)).r;
float top = texture2D(texture0, uvVarying + vec2(0.0, y)).r;
float bottom = texture2D(texture0, uvVarying - vec2(0.0, y)).r;
#if 1
// nutzt proportionalität zum normal vector aus
float dx = left-right;
float dy = bottom-top;
//vec3 mapN = vec3(dx, dy, sqrt(1.0 - dx * dx - dy * dy));
//vec3 mapN = vec3(dx, dy, sqrt(dx * dx + dy * dy));
dx = (dx + 1.0) * 0.5;
dy = (dy + 1.0) * 0.5;
float dz = sqrt(dx * dx + dy * dy);
//dz = (dz + 1.0) * 0.5;
vec3 mapN = vec3(dx, dy, dz);
#else
// kreuzprodukt
float dx = right-left;
float dy = top-bottom;
vec3 dvx = vec3(0.1, 0.0, dx);
vec3 dvy = vec3(0.0, 0.1, dy);
vec3 mapN = normalize(cross(dvx, dvy));
#endif
gl_FragColor = vec4(mapN,255.0);
}
ask me if you need further help...