In short:
I have a heightmapped terrain, which has had its y value offset in the vertex shader.
Now I am looking to draw gridlines over the terrain, in the fragment shader.
I am able to sample colour from the heightmap texture in the fragment shader.
This what I've been attempting, but no luck. The idea is that the terrain is white, gridlines are black.
Terrain width is 1024. So is the texture.
Could somebody please suggest a method of testing whether the texture coord components, x, and y, are divisible by some number? and changing the pixel colour.
With this code I only get white terrain. :/
uniform sampler2D hmap_texture;
in vec2 texCoord;
layout (location=0) out vec4 fragColour;
void main(void) {
//vec4 colour = texture2D(hmap_texture, texCoord);
vec4 colour = vec4(1.0, 1.0, 1.0, 1.0);
if( mod(texCoord.x, 32) == 0) {
colour = vec4(0.0, 0.0, 0.0, 1.0)
}
if( mod(texCoord.y, 32) == 0) {
colour = vec4(0.0, 0.0, 0.0, 1.0)
}
fragColour = colour;
}
Many thanks.
Nathan