Make raster renderings of a mesh with (software) raycasting, to visualize mesh properties such as normals and curvatures. (Static methods)
Static methods
staticambientOcclusion(render:Render, numSamples:Int = 32, normalize:Bool = true):Vector<Float>
Compute per-pixel ambient occlusion
Parameters:
render | The renderer object |
---|---|
numSamples | Number of samples Smaller=>faster,noisier. Larger=>slower,finer |
normalize | Whether to normalize to range [0,1] |
Returns:
a flat vector with width x height elements
staticcurvature(render:Render):Vector<Float>
Compute the per-pixel curvature map
Parameters:
render | The renderer object |
---|
Returns:
a flat vector with width x height x 2 elements (curvature in the two principle axes as the 2 channels)
staticdepth(render:Render, normalize:Bool = false):Vector<Float>
Compute the per-pixel depth map.
When normalize=false
, empty void is encoded as Math.POSITIVE_INFINITY
.
Parameters:
render | The renderer object |
---|---|
normalize | Whether to normalize to range [0,1] |
Returns:
a flat vector with width x height elements
staticlambertian(render:Render, light:Vec3, normalize:Bool = true):Vector<Float>
Compute per-pixel Lambertian ("n-dot-l") shading.
When normalize=false
, empty void is encoded as Math.NEGATIVE_INFINITY
.
Parameters:
render | The renderer object |
---|---|
light | The direction of light |
normalize | Whether to normalize to range [0,1] |
Returns:
a flat vector with width x height elements
staticnormal(render:Render):Vector<Float>
Compute the per-pixel normal map.
Parameters:
render | The renderer object |
---|
Returns:
a flat vector with width x height x 3 elements
(x
y
z
compnent of the normal as the 3 channels)
staticraycast(render:Render, fun:(RayHit, Int, Int) ‑> Void):Void
Cast a ray from each display pixel, with a customizable callback function for each result.
Parameters:
render | The renderer object |
---|---|
fun | The callback function that takes arguments
|
statictoPPMString(data:Vector<Float>, w:Int, h:Int, min:Float, max:Float):String
Encode pixel array as a PPM (Netpbm color image) string, for previewing results. (PPM is a dead simple image format with a trivial implementation)
Parameters:
data | the array holding image information,
any of those returned by methods in the |
---|---|
w | width of the image |
h | height of the image |
min | minimum pixel value (used for normalization) |
max | maximum pixel value (used for normalization) |
Returns:
a string containing PPM encoding