Refactor arc shader so it uses only matrix uniform

This commit is contained in:
2021-06-10 11:52:39 +02:00
parent 822db37a58
commit e016d3aa9e
4 changed files with 39 additions and 38 deletions
+15 -15
View File
@@ -5,32 +5,32 @@ in vec4 vColor [];
in vec4 vparams [];
out vec4 gColor;
out float gRadIn;
out float gRadOut;
out vec2 cenPosT;
out vec2 angles;
out vec2 dist;
uniform vec2 winSize;
uniform float zoom;
uniform mat4 worldMat;
void main()
{
angles = vparams[0].xy;
vec3 cenPos = gl_in[0].gl_Position.xyz;
vec4 cenPos = gl_in[0].gl_Position;
gColor = vColor[0];
float width = vparams[0].w * 0.5;
float rad = vparams[0].z;
gRadOut = (rad + width) * zoom * 2;
gRadIn = (rad - width) * zoom * 2;
float width = vparams[0].w ;
float rad = vparams[0].z + width;
gRadIn = 1 - width * 2 / rad;
// I am not currently sure why the multiplicand is 4 and not 2
cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y);
gl_Position = vec4 (cenPos.x + gRadOut/winSize.x, cenPos.y + gRadOut/winSize.y, cenPos.z , 1);
gl_Position = worldMat * vec4 (cenPos.x + rad, cenPos.y + rad, cenPos.z , 1);
dist = vec2 (1,1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRadOut/winSize.x, cenPos.y + gRadOut/winSize.y, cenPos.z , 1);
gl_Position = worldMat * vec4 (cenPos.x - rad, cenPos.y + rad, cenPos.z , 1);
dist = vec2 (-1,1);
EmitVertex();
gl_Position = vec4 (cenPos.x + gRadOut/winSize.x, cenPos.y - gRadOut/winSize.y, cenPos.z , 1);
gl_Position = worldMat * vec4 (cenPos.x + rad, cenPos.y - rad, cenPos.z , 1);
dist = vec2 (1,-1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRadOut/winSize.x, cenPos.y - gRadOut/winSize.y, cenPos.z , 1);
gl_Position = worldMat * vec4 (cenPos.x - rad, cenPos.y - rad, cenPos.z , 1);
dist = vec2 (-1,-1);
EmitVertex();
EndPrimitive();