Revamped shader arch

This commit is contained in:
2026-11-05 16:49:25 +01:00
parent f8671bd35f
commit 9bd2cd5667
20 changed files with 593 additions and 705 deletions
+45
View File
@@ -0,0 +1,45 @@
module lod_policies;
import voxel_tracing;
public struct PixelFootprintLod : ILodPolicy
{
// Angular size of one pixel in radians (small-angle approximation).
// For a pinhole camera: 2 * tan(fovY * 0.5) / imageHeightInPixels.
public float pixelAngle;
// How many pixels a node may cover before we refuse to stop.
// 1.0 = stop once a node is <= 1 pixel wide.
// < 1.0 = more detail (sharper, slower), > 1.0 = coarser (faster, blurrier).
public float pixelThreshold;
// Cone radius at t = 0. Zero for a pinhole camera; non-zero for
// secondary rays that inherit a footprint from a previous bounce.
public float coneRadius0;
// Footprint (world-space width of one pixel) at ray distance t.
public float footprint(float t)
{
return coneRadius0 + t * pixelAngle;
}
public bool shouldStop(float t, float nodeSize)
{
// Node edge length not larger than the allowed pixel coverage -> stop.
return nodeSize <= footprint(t) * pixelThreshold;
}
// Convenience constructor from camera parameters.
public static PixelFootprintLod create(
float fovYRadians,
float imageHeightPixels,
float pixelThreshold = 1.0,
float coneRadius0 = 0.0)
{
PixelFootprintLod p;
p.pixelAngle = 2.0 * tan(0.5 * fovYRadians) / imageHeightPixels;
p.pixelThreshold = pixelThreshold;
p.coneRadius0 = coneRadius0;
return p;
}
}