[require] GLSL >= 1.10 [vertex shader] varying vec4 pos; void main() { gl_Position = gl_Vertex; pos = gl_Vertex; } [fragment shader] varying vec4 pos; vec4 y_adjust(vec4 pos) { vec4 x; if (pos.x > 0.0) x = vec4(-0.5, 0.0, 0.0, 0.0); else x = vec4(1.5, 0.0, 0.0, 0.0); if (pos.y > 0.0) return vec4(0.0, -0.5, 0.5, 0.0) + x; else return vec4(0.0, 1.5, 0.5, 0.0) + x; } void main() { gl_FragColor = sign(pos) + y_adjust(pos); } [test] draw rect -1 -1 2 2 probe all rgb 0.5 0.5 0.5 0.5