Skip to content

API Reference

TechLabsInc edited this page Aug 25, 2021 · 9 revisions

PathtracingRenderer

Constructors

MonteRay.PathtracingRenderer( options : Object )

options - (optional) An object with properties to initialize the renderer.

  • advancedLighting : Boolean

    Whether to use exact lighting and enable caustics. This option slows down the rendering process, so do not enable unless you need to. Default is false.

  • alpha : Boolean

    Whether to enable transparency in the image. Default is false.

  • BVHAcceleration : Boolean

    Whether to use BVH Accelerated raycasting. Requires three-mesh-bvh and Three.js r123 or later. Default is true.

  • canvas : HTMLCanvasElement

    The canvas to use for displaying the rendered image.

  • downloadInterval : Integer

    How many samples per pixel completed before downloading an in-progress image. Default is null.

  • fps : Number

    How often you want the image to update using the automatic frame limiting feature.

  • lightSamples : Integer

    How many direct light samples to take per ambient light sample. This option helps generate softer shadows in less time, but also darkens the image as a side effect.

  • maxSamples : Integer

    How many samples per pixel before completing the render and downloading the image. Default is null.

  • nextFrame : Function

    A function to invoke after reaching the desired amount of samples and downloading the resulting image. This option is ignored when maxSamples is undefined.

  • pixelBatchSize : Integer

    How many pixels to render between each screen update. This option is ignored when fps is defined. Default is the number of pixels on screen.

  • recursiveLighting : Boolean

    Whether to enable recursive direct light bouncing. This option fixes refractive material shadows and adds reflected light, but also generates refraction-related noise. Default is false.

  • renderMode : MonteRay.DepthRenderMode, MonteRay.RandomRenderMode, MonteRay.LinearRenderMode, MonteRay.CenterRenderMode

    What order to render the pixels on the screen. Default is MonteRay.DepthRenderMode.

Constants

.VERSION : String

The current version of MonteRay.

.DepthRenderMode

.RandomRenderMode

.LinearRenderMode

.CenterRenderMode

These specify the order to render the pixels to render certain parts of the image first. Any can be used in the renderMode option when initializing a MonteRay.PathtracingRenderer.

Properties

.domElement : HTMLCanvasElement

Methods

.download ( ) : null

Save the resulting rendered image by downloading at the current resolution.

.render ( scene : Scene, camera : Camera ) : null

.setPixelRatio ( ratio : Number ) : null

.setSize ( width: Integer, height : Integer ) : null

 

Color

Constructors

MonteRay.Color( red : Float, green : Float, blue : Float, alpha : Float )

Example:

new MonteRay.Color(1, 0.47843137254901963, 0, 1);

MonteRay.Color( red : Float, green : Float, blue : Float)

MonteRay.Color( color : MonteRay.Color )

MonteRay.Color( color : THREE.Color )

MonteRay.Color( hex : Hexadecimal )

Example:

new MonteRay.Color(0x007aff);

MonteRay.Color( hex : String )

Example:

new MonteRay.Color("#007aff");

MonteRay.Color( colorName : String )

Example:

new MonteRay.Color("red");

MonteRay.Color( cssStyleString : String )

Example:

new MonteRay.Color("rgb(0, 122, 255)");
new MonteRay.Color("rgba(0, 122, 255, 1)");
new MonteRay.Color("hsl(211, 100%, 50%)");
new MonteRay.Color("hsla(211, 100%, 50%, 1)");

Properties

r : Float

The red channel value between 0 and 1. Default is 1.

g : Float

The green channel value between 0 and 1. Default is 1.

b : Float

The blue channel value between 0 and 1. Default is 1.

a : Float

The alpha or transparency channel value between 0 and 1. Default is 1.

Methods

.add ( color : MonteRay.Color ) : this

.addA ( color : MonteRay.Color ) : this

Same as .add but includes the alpha channel in the operation.

.addColors ( color1 : MonteRay.Color, color2 : MonteRay.Color ) : this

.addColorsA ( color : MonteRay.Color ) : this

Same as .addColors but includes the alpha channel in the operation.

.addScalar ( s : Float ) : this

.addScalarA ( color : MonteRay.Color ) : this

Same as .addScalar but includes the alpha channel in the operation.

.clone ( ) : MonteRay.Color

