zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
114 stars 22 forks source link

drawVertices draws back-faces #96

Closed m-7761 closed 4 years ago

m-7761 commented 4 years ago

This recommendation deals with this code: https://github.com/zturtleman/mm3d/issues/95

The problem is when back faces are hidden, vertices using GL_POINTS aren't eliminated. So what I recommend is drawVertices and drawLines sharing a common subroutine, that draws triangles, and uses glPolygonMode.

I further recommend using GL_LESS with glDepthFunc so that pixels are rejected, except for the red selection, with a two-pass loop. #95 goes into this. I think it helps to use 50/50 alpha for unselected edges, but not vertices. It makes them appear thinner, and helps vertices stand out.

EDITED: There's more problems... see next reply.

m-7761 commented 4 years ago

MORE RELATED ISSUES

The back-face mode is actually not implemented by the "Canvas" views. It works in the non wireframe modes, because it leaks from Model::draw. And on my project with shared context, it leaks from the perspective views too.

To enable it DO_BACKFACECULL must be consulted around the following lines:

    model->drawLines();
    model->drawVertices();

But I've m_drawOptions to store some of these settings in model, so I've opted to have drawLines/Vertices consult those automatically.

In another topic I lamented that culling doesn't work in the ortho views... I thought I was mistaken, but I guess not. It's much easier to work on a model oftentimes with the noise from back faces removed from the flurry of wireframes.

m-7761 commented 4 years ago

CLOSED:

This isn't technically at issue. The back-face mode does leak (see excerpt below) but it doesn't matter as long as GL_LINES and GL_POINTS are used.

https://github.com/zturtleman/mm3d/blob/dcb15f3440a62376ed2e09d01960b58426c13ef6/src/depui/modelviewport.cc#L480

I think it's very helpful to be able to hide back-faces in wireframe views. Although it's not without side effects, since the vertices on the silhouette kind of pop in and out of existence... and selecting vertices, etc. still selects the hidden elements. I am going to make the red selection disable depth-test I think, so that it's visible, even when faces are hiding it.

(It might be possible to stipple the lines of the back-faces, less so vertices.)