Skip to content

Commit

Permalink
Minor improvement to degenerate normals in GLSL Bezier triangle:
Browse files Browse the repository at this point in the history
    - negate derivative terms when evaluating points on edge where u + v = 1
  • Loading branch information
barfowl committed Feb 12, 2019
1 parent ec231f8 commit 1cdbb72
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions opensubdiv/osd/glslPatchCommon.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -1172,10 +1172,17 @@ OsdEvalPatchBezierTriangle(ivec3 patchParam, vec2 UV,
dNv = cross(dUV, dPv) + cross(dPu, dVV);

if (nLength < nEpsilon) {
float DU = (UV.x == 1.0) ? -1.0 : 1.0;
float DV = (UV.y == 1.0) ? -1.0 : 1.0;
// Use 1st order Taylor approximation of N(u,v) within patch interior:
if (w > 0.0) {
N = dNu + dNv;
} else if (u >= 1.0) {
N = -dNu + dNv;
} else if (v >= 1.0) {
N = dNu - dNv;
} else {
N = -dNu - dNv;
}

N = DU * dNu + DV * dNv;
nLength = length(N);
if (nLength < nEpsilon) {
nLength = 1.0;
Expand Down

0 comments on commit 1cdbb72

Please sign in to comment.