#version 120 void main(void) { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; float x = gl_Position.x; float y = gl_Position.y; float z = gl_Position.z; int depth = int(sqrt(x * x + y * y + z * z)); if (depth < 800) { depth = 0; } if (depth > 9000) { depth = 9000; } float fRed = 0; float fBlue = 0; float fGreen = 0; if (depth < 1500) { int adj_depth = depth; // Red to yellow fRed = 1.0; fGreen = float(adj_depth) / 1500; } if (depth >= 1500 && depth < 3000) { // Yellow to green int adj_depth = depth - 1500; fGreen = 1.0; fRed = 1.0 - (float(adj_depth) / 1500); } if (depth >= 3000 && depth < 4500) { // Green to Cyan int adj_depth = depth - 3000; fGreen = 1.0; fBlue = float(adj_depth) / 1500; } if (depth >= 4500 && depth < 6000) { // Cyan to Blue int adj_depth = depth - 4500; fBlue = 1.0; fGreen = 1.0 - (float(adj_depth) / 1500); } if (depth >= 6000 && depth < 7500) { // Blue to Magenta int adj_depth = depth - 6000; fBlue = 1.0; fRed = float(adj_depth) / 1500; } if (depth >= 1500 && depth < 3000) { // Magenta to Red int adj_depth = depth - 7500; fRed = 1.0; fBlue = 1.0 - (float(adj_depth) / 1500); } gl_FrontColor = vec4(fRed, fGreen, fBlue, 1.0); }