#version 100 precision mediump float; // The inputs from the vertex shader // - color of the vertex // - texture coordinates varying vec4 v_color; varying vec2 v_texCoords; // The texture used for the object // It is a constant (uniform) accross all vertices. uniform sampler2D u_texture; // The main program starts here. #extension GL_OES_standard_derivatives : enable void main(void) { // Compute the color from the texture and texture coordinates vec4 color = texture2D(u_texture, v_texCoords); vec2 coord = v_texCoords.xy; // Compute anti-aliased world-space grid lines vec2 grid = abs(fract(coord - 0.5) - 0.5) / fwidth(coord); float line = min(grid.x, grid.y); // Just visualize the grid lines directly gl_FragColor = vec4(vec3(1.0 - min(line, 1.0)), 1.0); // Compute the final color by multiplying with the color of the object //gl_FragColor = color * v_color; }