-
Notifications
You must be signed in to change notification settings - Fork 27
The Globals object
The Globals Object encapsulates many options you can feed to the renderer before it starts tracing photons
Here follows an explanation of all the settings divided by category
epsilon
: This value is used to determine the minimum precision value used for various calculations, lowering/increasing it too much can cause precision issues and incorrect renders
highPrecision
: setting highPrecision to true
will switch to Float64Arrays for every calculation made inside the renderer, those are obviously more expensive to work with and you can expect a 2x slowdown from using them. If changes to the epsilon
value are not solving the precision issues you encounter, setting highPrecision
to true might be your only option
USE_STRATIFIED_SAMPLING
: wether the renderer should use stratified sampling or not
samplingRatioPerPixelCovered
: variable determining how many samples are taken from a line, eg. if a light ray is "200 pixels long" the amount of pixels drawn would be floor(light_ray_pixel_length * samplingRatioPerPixelCovered);
the expected range is [0...1] values towards 1 will draw more samples per line, so expect more pixels drawn but a lower number of photons fired values towards 0 will draw less samples per line, so expect less pixels drawn but a bigger number of photons fired
LIGHT_BOUNCES
: how many light bounces to compute for each photon
skipBounce
: how many light bounces to skip from each photon fired. If the photon bounces 4 times around the scene and skipBounce is set to 1, the first "bounce" of light wont be drawn in the canvas, but the bounce is still computed
workersCount
: the amount of web workers to spawn, each will start a new thread to speed up rendering. Its advised to not use more workers than the number of cores in your processor. Every browser has its limits on how many web workers can be spawned, Chrome currently can handle at most 60 (but believe me you'll fry your browser with much less than that)
PHOTONS_PER_UPDATE
: only used to print to the console the amount of photons fired and colored pixels at an interval specified by the value
WORLD_SIZE
vertical extent of the world with respect to the canvas size, if WORLD_SIZE
is set to 20, the top corner of the canvas will have a world y coordinate of 10, and the bottom coordinate of the canvas element will have a world y coordinate of -10
worldAttenuation
the amount of radiance lost as a photon travels through the scene
registerVideo
: wether you want to register the frames rendered as a .webm video
photonsPerVideoFrame
: amount of photons to trace for each frame before computing the next one
framesPerSecond
: fps of the final video
framesCount
: amount of frames to render
frameStart
: starting frame of the video
motionBlur
: enables motion blur if set to true. This will effectively make the renderer call multiple times the createScene
function, each time with a random number in the range [0...1] for the motionBlurT
parameter, this makes it possible to create blurred animations and video frames
motionBlurFramePhotons
: amount of photons traced before createScene
is called again with a different motionBlurT
parameter. If your createScene
function takes a lot of time to compute you should evaluate carefully how many photons to trace before calling the function again
deactivateOffscreenCanvas
: if set to false, an offscreen canvas can is activated to draw on it as you would do with the standard javascript canvas API. Activating an oc canvas slows down render times by about 1.7x. The canvas image will then be used to increase / decrease the radiance contribution along the pixels covered by the canvas, see scenes/offscreenCanvas.js
for an example on how to use the offscreen canvas
offscreenCanvasCPow
: how strongly the radiance is modified along pixels drawn by the offscreen canvas
canvasSize {
width: 800, // width of the main canvas in pixels
height: 800, // height of the main canvas in pixels
}
toneMapping
: enables / disables Reinhard tonemapping
gamma
: gamma correction value
exposure
: exposure value