PDA

View Full Version : Smooth/think line rasterization in 3.2 core profile



mlfarrell
01-01-2014, 03:44 PM
Hello

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?

Dark Photon
01-02-2014, 08:37 AM
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.

tksuoran
01-02-2014, 02:49 PM
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.

malexander
01-02-2014, 03:03 PM
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.

tksuoran
01-03-2014, 04:30 AM
You can still use line widths > 1.0 in the core profile

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.

Remember that forward compatibility should only be used during development, and never in release builds.

mlfarrell
01-03-2014, 06:35 PM
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.

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?

Is there a way to get GL_VERSION to spit out 3.2 without losing legacy features?

arekkusu
01-03-2014, 07:19 PM
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.

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 (http://arek.bdmonkeys.net/bugs/invariance/HWAA.html) 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.

mlfarrell
01-03-2014, 09:00 PM
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.


Which goes back to my original argument, I shouldn't have to break my back to get thick lines just because I want to support new GL features. In other words, imo, there is no good solution to replace it in core profile, and I think it was a bad decision by the ARB to remove it in the first place.

malexander
01-04-2014, 10:37 AM
Again, wide lines are deprecated but not removed in the Core GL contexts. The GL ARB specifically mentions this in the GL 3.1 spec (Appendix G). Since the ARB went to the trouble of specifically singling out wide lines to be kept in the core profile, I somewhat doubt they'll be removed, especially since they seem to have stopped deprecating and removing features. You can use this on OSX and all other core GL implementations, unless you're adverse to using a deprecated feature.

mlfarrell
01-04-2014, 11:00 AM
interesting. I tried it the other day and I could've sworn that it wasn't working. Maybe lines > 1.0 + glsl version 150 won't work.

Either way, I found these articles and I'm gonna use them to do it a better way.

http://www.codeproject.com/Articles/199525/Drawing-nearly-perfect-2D-line-segments-in-OpenGL
http://www.twodee.org/weblog/?p=805

slime73
01-04-2014, 02:50 PM
Again, wide lines are deprecated but not removed in the Core GL contexts. The GL ARB specifically mentions this in the GL 3.1 spec (Appendix G). Since the ARB went to the trouble of specifically singling out wide lines to be kept in the core profile, I somewhat doubt they'll be removed, especially since they seem to have stopped deprecating and removing features. You can use this on OSX and all other core GL implementations, unless you're adverse to using a deprecated feature.

Wide lines are not supported in OS X core profile contexts.
https://developer.apple.com/graphicsimaging/opengl/capabilities/

malexander
01-05-2014, 09:29 PM
That's a good point, you do have to check the GL_LINE_WIDTH_RANGE (or GL_SMOOTH_LINE_WIDTH_RANGE, if you are using smooth lines). Both AMD and Nvidia drivers on Linux and Windows support the same aliased line ranges in the core profile as they do in the compatibility (AMD: 1 63, Nvidia: 0.5, 10). Intel graphics has a range of 1,1 (no line widths other than 1 are supported). Apple isn't known for supporting deprecated features, so they apparently set it to 1,1 as well.