polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

Backface colors flipped when using different and custom backface shading

Open sgsellan opened this issue 1 year ago • 1 comments

Hi!

I am using polyscope in python on my intel Mac. When I read this mesh and choose the "backface shading -> custom" option, all faces assume the "inverted" color, despite this mesh being definitely not inverted. Here's a MWE:

import igl
import polyscope as ps
V, _, N, F, _, _ = igl.read_obj("test/unit_tests_data/bunny_oded.obj")
ps.init()
ps.register_surface_mesh("bunny", V,F)
ps.show()

Here is what I see:

Screenshot 2023-07-03 at 11 28 37 PM

sgsellan avatar Jul 04 '23 21:07 sgsellan

After some debugging, it seems that this may actually be due to the underlying graphics drivers. This shader is the one place we use gl_FrontFacing There are scattered posts online that gl_FrontFacing is broken on certain OSX openGL driver versions.

We could potentially work around this by rewriting the shader to manually test for front-facingness using screen space derivatives, but that would presumably decrease performance on non-broken platforms.

It would be good to find some fix for this, but I'm not sure what the right fix is. (Also, can we confirm that this is a broken gl_FrontFacing somehow, and figure out which platforms are effected?)

nmwsharp avatar Jul 04 '23 22:07 nmwsharp