1# pass an basic component layout through vs->tcs->tes->fs. 2 3[require] 4GLSL >= 1.50 5GL_ARB_arrays_of_arrays 6GL_ARB_enhanced_layouts 7GL_ARB_tessellation_shader 8GL_ARB_separate_shader_objects 9 10[vertex shader] 11#extension GL_ARB_enhanced_layouts: require 12#extension GL_ARB_separate_shader_objects: require 13 14in vec4 vertex; 15 16// consume Y/Z/W components 17layout(location = 0, component = 1) out vec3 a; 18 19// consumes X component 20layout(location = 0) out float b; 21 22void main() 23{ 24 gl_Position = vertex; 25 26 a = vec3(0.0, 0.75, 1.0); 27 b = 0.25; 28} 29 30 31[tessellation control shader] 32#extension GL_ARB_arrays_of_arrays: require 33#extension GL_ARB_enhanced_layouts: require 34#extension GL_ARB_tessellation_shader: require 35#extension GL_ARB_separate_shader_objects: require 36 37layout(vertices = 3) out; 38 39// consume Y/Z/W components 40layout(location = 0, component = 1) in vec3 a[]; 41 42// consumes X component 43layout(location = 0) in float b[]; 44 45// consume Y/Z/W components 46layout(location = 0, component = 1) out vec3 a_tcs[]; 47 48// consumes X component 49layout(location = 0) out float b_tcs[]; 50 51void main() { 52 gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; 53 gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 0.0); 54 gl_TessLevelInner = float[2](0.0, 0.0); 55 a_tcs[gl_InvocationID] = a[gl_InvocationID]; 56 b_tcs[gl_InvocationID] = b[gl_InvocationID]; 57} 58 59 60[tessellation evaluation shader] 61#extension GL_ARB_arrays_of_arrays: require 62#extension GL_ARB_enhanced_layouts: require 63#extension GL_ARB_tessellation_shader: require 64#extension GL_ARB_separate_shader_objects: require 65 66layout(triangles) in; 67 68// consume Y/Z/W components 69layout(location = 0, component = 1) in vec3 a_tcs[]; 70 71// consumes X component 72layout(location = 0) in float b_tcs[]; 73 74// consume Y/Z/W components 75layout(location = 0, component = 1) out vec3 a_tes; 76 77// consumes X component 78layout(location = 0) out float b_tes; 79 80void main() { 81 gl_Position = gl_in[0].gl_Position * gl_TessCoord[0] 82 + gl_in[1].gl_Position * gl_TessCoord[1] 83 + gl_in[2].gl_Position * gl_TessCoord[2]; 84 85 a_tes = a_tcs[0]; 86 b_tes = b_tcs[0]; 87} 88 89 90[fragment shader] 91#extension GL_ARB_enhanced_layouts: require 92#extension GL_ARB_separate_shader_objects: require 93 94// consume Y/Z/W components 95layout(location = 0, component = 1) in vec3 a_tes; 96 97// consumes X component 98layout(location = 0) in float b_tes; 99 100void main() 101{ 102 gl_FragColor = vec4(b_tes, a_tes); 103} 104 105[vertex data] 106vertex/float/2 107-1.0 -1.0 108 1.0 -1.0 109-1.0 1.0 110-1.0 1.0 111 1.0 -1.0 112 1.0 1.0 113 114[test] 115clear color 0.1 0.1 0.1 0.1 116clear 117patch parameter vertices 3 118draw arrays GL_PATCHES 0 6 119probe all rgba 0.25 0.0 0.75 1.0 120