Create a new ShaderMaterial instance.
Optional
shaderDesc: ShaderDescThe description of the shader to be used by the material.
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).
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.
Controls how triangles are culled based on their face direction with respect to the viewpoint. Can be:
Defaults to CULLFACE_BACK.
The name of the material.
Stencil parameters for back faces (default is null).
Stencil parameters for front faces (default is null).
A unique id the user can assign to the material. The engine internally does not use this for anything, and the user can assign a value to this id for any purpose they like. Defaults to an empty string.
Gets whether the alpha channel is written to the color buffer.
Sets whether the alpha channel is written to the color buffer. 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 alpha component will not be written. Defaults to true.
Gets the blend state for this material.
Sets the blend state for this material. Controls how fragment shader outputs are blended when being written to the currently active render target. This overwrites blending type set using Material#blendType, and offers more control over blending.
Gets the blend mode for this material.
Sets the blend mode for this material. Controls how fragment shader outputs are blended when being written to the currently active render target. Can be:
Defaults to BLEND_NONE.
Gets whether the blue channel is written to the color buffer.
Sets whether the blue channel is written to the color buffer. 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 blue component will not be written. Defaults to true.
Gets the object containing custom shader chunks.
Sets the object containing custom shader chunks that will replace default ones.
Gets the offset for the output depth buffer value.
Sets the offset for the output depth buffer value. Useful for decals to prevent z-fighting. Typically a small negative value (-0.1) is used to render the mesh slightly closer to the camera.
Gets the depth test function.
Sets the depth test function. Controls how the depth of new fragments is compared against the current depth contained in the depth buffer. Can be:
Defaults to FUNC_LESSEQUAL.
Gets the depth state.
Sets the depth state. Note that this can also be done by using Material#depthTest, Material#depthFunc and Material#depthWrite.
Gets whether depth testing is enabled.
Sets whether depth testing is enabled. 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.
Gets whether depth writing is enabled.
Sets whether depth writing is enabled. 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.
Gets whether the green channel is written to the color buffer.
Sets whether the green channel is written to the color buffer. 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 green component will not be written. Defaults to true.
Gets whether the red channel is written to the color buffer.
Sets whether the red channel is written to the color buffer. 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.
Gets the shader description.
Gets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.
Sets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.
Copy a ShaderMaterial
.
The material to copy from.
The destination material.
Deletes a shader parameter on a material.
The name of the parameter to delete.
Removes this material from the scene and possibly frees up memory from its shaders (if there are no other materials using it).
Returns true if a define is enabled on the material, otherwise false.
The name of the define to check.
The value of the define.
Retrieves the specified shader parameter from a material.
The name of the parameter to query.
The named parameter.
Adds or removes a define on the material. Defines can be used to enable or disable various parts of the shader code.
The name of the define to set.
The value of the define. If undefined or false, the define is removed.
Sets a shader parameter on a material.
The name of the parameter to set.
The value for the specified parameter.
Applies any changes made to the material's properties.
A ShaderMaterial is a type of material that utilizes a specified shader for rendering purposes.
A simple example which creates a material with custom vertex and fragment shaders: