Debug Module
Debug colors, heatmaps, luminance, UV visualization, and bad-value highlighting.
Turn the guide into code
Take the key idea from this page into the playground and validate it in a real shader instead of leaving it as theory.
Open PlaygroundDebug colors, heatmaps, luminance, UV visualization, and bad-value highlighting.
Import
import Debug
This module imports: Math.
Constants
None.
Structs
No structs found.
Enums
No enums found.
Functions
debug_red
Returns the standard debug red color.
debug_red :: () -> float3 { return float3(1.0, 0.0, 0.0); }
debug_green
Returns the standard debug green color.
debug_green :: () -> float3 { return float3(0.0, 1.0, 0.0); }
debug_blue
Returns the standard debug blue color.
debug_blue :: () -> float3 { return float3(0.0, 0.2, 1.0); }
debug_cyan
Returns the standard debug cyan color.
debug_cyan :: () -> float3 { return float3(0.0, 1.0, 1.0); }
debug_yellow
Returns the standard debug yellow color.
debug_yellow :: () -> float3 { return float3(1.0, 1.0, 0.0); }
debug_magenta
Returns the standard debug magenta color, commonly used here to mark NaN values.
debug_magenta :: () -> float3 { return float3(1.0, 0.0, 1.0); }
debug_black
Returns black for checkerboards, masks, and low-end debug ramps.
debug_black :: () -> float3 { return float3(0.0); }
debug_white
Returns white for checkerboards, masks, and high-end debug ramps.
debug_white :: () -> float3 { return float3(1.0); }
luminance
Reference: https://en.wikipedia.org/wiki/Rec._709
luminance :: (float3 color) -> float
normal_color
Maps a normal from signed [-1, 1] space into displayable [0, 1] RGB.
normal_color :: (float3 n) -> float3
signed_color
Maps a signed vector from [-1, 1] into [0, 1] without normalizing it.
signed_color :: (float3 value) -> float3
mask_color
Returns green for true and red for false, useful for visualizing predicates.
mask_color :: (bool value) -> float3
has_bad
Returns true when any component is NaN or infinite.
has_bad :: (float2 value) -> bool
has_bad
Returns true when any component is NaN or infinite.
has_bad :: (float3 value) -> bool
has_bad
Returns true when any component is NaN or infinite.
has_bad :: (float4 value) -> bool
bad_value_color
Replaces a scalar's normal debug color with magenta for NaN or yellow for infinity.
bad_value_color :: (float value, float3 okColor) -> float3
bad_value_color
Replaces a vector's normal debug color with magenta for NaN or yellow for infinity.
bad_value_color :: (float3 value, float3 okColor) -> float3
heatmap
Useful for visualizing depth, roughness, overdraw, lighting cost, and scalar fields.
heatmap :: (float value) -> float3
heatmap_range
Remaps a scalar range to [0, 1] and displays it with heatmap().
heatmap_range :: (float value, float minValue, float maxValue) -> float3
depth_gray
Displays linear depth as grayscale between nearPlane and farPlane.
depth_gray :: (float depth, float nearPlane, float farPlane) -> float3
depth_bands
Displays repeating colored depth bands for spotting precision and ordering issues.
depth_bands :: (float depth, float bandCount) -> float3
checker
Creates a procedural black/white checkerboard in UV space.
checker :: (float2 uv, float scale) -> float3
uv_color
Displays UV coordinates directly as red/green color channels.
uv_color :: (float2 uv) -> float3
axis_color
Colors a direction by its dominant axis: X red, Y green, Z blue.
axis_color :: (float3 direction) -> float3
overdraw_tint
Returns a heatmapped color with alpha proportional to count / maxCount.
overdraw_tint :: (float count, float maxCount) -> float4
Source
Generated from compiler-reference/modules/Debug.bwsl.