Commit f05111fd authored by Ken Martin's avatar Ken Martin
Browse files

Update surface with edges

Update the approach to only draw pixels that are within the
triangle as opposed to outside of it. This fixes the overlay
lines that can show up with transparency and makes the shader
simpler and faster.

Downside is that the edges on non-manifold surfaces are half width
when previously they were closer to whole width.

See vtk/vtk#18064
parent 6c788bf1
Pipeline #212227 running with stage
......@@ -80,20 +80,6 @@ void main()
edgeEqn[i] = vec4(tmp.x, tmp.y, 0.0, -d);
}
vec2 offsets[3];
offsets[0] = edgeEqn[2].xy + edgeEqn[0].xy;
offsets[0] = -0.5*normalize(offsets[0])*lineWidth;
offsets[0] /= vpDims.zw;
offsets[1] = edgeEqn[0].xy + edgeEqn[1].xy;
offsets[1] = -0.5*normalize(offsets[1])*lineWidth;
offsets[1] /= vpDims.zw;
offsets[2] = edgeEqn[1].xy + edgeEqn[2].xy;
offsets[2] = -0.5*normalize(offsets[2])*lineWidth;
offsets[2] /= vpDims.zw;
//VTK::Edges::Impl
for (int i = 0; i < 3; i++)
......@@ -120,7 +106,6 @@ void main()
// gl_Position = gl_in[i].gl_Position;
gl_Position = gl_in[i].gl_Position;
gl_Position.xy = gl_Position.xy + offsets[i]*gl_Position.w;
EmitVertex();
}
......
......@@ -698,21 +698,13 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderEdges(
std::string fsimpl =
// distance gets larger as you go inside the polygon
"float edist[3];\n"
"edist[0] = dot(edgeEqn[0].xy, gl_FragCoord.xy) + edgeEqn[0].w;\n"
"edist[1] = dot(edgeEqn[1].xy, gl_FragCoord.xy) + edgeEqn[1].w;\n"
"edist[2] = dot(edgeEqn[2].xy, gl_FragCoord.xy) + edgeEqn[2].w;\n"
"edist[0] = dot(edgeEqn[0].xy, gl_FragCoord.xy) + edgeEqn[0].w + edgeEqn[0].z;\n"
"edist[1] = dot(edgeEqn[1].xy, gl_FragCoord.xy) + edgeEqn[1].w + edgeEqn[1].z;\n"
"edist[2] = dot(edgeEqn[2].xy, gl_FragCoord.xy) + edgeEqn[2].w + edgeEqn[2].z;\n"
// "if (abs(edist[0]) > 0.5*lineWidth && abs(edist[1]) > 0.5*lineWidth && abs(edist[2]) >
// 0.5*lineWidth) discard;\n"
"if (edist[0] < -0.5 && edgeEqn[0].z > 0.0) discard;\n"
"if (edist[1] < -0.5 && edgeEqn[1].z > 0.0) discard;\n"
"if (edist[2] < -0.5 && edgeEqn[2].z > 0.0) discard;\n"
"edist[0] += edgeEqn[0].z;\n"
"edist[1] += edgeEqn[1].z;\n"
"edist[2] += edgeEqn[2].z;\n"
"float emix = clamp(0.5 + 0.5*lineWidth - min( min( edist[0], edist[1]), edist[2]), 0.0, "
"1.0);\n";
......
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