[require] GLSL >= 1.50 GL_ARB_fragment_layer_viewport [vertex shader passthrough] [geometry shader] #version 150 layout(triangles) in; layout(triangle_strip, max_vertices=3) out; uniform int layer; void main() { for (int i = 0; i < 3; i++) { gl_Position = gl_in[i].gl_Position; gl_Layer = layer; EmitVertex(); } } [fragment shader] #version 150 #extension GL_ARB_fragment_layer_viewport: require uniform int layer; void main() { if (gl_Layer == layer) gl_FragColor = vec4(0,1,0,0); else gl_FragColor = vec4(1,0,0,0); } [test] clear color 0.0 0.0 0.0 0.0 clear uniform int layer 0 draw rect -1 -1 1 1 uniform int layer 1 draw rect 0 -1 1 1 uniform int layer 10000 draw rect -1 0 1 1 uniform int layer -10000 draw rect 0 0 1 1 probe all rgb 0.0 1.0 0.0