diff --git a/shader/picture/arc.frag b/shader/picture/arc.frag new file mode 100644 index 000000000..f8595b223 --- /dev/null +++ b/shader/picture/arc.frag @@ -0,0 +1,13 @@ +#version 450 core +in vec4 vCol; +in vec3 vPos; +in vec3 vparams; +layout (location=0) out vec4 fCol; +layout (location=1) out vec4 fPos; +void main() +{ + float d = (dot(vec2(vparams.xy),vec2(vparams.xy))); + if ( d > 1 || d < (vparams.z * vparams.z) ) {discard;} + fCol = vCol; + fPos = vec4(vPos,1); +} diff --git a/shader/picture/arc.vert b/shader/picture/arc.vert new file mode 100644 index 000000000..27c400171 --- /dev/null +++ b/shader/picture/arc.vert @@ -0,0 +1,15 @@ +#version 450 core +struct PosColBox { vec4 pos; vec4 col; vec4 box; }; +layout (std430, binding = 12) readonly buffer Data { PosColBox data[]; }; +layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; +layout (location = 0) uniform int layoff; +out vec4 vCol; +out vec3 vPos; +out vec3 vparams; +void main() { + vec4 p = data[gl_VertexID].pos; + gl_Position = theMat * p; + vCol = data[gl_VertexID].col; + vparams = data[gl_VertexID].box.xyz; + vPos = p.xyz; +} diff --git a/shader/picture/basic.frag b/shader/picture/basic.frag new file mode 100644 index 000000000..62e8b8b09 --- /dev/null +++ b/shader/picture/basic.frag @@ -0,0 +1,10 @@ +#version 450 core +in vec4 vCol; +in vec3 vPos; +layout (location=0) out vec4 fCol; +layout (location=1) out vec4 fPos; +void main() +{ + fCol = vCol; + fPos = vec4(vPos,1); +} diff --git a/shader/picture/basic.vert b/shader/picture/basic.vert new file mode 100644 index 000000000..5b858b5e9 --- /dev/null +++ b/shader/picture/basic.vert @@ -0,0 +1,13 @@ +#version 450 core +struct PosCol { vec4 pos; vec4 col; }; +layout (std430, binding = 10) readonly buffer Data { PosCol data[]; }; +layout (location = 0) uniform int layoff; +layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; +out vec4 vCol; +out vec3 vPos; +void main() { + vec4 p = data[gl_VertexID].pos; + gl_Position = theMat * p; + vCol = data[gl_VertexID].col; + vPos = p.xyz; +} diff --git a/shader/picture/ellipse.frag b/shader/picture/ellipse.frag new file mode 100644 index 000000000..576a4c13c --- /dev/null +++ b/shader/picture/ellipse.frag @@ -0,0 +1,14 @@ +#version 450 core +layout (location=0) out vec4 fCol; +layout (location=1) out vec4 fPos; +in vec4 gColC; +in vec4 gColE; +in vec3 gPos; +in vec2 gBoundingBox; +void main() { + float d = dot(gBoundingBox,gBoundingBox); + if ( d > 1) { discard; } + fCol = mix (gColE , gColC, d); + fPos = vec4(gPos,1); + +} diff --git a/shader/picture/ellipse.vert b/shader/picture/ellipse.vert new file mode 100644 index 000000000..21ec496cb --- /dev/null +++ b/shader/picture/ellipse.vert @@ -0,0 +1,33 @@ +#version 450 core +struct PosCol { vec4 posx; vec4 colx; }; +layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; +layout (std430, binding = 13) readonly buffer Data { PosCol data[]; }; +layout (location = 0) uniform int n; +out vec4 gColC; // center color +out vec4 gColE; // edge color +out vec2 gBoundingBox; +out vec3 gPos; +const int ks[6] = // + {1,0,2 // 2--3 + ,2,0,3 // | | + }; // 1--0 + // +const vec2 bs[4] = + { vec2( 1, 1) + , vec2(-1, 1) + , vec2(-1,-1) + , vec2( 1,-1) + } ; +void main() +{ + int i0 = n + (3 * ((gl_VertexID-n)/6) ); + gColC = data[i0].colx; + gColE = data[i0+1].colx; + int k = ks[(gl_VertexID - n) % 6]; + gBoundingBox = bs[k]; + gPos = (k > 2.5 + ? data[i0].posx + data[i0+2].posx - data[i0+1].posx + : data[i0+k].posx + ).xyz; + gl_Position = theMat * vec4(gPos,1); +}