Class ScreenSpaceTessellator
This tessellator splits triangles recursively based on how large they appear on screen (in pixels), rather than world-space dimensions. This provides per-polygon level-of-detail tessellation that adapts to camera distance naturally.
Tessellation algorithm:
- Compute screen-space lengths of all three edges (pixels)
- If longest edge ≤ maxScreenPixels, emit the triangle as-is
- Otherwise, split the longest edge at its midpoint
- Interpolate: world coordinates, texture coordinates, screen coordinates, Z-depth
- Recurse on the two resulting sub-triangles
Safeguards against excessive tessellation:
- Maximum recursion depth (prevents infinite/very deep recursion)
- Maximum triangles per original polygon (hard limit on output)
- Maximum screen-space edge length (skip tessellation for huge off-screen polygons)
The resulting TessellatedTexturedTriangle instances have pre-computed screen
coordinates, avoiding redundant transformation during the render phase.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionScreenSpaceTessellator(double maxScreenPixels) Creates a tessellator with the specified maximum screen-space edge length. -
Method Summary
Modifier and TypeMethodDescriptionReturns the list of tessellated triangles.voidsetMaxScreenPixels(double maxScreenPixels) Updates the maximum screen-space edge length threshold.voidtessellate(TexturedTriangle original) Tessellates the given textured triangle into smaller triangles.
-
Constructor Details
-
ScreenSpaceTessellator
public ScreenSpaceTessellator(double maxScreenPixels) Creates a tessellator with the specified maximum screen-space edge length.- Parameters:
maxScreenPixels- the maximum allowed edge length in screen pixels; edges longer than this will be subdivided
-
-
Method Details
-
setMaxScreenPixels
public void setMaxScreenPixels(double maxScreenPixels) Updates the maximum screen-space edge length threshold.This method allows adaptive tessellation control by updating the threshold before each tessellation operation. Called from
AdaptiveTessellationController.- Parameters:
maxScreenPixels- the new maximum allowed edge length in screen pixels
-
getResult
Returns the list of tessellated triangles.- Returns:
- the resulting tessellated triangles
-
tessellate
Tessellates the given textured triangle into smaller triangles.After calling this method, retrieve the resulting sub-triangles via
getResult(). The original triangle's texture reference and backface culling settings are preserved on all sub-triangles.Safeguards prevent excessive tessellation when the polygon is extremely large on screen (e.g., when camera is very close).
- Parameters:
original- the triangle to tessellate (must have screen coords computed)
-