uniform float px;
uniform float py;
uniform sampler2D nmap;
void main() {
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position,1.0);
}
uniform float px;
uniform float py;
uniform sampler2D nmap;
void main() {
float tx = 500.0;
float ty = 500.0;
float wx = gl_FragCoord.x;
float wy = gl_FragCoord.y;
float gx = floor(wx / tx);
float gy = floor(wy / ty);
float ix = mod(wx, tx);
float iy = mod(wy, ty);
float ipx = mod(px, tx);
float ipy = mod(py, ty);
float fx = ix / tx;
float fy = iy / ty;
vec3 l = vec3(px, py, 100);
vec3 z = vec3(wx, wy, 0);
vec3 n = texture2D(nmap, vec2(fx, fy)).xyz * 2.0 - 1.0;
vec3 d = normalize(l - z);
float c = max(0.0, dot(d, n)) * 0.1;
gl_FragColor = vec4(c,
c,
c,
1.0); // A
}