.copy ( color : MonteRay.Color ) : this

.equals ( color : MonteRay.Color ) : this

.equalsA ( color : MonteRay.Color ) : this

Same as .equals but includes the alpha channel in the operation.

.fromArray ( array : Array, offset : Integer ) : this

.fromBufferAttribute ( attribute : THREE.BufferAttribute, index : Integer ) : this

.lerp ( color : MonteRay.Color, amount : Float ) : this

.lerpA ( color : MonteRay.Color, amount : Float ) : this

Same as .lerp but includes the alpha channel in the operation.

.lerpColors ( color1 : MonteRay.Color, color2 : MonteRay.Color, amount : Float ) : this

.lerpColorsA ( color1 : MonteRay.Color, color2 : MonteRay.Color, amount : Float ) : this

Same as .lerpColors but includes the alpha channel in the operation.

.multiply ( color : MonteRay.Color ) : this

.multiplyA ( color : MonteRay.Color ) : this

Same as .multiply but includes the alpha channel in the operation.

.multiplyScalar ( s : Float ) : this

.multiplyScalarA ( s : Float ) : this

Same as .multiplyScalar but includes the alpha channel in the operation.

.divideScalar ( s : Float ) : this

Multiplies this color's RGB values by s.

.divideScalarA ( s : Float ) : this

Same as .divideScalar but includes the alpha channel in the operation.

.set ( value : Color_Hex_or_String ) : this

.setA ( value : Color_Hex_or_String ) : this

Same as .set but includes the alpha channel in the operation.

.setHex ( hex : Hexadecimal ) : this

hex can be a six digit hexadecimal (0x007aff), or an eight digit hexadecimal (0x007affff) in format rrggbbaa.

.setRGB ( r : Float, g : Float, b : Float ) : this

.setRGBA ( r : Float, g : Float, b : Float, a : Float ) : this

Same as .setRGB but includes the alpha channel in the operation.

.setScalar ( s : Float ) : this

.setScalarA ( s : Float ) : this

Same as .setScalar but includes the alpha channel in the operation.

.sub ( color : MonteRay.Color ) : this

.subA ( color : MonteRay.Color ) : this

Same as .sub but includes the alpha channel in the operation.

.toArray ( array : Array, offset : Integer ) : this

.fromTHREEColor ( color : THREE.Color, alpha : FLOAT ) : this

.random ( ) : this

Sets each value of this color to a pseudo-random value between 0 and 1, excluding 1.

.randomA ( ) : this

Same as .random but includes the alpha channel in the operation.

.invert ( ) : this

Inverts this color's RGB values.

.invertA ( ) : this

Same as .invert but includes the alpha channel in the operation.

.clamp ( min : MonteRay.Color, max : MonteRay.Color ) : this

Makes sure this color's RGB values are between min's and max's RGB values.

.clampA ( min : MonteRay.Color, max : MonteRay.Color ) : this

Same as .clamp but includes the alpha channel in the operation.

.clampScalar ( min : Float, max : Float ) : this

Makes sure this color's RGB values are between min and max.

.clampScalarA ( min : Float, max : Float ) : this

Same as .clampScalar but includes the alpha channel in the operation.

.clampV ( ) : this

Clamps color values to the visible spectrum.

.min ( v : Float ) : Float

Makes sure this color's RGB values are no greater than v.

.minA ( v : Float ) : Float

Same as .min but includes the alpha channel in the operation.

.max ( v : Float ) : Float

Makes sure this color's RGB values are no smaller than v.

.maxA ( v : Float ) : Float

Same as .max but includes the alpha channel in the operation.

.maxVal ( ) : Float

Returns the greatest value out of this color's R, G, and B.

.maxValA ( ) : Float

Same as .maxVal but includes the alpha channel in the operation.

.setR ( value : Float ) : this

Sets the value of the red channel.

.setG ( value : Float ) : this

Sets the value of the green channel.

.setB ( value : Float ) : this

Sets the value of the blue channel.

.setA ( value : Float ) : this

Sets the value of the alpha channel.

.setComponent ( index : Integer, value : Float ) : this

Sets the value of the specified component channel in order RGBA.

.getComponent ( index : Integer ) : Float

Gets the value of the specified component channel in order RGBA.

Clone this wiki locally