#version 450 core struct PosTex { vec4 pospos; vec4 texang; }; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std140, binding = 1) uniform TheLight { vec4 lightPos; vec4 colrad; }; layout (std430, binding = 2) readonly buffer Pos { PosTex data[]; }; float rad = colrad.w; int indices[18] = {5,7,1 // 6----7 ,7,3,1 // /| /| ,7,6,3 // 2-+--3 | ,6,2,3 // | 4 | 5 ,6,4,2 // 0 1 ,4,0,2 }; vec2 shift(vec2 p) { return vec2(lightPos.xy + (rad * normalize(p - lightPos.xy))); } float detV(vec2 p, vec2 q) { return p.x*q.y - p.y*q.x; } float isLHS(vec2 p, vec2 q) { return sign(-detV(p,q)); } void main() { vec4 pp = data[gl_VertexID / 18].pospos; int j = indices[gl_VertexID % 18]; vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw); float z = ((j / 2) % 2 > 0.5 ? 100 : -500); vec2 xyo = ( j > 3.5 ? shift(xy) : xy); vec4 p = theMat * vec4(xyo,z,1); gl_Position = (isLHS(pp.xy-lightPos.xy,pp.zw-lightPos.xy) < 0 ? p : vec4(1,1,1,0)); }