B.Render.Stage()

Separates the rendering process within the frame.

To create the object use device.stage().

TYPES:

Rect

Describes pixel rect.

{number} x

{number} y

{number} width

{number} height

DepthRange

Describes depth range.

{number} near

range [0, 1]

{number} far

range [0, 1]

Cleanup

Describes color, depth and stencil cleanup values.

{B.Math.Color} color

{number} depth

{number} stencil

WriteMasks

Describes color, depth and stencil write masks.

{B.Render.Mask} color

{boolean} depth

{number} stencil

Handler

Stage handler callback.

PARAMETERS:

{B.Render.Stage} stage

CONSTANTS:

{Object} VIEW

Stage view matrix uniform placeholder. It allows to set stage view matrix to a uniform value automatically.

stage.uniform("mxView", B.Render.Stage.VIEW);

{Object} PROJ

Stage projection matrix uniform placeholder. It allows to set stage projection matrix to a uniform value automatically.

stage.uniform("mxProj", B.Render.Stage.PROJ);

{Object} VIEW_PROJ

Stage view-projection matrix uniform placeholder. It allows to set stage view-projection matrix to a uniform value automatically.

stage.uniform("mxViewProj", B.Render.Stage.VIEW_PROJ);

{Object} VIEW_INV

Stage view inverse matrix uniform placeholder. It allows to set stage view inverse matrix to a uniform value automatically.

stage.uniform("mxViewInv", B.Render.Stage.VIEW_INV);

{Object} VIEW_POS

Stage view position uniform placeholder. It allows to set world-space view position to a uniform value automatically.

stage.uniform("viewPos", B.Render.Stage.VIEW_POS);

{Object} VIEW_DIR

Stage view direction uniform placeholder. It allows to set world-space normalized view direction to a uniform value automatically.

stage.uniform("viewDir", B.Render.Stage.VIEW_DIR);

METHODS:

device()

Returns linked rendering device.

RETURNS:

name()

Returns string name.

RETURNS:

{string}

output(target)

Sets output target.

PARAMETERS:

RETURNS:

output()

Gets output target.

culling(enable)

Sets frustum culling enable.

PARAMETERS:

{boolean} enable

RETURNS:

culling()

Gets frustum culling enable.

RETURNS:

{boolean}

view(matrix)

Sets view matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

view()

Gets view matrix.

RETURNS:

proj(matrix)

Sets projection matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

proj()

Gets projection matrix.

RETURNS:

viewProj()

Returns view-projection matrix.

RETURNS:

viewInv()

Returns view inverse matrix.

RETURNS:

viewPos()

Returns view position.

RETURNS:

viewDir()

Returns view direction.

RETURNS:

unproject(x, y, result)

Finds 3D-coordinates of pixel position (viewport and scissor are taking into account).

PARAMETERS:

{number} x

{number} y

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

{B.Math.Vector3 | null}

null if the point is outside of the drawable area or the output target is not specified

viewport(rect)

Sets viewport.

PARAMETERS:

{B.Render.Stage~Rect | false} rect

pass false to use default viewport (entire output area)

RETURNS:

viewport(x, y, width, height)

Sets viewport parameters.

PARAMETERS:

{number} x

{number} y

{number} width

{number} height

RETURNS:

viewport()

Gets viewport.

RETURNS:

depthRange(range)

Sets depth range.

PARAMETERS:

{B.Render.Stage~DepthRange | false} range

pass false to use default depth range (near = 0, far = 1)

RETURNS:

depthRange(near, far)

Sets depth range parameters.

Near must be less than or equal to far.

PARAMETERS:

{number} near

range [0, 1]

{number} far

range [0, 1]

RETURNS:

depthRange()

Gets depth range.

scissor(rect)

Sets scissor rect.

PARAMETERS:

{B.Render.Stage~Rect | false} rect

pass false to disable scissor

RETURNS:

scissor(x, y, width, height)

Sets scissor rect parameters.

PARAMETERS:

{number} x

{number} y

{number} width

{number} height

RETURNS:

scissor()

Returns scissor rect.

RETURNS:

{B.Render.Stage~Rect | false}

false if scissor is disabled

cleanup(cleanup)

Sets output target cleanup.

Initial value is {color: B.Math.Color.WHITE, depth: 1, stencil: 0}.

PARAMETERS:

{B.Render.Stage~Cleanup | false} cleanup

pass false to disable cleanup

RETURNS:

cleanup(color, depth, stencil)

Sets output target cleanup parameters.

PARAMETERS:

{B.Math.Color} color

{number} depth

{number} stencil

RETURNS:

cleanup()

Returns output target cleanup or false if cleanup is disabled.

RETURNS:

write(mask)

Sets output target write masks.

Initial value is {color: B.Render.Mask.RGBA, depth: true, stencil: 1}.

PARAMETERS:

RETURNS:

write(color, depth, stencil)

Sets output target write masks parameters.

PARAMETERS:

{B.Render.Mask} color

{boolean} depth

{number} stencil

RETURNS:

write()

Gets output target write masks.

uniforms()

Returns array of uniforms names.

RETURNS:

{Array.<string>}

uniform(name, value)

Sets uniform value.

stage.
    uniform("someNumber", 1.5).
    uniform("someVector2", B.Math.makeVector2(1, 2)).
    uniform("someVector3", B.Math.makeVector3(1, 2, 3)).
    uniform("someVector4", B.Math.makeVector4(1, 2, 3, 4)).
    uniform("someColor", B.Math.makeColor(1, 0, 0, 0.5)).
    uniform("someMatrix3", B.Math.makeMatrix3().setRotationX(Math.PI)).
    uniform("someMatrix4", B.Math.makeMatrix4().setTranslation(1, 2, 3)).
    uniform("someTexture", dev.makeTexture(image)).
    uniform("someTexture", dev.stage("someStage").output().color()).
    uniform("someDepth", dev.stage("someStage").output().depth());

stage.uniform("someTexture", null); // removing

PARAMETERS:

RETURNS:

uniform(name)

Gets uniform value.

PARAMETERS:

{string} name

RETURNS:

before(handler)

Sets before stage handler.

stage.before(function (stage) {
    // ...
});

stage.before(null); // removing

PARAMETERS:

{null | B.Render.Stage~Handler} handler

RETURNS:

before()

Gets before stage handler.

RETURNS:

after(handler)

Sets after stage handler.

stage.after(function (stage) {
    // ...
});

stage.after(null); // removing

PARAMETERS:

{null | B.Render.Stage~Handler} handler

RETURNS:

after()

Gets after stage handler.

RETURNS:

free()

Frees all internal data and detach the resource from linked rendering device.

TYPES:

CONSTANTS:

METHODS: