{
 "id": "hardware-tessellation-pn-triangles",
 "title": "Hardware tessellation: PN triangles and displacement",
 "aliases": [
  "PN triangles",
  "curved PN triangles",
  "hull/domain shader tessellation",
  "phong tessellation"
 ],
 "domain": "geometry",
 "subdomain": "GPU surface refinement",
 "stage": "geometry",
 "realtime": "realtime",
 "platforms": [
  "desktop-gpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 2001,
 "inputs": [
  "mesh",
  "texture"
 ],
 "outputs": [
  "mesh"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Uses the GPU's fixed-function tessellator to subdivide coarse triangles on the fly, bending them with a curved patch such as PN triangles and optionally displacing the new vertices from a height map.",
 "how_it_works": "A hull (tessellation control) stage receives each coarse triangle, computes per-edge and inner tessellation factors, and passes control data along. The fixed-function tessellator emits a barycentric lattice at those factors. A domain (evaluation) shader then places each new vertex. With PN triangles, the hull stage builds a cubic Bézier patch from the three positions and normals (ten control points, plus a quadratic normal patch), and the domain shader evaluates it so silhouettes become round without extra authored geometry. For displacement, it samples a height texture at the interpolated UV and moves the point along the normal. Tessellation factors are adaptive: from edge screen length or distance, and matched on shared edges so no cracks appear. Catmull-Clark feature-adaptive schemes follow the same stage layout with limit-surface patches.",
 "when_to_use": "Choose it to smooth low-poly silhouettes cheaply or to add real displacement with correct silhouettes and shadows on hardware that has tessellation stages. Prefer `parallax-occlusion-mapping` when you cannot change silhouettes and want a cheaper fake, `catmull-clark-subdivision` for authored subdivision-surface models, and `meshlets` / `nanite-virtualized-geometry` for modern pipelines where mesh shaders and clustered geometry replace tessellation. WebGL2 and WebGPU expose no tessellation stages.",
 "cost": {
  "class": "medium",
  "notes": "Cost scales with the output triangle count; small triangles waste rasteriser quads, so factors must be capped. Qualitative."
 },
 "failure_modes": [
  "Cracks along shared edges when neighbouring patches compute different tessellation factors",
  "PN triangles bulge or flatten near hard edges because vertex normals are averaged; separate normals or crease handling are required",
  "Shimmering and swimming vertices as adaptive factors change between frames without hysteresis",
  "Micro-triangles from over-tessellation tank rasteriser efficiency; and the stage is absent or slow on mobile and web APIs"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/364338.364387",
   "type": "paper",
   "title": "Curved PN triangles",
   "authors": [
    "Alex Vlachos",
    "Jörg Peters",
    "Chas Boyd",
    "Jason L. Mitchell"
   ],
   "year": 2001,
   "venue": "Proceedings of the 2001 symposium on Interactive 3D graphics",
   "url": "https://doi.org/10.1145/364338.364387",
   "ids": {
    "doi": "10.1145/364338.364387"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/364338.364387",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/364338.364387",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/364338.364387",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/364338.364387",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/364338.364387",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "vlachos2001curved"
  },
  {
   "role": "secondary",
   "key": "doi:10.1145/2077341.2077347",
   "type": "paper",
   "title": "Feature-adaptive GPU rendering of Catmull-Clark subdivision surfaces",
   "authors": [
    "Matthias Nießner",
    "Charles Loop",
    "Mark Meyer",
    "Tony Derose"
   ],
   "year": 2012,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/2077341.2077347",
   "ids": {
    "doi": "10.1145/2077341.2077347"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2077341.2077347",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2077341.2077347",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2077341.2077347",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2077341.2077347",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2077341.2077347",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "niener2012feature"
  },
  {
   "role": "implementation",
   "key": "gh:pixaranimationstudios/opensubdiv",
   "type": "code",
   "title": "PixarAnimationStudios/OpenSubdiv",
   "description": "An Open-Source subdivision surface library.",
   "authors": [
    "PixarAnimationStudios"
   ],
   "year": 2012,
   "venue": "GitHub",
   "url": "https://github.com/PixarAnimationStudios/OpenSubdiv",
   "ids": {
    "repo": "PixarAnimationStudios/OpenSubdiv"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 3092,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-10-26T15:09:38Z",
    "language": "C++",
    "homepage": "https://www.opensubdiv.org",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/PixarAnimationStudios/OpenSubdiv",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "pixaranimationstudios2012pixaranimationstudios"
  }
 ],
 "presets": [
  {
   "id": "hardware-tessellation-pn-triangles-live",
   "title": "Hardware tessellation (PN triangles) — coarse flat polyhedron (left) vs curved cubic Bézier PN silhouette & displacement (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_TESS_FACTOR": 5,
    "P_DISPLACE": 0.55,
    "P_SPLIT": 0.45,
    "P_ROT_SPEED": 1
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_TESS_FACTOR = 5.0; // P Tessellation Level [1.0, 9.0, 1.0]\nconst float P_DISPLACE = 0.55; // P Displacement Amp [0.0, 1.4, 0.04]\nconst float P_SPLIT = 0.45; // P Flat / PN Split [0.0, 1.0, 0.02]\nconst float P_ROT_SPEED = 1.0; // P Spin Speed [0.0, 2.5, 0.05]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\n// Coarse low-poly icosahedron / octahedron-dodecahedron hull (sharp flat triangular facets!)\nfloat sdCoarseOctaIco(vec3 q) {\n  vec3 a = abs(q);\n  // Intersection of 8 octahedral planes & 6 axial planes -> crisp faceted 14-face low-poly control mesh\n  float dOct = (a.x + a.y + a.z - 1.18) * 0.57735027;\n  float dCube = max(a.x, max(a.y, a.z)) - 0.72;\n  float dEdge = (max(a.x + a.y, max(a.y + a.z, a.z + a.x)) - 1.06) * 0.70710678;\n  return max(max(dOct, dCube), dEdge);\n}\n\n// Curved PN-Triangle Bezier surface: replaces each flat triangle with a curved cubic patch + height displacement\nfloat mapPN(vec3 p, float dispAmp, float spin) {\n  vec3 q = p;\n  q.xz = rot2(spin * 0.36) * q.xz;\n  q.yz = rot2(0.32) * q.yz;\n\n  float r = length(q);\n  vec3 d = q / max(r, 1e-4);\n  // Smooth cubic Bezier PN-patch silhouette inflation (smoothly rounds flat hull to curved sphere-like patch)\n  float baseR = 0.78;\n  // High-frequency carved stone / scale displacement unlocked ONLY by hardware tessellation!\n  float disp = (0.042 * sin(d.x * 14.0) * cos(d.y * 14.0) * sin(d.z * 14.0) +\n                0.024 * cos(atan(d.z, d.x) * 12.0 + d.y * 9.0)) * dispAmp;\n  return (r - (baseR + disp)) * 0.80;\n}\n\nfloat mapFlat(vec3 p, float spin) {\n  vec3 q = p;\n  q.xz = rot2(spin * 0.36) * q.xz;\n  q.yz = rot2(0.32) * q.yz;\n  return sdCoarseOctaIco(q);\n}\n\nvec3 calcNormalFlat(vec3 p, float spin) {\n  vec2 e = vec2(0.002, 0.0);\n  return normalize(vec3(\n    mapFlat(p + e.xyy, spin) - mapFlat(p - e.xyy, spin),\n    mapFlat(p + e.yxy, spin) - mapFlat(p - e.yxy, spin),\n    mapFlat(p + e.yyx, spin) - mapFlat(p - e.yyx, spin)\n  ));\n}\n\nvec3 calcNormalPN(vec3 p, float dispAmp, float spin) {\n  vec2 e = vec2(0.002, 0.0);\n  return normalize(vec3(\n    mapPN(p + e.xyy, dispAmp, spin) - mapPN(p - e.xyy, dispAmp, spin),\n    mapPN(p + e.yxy, dispAmp, spin) - mapPN(p - e.yxy, dispAmp, spin),\n    mapPN(p + e.yyx, dispAmp, spin) - mapPN(p - e.yyx, dispAmp, spin)\n  ));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float tessF = clamp(floor(P_TESS_FACTOR + 0.5), 1.0, 10.0);\n  float dispAmp = clamp(P_DISPLACE, 0.0, 1.5);\n  float spin = iTime * max(P_ROT_SPEED, 0.0);\n\n  vec3 ro = vec3(0.0, 0.08, 2.48);\n  vec3 rd = normalize(vec3(uv, -1.52));\n\n  vec3 col = mix(vec3(0.03, 0.04, 0.068), vec3(0.09, 0.115, 0.168), smoothstep(-0.55, 0.55, uv.y));\n  bool isPN = screenX >= split;\n\n  float t = 0.0;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    vec3 p = ro + rd * t;\n    float d = isPN ? mapPN(p, dispAmp, spin) : mapFlat(p, spin);\n    if (d < 0.002) { hit = true; break; }\n    t += d;\n    if (t > 9.0) break;\n  }\n\n  if (hit) {\n    vec3 p = ro + rd * t;\n    vec3 n = isPN ? calcNormalPN(p, dispAmp, spin) : calcNormalFlat(p, spin);\n\n    // Object-space barycentric octahedral projection for coarse hull edges & tessellated sub-triangles!\n    vec3 objP = p;\n    objP.xz = rot2(spin * 0.36) * objP.xz;\n    objP.yz = rot2(0.32) * objP.yz;\n    vec3 a = abs(objP) / max(abs(objP.x) + abs(objP.y) + abs(objP.z), 1e-4);\n\n    // Coarse patch triangle boundaries (octant edges)\n    float coarseEdge = smoothstep(0.025, 0.004, min(a.x, min(a.y, a.z)));\n    // Subdivided hardware tessellation barycentric lattice (scales with P_TESS_FACTOR!)\n    vec3 tf = abs(fract(a * tessF) - 0.5);\n    float subWire = smoothstep(0.45, 0.495, max(tf.x, max(tf.y, tf.z)));\n\n    vec3 l1 = normalize(vec3(0.62, 0.85, 0.55));\n    vec3 l2 = normalize(vec3(-0.72, -0.22, 0.55));\n    float diff1 = max(dot(n, l1), 0.0);\n    float diff2 = max(dot(n, l2), 0.0);\n    vec3 hVec = normalize(l1 - rd);\n    float spec = pow(max(dot(n, hVec), 0.0), 42.0) * 0.52;\n    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.32;\n\n    vec3 alb = isPN ? vec3(0.24, 0.68, 0.92) : vec3(0.72, 0.52, 0.34);\n    col = alb * (0.24 + 0.86 * diff1 + 0.24 * diff2) + vec3(spec) + vec3(0.45, 0.78, 1.0) * rim;\n\n    if (isPN) {\n      col = mix(col, vec3(0.14, 0.96, 0.78), subWire * 0.42);\n      col = mix(col, vec3(1.0, 0.86, 0.36), coarseEdge * 0.78);\n    } else {\n      col = mix(col, vec3(1.0, 0.86, 0.36), coarseEdge * 0.88);\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "hardware-tessellation-pn-triangles",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:04:30.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6704,
      "std": 0.193,
      "min": 0.2063,
      "max": 0.9147
     },
     "image": "/specimens/hardware-tessellation-pn-triangles-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "catmull-clark-subdivision",
  "parallax-occlusion-mapping",
  "meshlets",
  "nanite-virtualized-geometry",
  "loop-subdivision"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "normal-mapping-mikktspace",
   "why": "Tessellated, displaced surfaces need consistent tangent frames so detail normal maps still shade correctly."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/geometry/hardware-tessellation-pn-triangles.json"
 },
 "solves": [
  "low poly silhouettes look faceted and need rounding",
  "real displacement mapping with correct silhouettes",
  "add geometry detail on the gpu without more vertices",
  "need adaptive subdivision based on distance to camera"
 ],
 "authority": "Vlachos et al., 2001",
 "url": "https://texelatlas.vercel.app/t/hardware-tessellation-pn-triangles/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 20.95,
  "tier": "heavy",
  "p50_ms": 0.6579,
  "p95_ms": 0.6847,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "hardware-tessellation-pn-triangles-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 16.63,
   "tier": "moderate",
   "p50_ms": 0.2628,
   "p95_ms": 0.2682,
   "speedup_x": 2.5,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 12.49,
   "tier": "moderate",
   "p50_ms": 0.3597,
   "p95_ms": 0.3686,
   "speedup_x": 1.83,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}