API Reference

Class List

pc.Material

A material determines how a particular mesh instance is rendered. It specifies the shader and render state that is set before the mesh instance is submitted to the graphics device.

Summary

Properties

alphaTestThe alpha test reference value to control which fragements are written to the currently active render target based on alpha value.
alphaWriteIf true, the alpha component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
blendTypeControls how primitives are blended when being written to the currently active render target.
blueWriteIf true, the blue component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
cullControls how triangles are culled based on their face direction with respect to the viewpoint.
depthTestIf true, fragments generated by the shader of this material are only written to the current render target if they pass the depth test.
depthWriteIf true, fragments generated by the shader of this material write a depth value to the depth buffer of the currently active render target.
greenWriteIf true, the green component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
nameThe name of the material.
redWriteIf true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
shaderThe shader used by this material to render mesh instances.
stencilBackStencil parameters for back faces (default is null).
stencilFrontStencil parameters for front faces (default is null).

Methods

deleteParameterDeletes a shader parameter on a material.
getParameterRetrieves the specified shader parameter from a material.
initInitializes the material with the properties in the specified data.
setParameterSets a shader parameter on a material.
setParametersPushes all material parameters into scope.
updateApplies any changes made to the material's properties.

Details

Constructor

Material()

Create a new Material instance

Properties

NumberalphaTest

The alpha test reference value to control which fragements are written to the currently active render target based on alpha value. All fragments with an alpha value of less than the alphaTest reference value will be discarded. alphaTest defaults to 0 (all fragments pass).

BooleanalphaWrite

If true, the alpha component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the alpha component will not be written. Defaults to true.

NumberblendType

Controls how primitives are blended when being written to the currently active render target. Can be one of the following values:

  • pc.BLEND_SUBTRACTIVE: Subtract the color of the source fragment from the destination fragment and write the result to the frame buffer.
  • pc.BLEND_ADDITIVE: Add the color of the source fragment to the destination fragment and write the result to the frame buffer.
  • pc.BLEND_NORMAL: Enable simple translucency for materials such as glass. This is equivalent to enabling a source blend mode of pc.BLENDMODE_SRC_ALPHA and a destination blend mode of pc.BLENDMODE_ONE_MINUS_SRC_ALPHA.
  • pc.BLEND_NONE: Disable blending.
  • pc.BLEND_PREMULTIPLIED: Similar to pc.BLEND_NORMAL expect the source fragment is assumed to have already been multiplied by the source alpha value.
  • pc.BLEND_MULTIPLICATIVE: Multiply the color of the source fragment by the color of the destination fragment and write the result to the frame buffer.
  • pc.BLEND_ADDITIVEALPHA: Same as pc.BLEND_ADDITIVE except the source RGB is multiplied by the source alpha.
Defaults to pc.BLEND_NONE.

BooleanblueWrite

If true, the blue component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the blue component will not be written. Defaults to true.

Numbercull

Controls how triangles are culled based on their face direction with respect to the viewpoint. Can be one of the following values:

  • pc.CULLFACE_NONE: Do not cull triangles based on face direction.
  • pc.CULLFACE_BACK: Cull the back faces of triangles (do not render triangles facing away from the view point).
  • pc.CULLFACE_FRONT: Cull the front faces of triangles (do not render triangles facing towards the view point).
  • pc.CULLFACE_FRONTANDBACK: Cull both front and back faces (triangles will not be rendered).
Defaults to pc.CULLFACE_BACK.

BooleandepthTest

If true, fragments generated by the shader of this material are only written to the current render target if they pass the depth test. If false, fragments generated by the shader of this material are written to the current render target regardless of what is in the depth buffer. Defaults to true.

BooleandepthWrite

If true, fragments generated by the shader of this material write a depth value to the depth buffer of the currently active render target. If false, no depth value is written. Defaults to true.

BooleangreenWrite

If true, the green component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the green component will not be written. Defaults to true.

Stringname

The name of the material.

BooleanredWrite

If true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the red component will not be written. Defaults to true.

pc.Shadershader

The shader used by this material to render mesh instances.

pc.StencilParametersstencilBack

Stencil parameters for back faces (default is null).

pc.StencilParametersstencilFront

Stencil parameters for front faces (default is null).

Methods

deleteParameter(name)

Deletes a shader parameter on a material.

Parameters

nameStringThe name of the parameter to delete.

getParameter(name)

Retrieves the specified shader parameter from a material.

Parameters

nameStringThe name of the parameter to query.

Returns

Object The named parameter.

init(data)

Initializes the material with the properties in the specified data.

Parameters

dataObjectThe initial data for the material.

setParameter(name, data)

Sets a shader parameter on a material.

Parameters

nameStringThe name of the parameter to set.
dataNumber, Array, pc.TextureThe value for the specified parameter.

setParameters()

Pushes all material parameters into scope.

update()

Applies any changes made to the material's properties.