diff --git a/shader/twoD/arc.frag b/shader/twoD/arc.frag index a6fcfcc82..7057e65d9 100644 --- a/shader/twoD/arc.frag +++ b/shader/twoD/arc.frag @@ -1,34 +1,34 @@ #version 430 core in vec4 gColor; -in vec2 cenPosT; in float gRadIn; -in float gRadOut; in vec2 angles; +in vec2 dist; out vec4 fColor; -out float gl_FragDepth; -uniform float rotation; +//uniform float rotation; void main() { - vec2 pos = gl_FragCoord.xy; - float d = distance(pos,cenPosT); - float dTest = max ( step(gRadOut/2,d) - , 1 - step(gRadIn/2,d) - ); - - vec2 posDiff = pos - cenPosT; - float sa = angles.x - rotation; +// vec2 pos = gl_FragCoord.xy; +// float d = distance(pos,cenPosT); +// float dTest = max ( step(gRadOut/2,d) +// , 1 - step(gRadIn/2,d) +// ); +// +// vec2 posDiff = pos - cenPosT; + float sa = angles.x; vec2 sv = vec2 (-sin(sa), cos(sa)); - float saTest = dot(sv,posDiff) >= 0 ? 0 : 1; - float ea = angles.y - rotation; +// float saTest = dot(sv,posDiff) >= 0 ? 0 : 1; + float ea = angles.y; vec2 ev = vec2 (-sin(ea), cos(ea)); - float eaTest = dot(ev,posDiff) <= 0 ? 0 : 1; - float aTest = ea - sa < radians(180) ? max (saTest,eaTest) - : min (saTest,eaTest); - - float onArcTest = max(dTest,aTest); - - gl_FragDepth = max(gl_FragCoord.z , onArcTest); +// float eaTest = dot(ev,posDiff) <= 0 ? 0 : 1; +// float aTest = ea - sa < radians(180) ? max (saTest,eaTest) +// : min (saTest,eaTest); +// +// float onArcTest = max(dTest,aTest); +// +// gl_FragDepth = max(gl_FragCoord.z , onArcTest); + float d = (dist.x * dist.x) + (dist.y * dist.y); + if (d > 1 || d < gRadIn || dot(sv, dist) < 0 || dot(ev, dist) > 0) {discard;} fColor = gColor; } diff --git a/shader/twoD/arc.geom b/shader/twoD/arc.geom index 3d2887290..ad9ab75d8 100644 --- a/shader/twoD/arc.geom +++ b/shader/twoD/arc.geom @@ -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(); diff --git a/shader/twoD/arc.vert b/shader/twoD/arc.vert index 69e1eb501..942525aad 100644 --- a/shader/twoD/arc.vert +++ b/shader/twoD/arc.vert @@ -13,7 +13,8 @@ uniform mat4 worldMat; void main() { - gl_Position = worldMat * vec4(position.xyz,1); + //gl_Position = worldMat * vec4(position.xyz,1); + gl_Position = vec4(position.xyz,1); vColor = color; vparams = saEaRadWdth; } diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index f54b42fe5..4504c4753 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -95,7 +95,7 @@ defaultWorld = World , _midgroundDecorations = [setDepth (-0.1) $ color orange $ pictures [ polygon $ rectNSEW 50 40 140 (-20) - , translate 60 45 $ thickArc 0 pi 75 10 + , translate 60 45 $ scale 0.5 1 $ thickArc 0 pi 75 10 ] ] }