
Tue, 11/01/2022 - 07:03
Hi,
We are building a product with Visualisation that relies on line rendering with variable widths.
Recently, we changed the windowing framework for our Viewport. Everything worked as expected, except lines are now only 1px thick everywhere, despite changing the Prs3d_LineAspect width.
After some investigation, we suspected that this is due to OpenCASCADE code that still uses the fixed function pipeline to set line width, despite there existing a new shader uniform named occLineWidth
to address this;
Graphic3d_ShaderManager.cxx:207
EOL" float aMixVal = smoothstep (occLineWidth - occLineFeather * 0.5, occLineWidth + occLineFeather * 0.5, aDistance);"
OpenGL_Context.cxx:2508
if (myGapi == Aspect_GraphicsLibrary_OpenGLES
|| core11ffp != NULL)
{
// glLineWidth() is still defined within Core Profile, but has no effect with values != 1.0f
core11fwd->glLineWidth (theWidth * myLineWidthScale);
}
When changing our OpenGL context to use the Compatibility
profile, the line rendering returns to the old, desired behavior.
Is it intended for line width to affect rendering when using the Core
profile of OpenGL? Are we misusing the visualisation API? Is code similar to the below needed somewhere?
auto shaderLoc = ActiveProgram()->GetStateLocation(OpenGl_OCCT_LINE_WIDTH);
ActiveProgram()->SetUniform(glContext, shaderLoc, theWidth * myLineWidthScale);
Thanks
Tue, 11/01/2022 - 07:45
Core Profile doesn't support line widths other than 1 pixel - that's all. You cannot change this in a shader or whatever. The only way to draw a thick line in Core Profile is to emulate it via triangles. It is a limitation of OpenGL itself.
Wed, 11/02/2022 - 02:01
Ah right, makes sense I guess the uniform in the shader is for wireframes on mesh presentations. I'll instead try to make a custom line object using
AIS
and polygonsThanks!