Smooth/think line rasterization in 3.2 core profile
Of all the deprecated features from 2.0 that I've been able to live with and mostly agree with, I got to say I strongly disagree with the decision to remove glLineWidth > 1.0 + smooth line rasterization from the core profile. Even GLES 2.0 supports this. As a developer of an engineering-like application, this sort of rendering is crucial to my pipeline, and now I've had to sacrifice it to get support for modern shader languages.
Can someone please point me to an alternative implementation that replaces the old line rendering with EXACT visual similarity to the old stuff?
Not what you asked, but you could just use the compatibility profile and exploit this feature, if it is offered by the GPU vendor(s) you're targetting. Possibily as a short-term solution or to compare against while you work out your own implementation.
Last edited by Dark Photon; 01-02-2014 at 07:48 AM.
You can do wide lines with geometry shader. I experimented with this a while back - see http://neure.dy.fi/wideline.html
I did not seek similar quality, but it should be possible to get pretty close. What I wanted back then was round line ends, which I achieved with by calculating distance to line segment in the fragment shader, rendering in multisample, and using alpha to coverage. To get results which are more like old line smooth, you probably would want to use blending instead of alpha to coverage, and calculate distance to line instead of line segment.
Note that non-multisample wide line rasterization in OpenGL is different, and IMO useless.
You can still use line widths > 1.0 in the core profile, and render to a multisample render target. That looks pretty decent for 4x multisample and above. The old smooth lines are pretty slow for a relatively large number of lines.
Edit: Assuming your GPU can handle it -- there are limits to the line thickness, usually topping out at 10.
While you can use wide lines in core profile, they are still deprecated. If you create a context with forward compatibility, wide lines are not supported.
Originally Posted by malexander
Remember that forward compatibility should only be used during development, and never in release builds.
Can you elaborate? I'm targeting osx only where I'm assuming 3.2 (and not higher, so I can't use geom shaders). Using compatability prevents me from being able to use shader language 150 isn't that true? Or am I missing something?
Originally Posted by tksuoran
Is there a way to get GL_VERSION to spit out 3.2 without losing legacy features?
Not on OSX. Legacy (Compatibility) = 2.1, else you get a Core (which is always forward-compatible, so all deprecated features are removed) context, = 3.2, 3.3, or 4.1 depending on the OS version and renderer.
Originally Posted by mlfarrell
But you can use geometry shaders in either profile, via EXT_geometry_shader4 in Compatibility, or as a GLSL 150+ feature in Core.
And, I'll propose that you really don't want to exactly emulate the appearance of GL's lines. If you think you do, spend more time carefully looking at the behavior of wide lines, AA, and line caps across all drivers. For consistency, you're better off rolling your own wide line segments (i.e. with a geometry shader: convert line strip (adjacency) to tri strips; find the line segment perpendicular vector after clip space projection, taking into account the viewport scale.) And then, if you like, you can ensure segments are joined or end caps are beveled better than GL does.