Commit e8ec00fd authored by Sylvain Thery's avatar Sylvain Thery

line drawing ok

parent 0c420188
......@@ -31,15 +31,14 @@ void main()
A = A/A.w;
B = B/B.w;
vec2 U2 = normalize((B.xyz - A.xyz).xy);
vec3 U = vec3(lineWidths*U2,0.0);
vec3 V = vec3(lineWidths*vec2(U2[1], -U2[0]), 0.0);
// U2 *= (lineWidths[0]+lineWidths[1])/2.0;
vec2 U2 = normalize(vec2(lineWidths[1],lineWidths[0])*(B.xy - A.xy));
vec2 LWCorr =lineWidths * max(abs(U2.x),abs(U2.y));
vec3 U = vec3(LWCorr*U2,0.0);
vec3 V = vec3(LWCorr*vec2(U2[1], -U2[0]), 0.0);
fragClip = posClip[0];
fragColor = vcolor[0];
// A -= vec4(U2,0.0,0.0);
gl_Position = vec4(A.xyz-U, 1.0);
EmitVertex();
gl_Position = vec4(A.xyz+V, 1.0);
......@@ -49,7 +48,6 @@ void main()
fragClip = posClip[1];
fragColor = vcolor[1];
// B += vec4(U2,0.0,0.0);
gl_Position = vec4(B.xyz+V, 1.0);
EmitVertex();
gl_Position = vec4(B.xyz-V, 1.0);
......
......@@ -9,7 +9,7 @@ void main()
{
vec4 A = POSITION_IN(0);
vec4 B = POSITION_IN(1);
float nearZ = 1.0;
if (ProjectionMatrix[2][2] != 1.0)
nearZ = - ProjectionMatrix[3][2] / (ProjectionMatrix[2][2] - 1.0);
......@@ -23,12 +23,13 @@ void main()
A = ProjectionMatrix*A;
B = ProjectionMatrix*B;
A = A/A.w;
B = B/B.w;
vec2 U2 = normalize((B.xyz - A.xyz).xy);
vec3 U = vec3(lineWidths*U2,0.0);
vec3 V = vec3(lineWidths*vec2(U2[1], -U2[0]), 0.0);
vec2 U2 = normalize(vec2(lineWidths[1],lineWidths[0])*(B.xy - A.xy));
vec2 LWCorr =lineWidths * max(abs(U2.x),abs(U2.y));
vec3 U = vec3(LWCorr*U2,0.0);
vec3 V = vec3(LWCorr*vec2(U2[1], -U2[0]), 0.0);
fragClip = posClip[0];
gl_Position = vec4(A.xyz-U, 1.0);
......@@ -45,6 +46,7 @@ void main()
EmitVertex();
gl_Position = vec4(B.xyz+U, 1.0);
EmitVertex();
EndPrimitive();
}
}
......@@ -31,14 +31,11 @@ void main()
A = A/A.w;
B = B/B.w;
vec2 U2 = normalize((B.xyz - A.xyz).xy);
vec3 V = vec3(lineWidths*vec2(U2[1], -U2[0]), 0.0)*3.0;
U2 *= (lineWidths[0]+lineWidths[1])/2.0;
vec3 U = vec3(U2,0.0)*3.0;
// vec3 U3 = normalize(B.xyz - A.xyz);
// U3 *= (lineWidths[0]+lineWidths[1])/2.0;
vec2 U2 = normalize(vec2(lineWidths[1],lineWidths[0])*(B.xy - A.xy));
vec2 LWCorr =lineWidths * max(abs(U2.x),abs(U2.y));
vec3 U = vec3(LWCorr*U2,0.0) * 3.0;
vec3 V = vec3(LWCorr*vec2(U2[1], -U2[0]), 0.0)*3.0;
fragClip = posClip[0];
fragColor = vcolor[0];
......
......@@ -24,17 +24,14 @@ void main()
A = ProjectionMatrix*A;
B = ProjectionMatrix*B;
A = A/A.w;
B = B/B.w;
vec2 U2 = normalize((B.xyz - A.xyz).xy);
vec3 V = vec3(lineWidths*vec2(U2[1], -U2[0]), 0.0)*3.0;
U2 *= (lineWidths[0]+lineWidths[1])/2.0;
vec3 U = vec3(U2,0.0)*3.0;
// vec3 U3 = normalize(B.xyz - A.xyz);
// U3 *= (lineWidths[0]+lineWidths[1])/2.0;
vec2 U2 = normalize(vec2(lineWidths[1],lineWidths[0])*(B.xy - A.xy));
vec2 LWCorr =lineWidths * max(abs(U2.x),abs(U2.y));
vec3 U = vec3(LWCorr*U2,0.0)*3.0;
vec3 V = vec3(LWCorr*vec2(U2[1], -U2[0]), 0.0)*3.0;
fragClip = posClip[0];
......
......@@ -31,9 +31,9 @@ namespace CGoGN
namespace Utils
{
#include "ShaderBold3DColorLines.vert"
#include "ShaderBold3DColorLines.geom"
#include "ShaderBold3DColorLines.frag"
#include "shaderBold3DColorLines.vert"
#include "shaderBold3DColorLines.geom"
#include "shaderBold3DColorLines.frag"
ShaderBold3DColorLines::ShaderBold3DColorLines() :
......
......@@ -23,6 +23,7 @@
*******************************************************************************/
#define CGoGN_UTILS_DLL_EXPORT 1
#include "Utils/Shaders/shaderBoldLines.h"
#include <algorithm>
namespace CGoGN
{
......@@ -88,6 +89,7 @@ void ShaderBoldLines::setLineWidth(float pix)
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
m_lineWidth[0] = pix / float(viewport[2]);
m_lineWidth[1] = pix / float(viewport[3]);
bind();
glUniform2fv(*m_uniform_lineWidth,1, m_lineWidth.data());
unbind();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment