Page MenuHome

Selection: Add conservative rasterization to select really small objects
ClosedPublic

Authored by Clément Foucault (fclem) on Jan 29 2020, 8:06 PM.

Details

Summary

The conservative depth shader is ~4.5x slower than the normal one as it
uses geometry shader and fragment shader discard.

This patch also includes a hack to also fix the view parallel planar
geometry and the really small wire objects.

For some reason, the conservative raster fix does not work with normal
selection but does with box select.

This is a fix for T63356.

Diff Detail

Repository
rB Blender

Event Timeline

Testing this, it seems to work well in wireframe mode but doesn't resolve the issue of small objects not being selected.

In this test file:

  • De-select all
  • Border select in the left 3D view (Nothing is selected)

  • Shift-Z (switch to wireframe mode)
  • Border select in the left 3D view (All objects are selected)

Even when zoomed in to "centimeter" grid-units, selection isn't working.


The conservative rasterization should be accounting for small faces, I tried tweaking the constants, but it didn't make any difference:

#define THRESHOLD 1.19209290E-7F /* also tried 1.19209290E-12F .. some values in between. */ 
#define FLT_MAX 3.40282346638528859812e+38F

Testing an update to the hack/workaround I posted in reply to T63356, which does select objects in the test above (see P1237).

So I'm not sure if this is a limitation with the conservative rasterization or something that could be supported.

In this test file:

This test file is crazy extreme, the near and far plane values are so crazy that I think the selection problems comes from this. I cannot even see any of the tiny objects in solid mode.

For the other 2 more normal objects I think selection is okayish if near/far planes have ok values.

But I will have another look at this later.

Maybe we can detect the case where a triangle is subpixel and just make it cover 1 pixel in this case.

Even with a near/far clip value of (0.1, 1000), this happens.

  • Fix backfacing case, zero area triangles and wrong depth for front facing
  • Remove triangle expansion because other workaround works

Newer approach don't really do conservative raster but expand (more like jitter) subpixel triangles and view aligned triangle. This should fix 99.9% of cases.

This works well now.
Otherwise only minor comments on the code.

source/blender/draw/engines/basic/shaders/conservative_depth_geom.glsl
19

Suggest calling this BOUNDS_MAX or similar, otherwise set to 3.40282347E+38F.

39

Unused variables.

56

Could use define for the constant.

This revision is now accepted and ready to land.Feb 4 2020, 5:33 AM
  • Cleanup Shader code