Constructor
new Material()
Create a new Material instance
Properties:
Name | Type | Description |
---|---|---|
alphaTest |
Number | The alpha test reference value to control which fragments 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). |
alphaToCoverage |
Boolean | Enables or disables alpha to coverage (WebGL2 only). When enabled, and if hardware anti-aliasing is on, limited order-independent transparency can be achieved. Quality depends on the number of MSAA samples of the current render target. It can nicely soften edges of otherwise sharp alpha cutouts, but isn't recommended for large area semi-transparent surfaces. Note, that you don't need to enable blending to make alpha to coverage work. It will work without it, just like alphaTest. |
alphaWrite |
Boolean | 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. |
blendType |
Number | Controls how primitives are blended when being written to the currently active render target.
Can be one of the following values:
|
blueWrite |
Boolean | 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. |
cull |
Number | Controls how triangles are culled based on their face direction with respect to the viewpoint.
Can be one of the following values:
|
depthTest |
Boolean | 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. |
depthWrite |
Boolean | 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. |
greenWrite |
Boolean | 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. |
name |
String | The name of the material. |
redWrite |
Boolean | 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. |
shader |
pc.Shader | The shader used by this material to render mesh instances. |
stencilFront |
pc.StencilParameters | Stencil parameters for front faces (default is null). |
stencilBack |
pc.StencilParameters | Stencil parameters for back faces (default is null). |
depthBias |
Number | Offsets the output depth buffer value. Useful for decals to prevent z-fighting. |
slopeDepthBias |
Number | Same as pc.Material#depthBias, but also depends on the slope of the triangle relative to the camera. |
- Source:
Methods
deleteParameter(name)
Deletes a shader parameter on a material.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the parameter to delete. |
- Source:
destroy()
Removes this material from the scene and possibly frees up memory from its shaders (if there are no other materials using it).
- Source:
getParameter(name) → {Object}
Retrieves the specified shader parameter from a material.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the parameter to query. |
- Source:
Returns:
The named parameter.
- Type
- Object
setParameter(name, data, passFlagsopt)
Sets a shader parameter on a material.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | The name of the parameter to set. | |
data |
Number | Array | pc.Texture | The value for the specified parameter. | |
passFlags |
Number |
<optional> |
Mask describing which passes the material should be included in. |
- Source:
setParameters()
Pushes all material parameters into scope.
- Source:
update()
Applies any changes made to the material's properties.
- Source: