Workbench: Shadow: Add support for completly manifold geom.
If a mesh is known to be manifold, then it's not necessary to increment the stencil buffer 2 times anymore. But we still need to account properly for degenerate triangles. In this case, only generate a quad if the tri is facing the lamp. If there is a degenerate loop, the other edge will either cancel the increment (if it is also facing the light) or not produce a quad (if not facing). This will always give the correct count.
This commit is contained in:
@@ -80,6 +80,14 @@ void main()
|
||||
bvec2 backface = greaterThan(facing, vec2(0.0));
|
||||
|
||||
#ifdef DEGENERATE_THRESHOLD
|
||||
# ifndef DOUBLE_MANIFOLD
|
||||
/* If the mesh is known to be manifold and we don't use double count,
|
||||
* only create an quad if the we encounter a facing geom. */
|
||||
if ((any(degen_edges.xz) && backface.y) ||
|
||||
(any(degen_edges.yw) && backface.x))
|
||||
return;
|
||||
# endif
|
||||
|
||||
/* If one of the 2 triangles is degenerate, replace edge by a non-manifold one. */
|
||||
backface.x = (any(degen_edges.xz)) ? !backface.y : backface.x;
|
||||
backface.y = (any(degen_edges.yw)) ? !backface.x : backface.y;
|
||||
|
||||
Reference in New Issue
Block a user