#version 410 uniform float eyePos; uniform sampler2D texture1; uniform bool doTexture; in vec3 xyzV; out vec4 fragColor; vec3 mf(vec3 x) { return x - floor(x); } float pi = 3.141592653589793238; void main (void) { vec3 xyz = xyzV; float lon = atan(xyz.y, xyz.x); float lat = atan(xyz.z, length(xyz.xy)); vec2 b = vec2(lon,lat); vec2 c = b * 36.0 / 2.0 / pi; // marks ever 10 degrees ivec2 d = ivec2(c + vec2(10000,10000)); // for checkering, integer coords c -= floor(c); fragColor = vec4(c, 1.0, 1.0); float lineWidth = 0.032; float xThresh = lineWidth / cos(lat); // prevent narrowing of lines at the poles int oe = (d.x + d.y + 10000) % 2; fragColor = c.x < xThresh || c.y < lineWidth ? vec4(0.1, 0.9, 0.1, 1.0) : oe > 0 ? vec4(.3,.4,.2,1) : vec4(.6,.7,.8,2); fragColor *= vec4(.4,.4,.4,1); if(doTexture) { vec2 k = b / (2.0 * pi); k = b / vec2(2 * pi, pi); k = (k + vec2(1.0, 1.0) / 2.0); fragColor = (fragColor + texture(texture1, k)) / 2.0; fragColor = texture(texture1, k); } }