🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

OpenGL 4 hidden line removal

Started by
9 comments, last by JoeJ 1 year, 7 months ago

I'm having little luck when it comes to hidden line removal in OpenGL 4.

Right now I'm using the glDepthRange method, but it is not perfect:

Do you know of any other solution?

Advertisement

What's the origin of those lines?

Shadow mapping acne? Z-Fighting? Something weird with how you generate your reflections?

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

There are 3 lines per triangle, one per edge. Yes, I'm sure that it's an issue with the depth buffer, given the use of glDepthRange. I also tried glPolygonOffset, with no luck really.

I guess the cause of the artifact is that you generate edge quads with their plane aligned normal to the camera?
If so, half of the quad is above the surface in empty space, so looking at depth alone will not tell the lines should be hidden, because there is nothing in front of them.

Not sure. I wonder why the artifact does not show over all the scene, if i'm right.

However, the solution is to draw no lines if the edge is flat or convex. So you need some adjacency information to know this. Unfortunately, mesh formats intended only for rendering have no adjacency information. But you could use the volumetric voxel data for a quick and robust solution.

Btw, the image is a good example of what i have expected when proposing per object silhouettes: Too much lines, which have no artistic origin, but come from the voxel quantization.
Tackling this would require a different way of filtering lines, so you want to decide now to avoid wasting time on only a partial solution, which later turns out to be redundant.
I would also consider to give up on the lines for now.

You are correct, once again. Here is a shader that takes advantage of adjacency data:

https://github.com/daw42/glslcookbook/blob/master/chapter06/shader/silhouette.gs

I shall strive to integrate this example with my code.

Finding adjacent triangles is the simplest part. It's getting those data into the shader that I'll struggle with.

Thanks again!

I just noticed you may have forgotten to mirror the lights when rendering the reflections. They seem very bright at their down side.

There is no need to alter the light position, or any other model matrix for any object, in the end. This is because I used simply camera_view_mat = scale(camera_view_mat, vec3(1, -1, 1)); at the beginning of the draw function, and everything follows suit by not having to account for whether or not a thing needs to be manually flipped or not.

P.S. I believe that this solution only works for cameras where the lookat is effectively vec3(0, 0, 0).

p.p.s.

LOL you really don't like those lines eh? ??

I’m going to take one last attempt at it, then I’ll put it aside if I can’t figure it out. I figure that ill send in the camera position and lookat, then compare that to the surface normal in the geometry shader.

Well, the problem appears to be fixed now that I’ve drawn the lines before I draw the triangles, using heuristically derived values for glDepthRange.

taby said:
LOL you really don't like those lines eh? ??

Yeah, there are quite a few issues:
They do not fuse well with CGI artstyle using DOF and reflections.
They usually try to imitate manual line art, where they are used to express curvature. But voxels have no curves, instead we amplify their quantization restrictions.
Actually they are imperfect at the vertices, showing discontinuities. This issue can be fixed technically, though.

So yeah, in this case i do not really like them.
But i also dislike their use in games such as Borderlands, or some older Tell Tale games.
In those games they mix edge detection (right), with manually painting lines into textures (wrong).
It's wrong, because lines should fade in and out depending on the eye vector and lighting, so painting them statically into textures is as wrong as painting lighting into textures.
The result looks bad and amateurish to me for both artistic and technical reasons. It's bad enough i can't play those games because i hate their visuals. But obviously many people like such artstyle.

What i do like is games with accurate anime artstyle, using such lines correctly. Never played one, but i like how close to hand drawn they sometimes get.
Those games also often have better character rigging then the average western game. Guilty Gear is a great example.

This topic is closed to new replies.

Advertisement