attribute vec4 attributePosition varying vec3 vertexColor ... void main() { float x = 0.0; float y = 0.0; float z = 0.0; if (attributePosition[0] > 0) { x = 1.0; } ... vertexColor = vec3(x,y,z); }