MToon is a material specification that has various features. The spec and implementation are originally founded for Unity engine and this is a port of the material.

See: https://github.com/Santarh/MToon

Hierarchy

  • ShaderMaterial
    • MToonMaterial

Constructors

Properties

Accessors

Methods

Constructors

Properties

_debugMode: any
_generateDefines: any

Returns a map object of preprocessor token and macro of the shader program.

_ignoreVertexColor: any

When this is true, vertex colors will be ignored. true by default.

_isOutline: any
_outlineWidthMode: any
_updateTextureMatrix: any
_updateUVAnimation: any

Update UV animation state. Intended to be called via update.

Param: delta

deltaTime

_uploadUniformsWorkaround: any

Upload uniforms that need to upload but doesn't automatically because of reasons. Intended to be called via constructor and update.

_v0CompatShade: any
alphaHash: boolean

Enables alpha hashed transparency, an alternative to .transparent or .alphaTest. The material will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise, but approximates alpha blending without the associated problems of sorting. Using TAARenderPass can reduce the resulting noise.

alphaToCoverage: boolean

Enables alpha to coverage. Can only be used with MSAA-enabled rendering contexts (meaning when the renderer was created with antialias parameter set to true). Enabling this will smooth aliasing on clip plane edges and alphaTest-clipped edges.

Default

false
blendAlpha: number

Represents the alpha value of the constant blend color. This property has only an effect when using custom blending with ConstantAlphaFactor or OneMinusConstantAlphaFactor.

Default

0
blendColor: Color

Represent the RGB values of the constant blend color. This property has only an effect when using custom blending with ConstantColorFactor or OneMinusConstantColorFactor.

Default

0x000000
blendDst: BlendingDstFactor

Blending destination. It's one of the blending mode constants defined in Three.js. Default is OneMinusSrcAlphaFactor.

Default

THREE.OneMinusSrcAlphaFactor
blendDstAlpha: null | number

The tranparency of the .blendDst. Default is null.

Default

null
blendEquation: BlendingEquation

Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is AddEquation.

Default

THREE.AddEquation
blendEquationAlpha: null | number

The tranparency of the .blendEquation. Default is null.

Default

null
blendSrc: 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214

Blending source. It's one of the blending mode constants defined in Three.js. Default is SrcAlphaFactor.

Default

THREE.SrcAlphaFactor
blendSrcAlpha: null | number

The tranparency of the .blendSrc. Default is null.

Default

null
blending: Blending

Which blending to use when displaying objects with this material. Default is NormalBlending.

Default

THREE.NormalBlending
clipIntersection: boolean

Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. Default is false.

Default

false
clipShadows: boolean

Defines whether to clip shadows according to the clipping planes specified on this material. Default is false.

Default

false
clipping: boolean

Default

false
clippingPlanes: null | Plane[]

User-defined clipping planes specified as THREE.Plane objects in world space. These planes apply to the objects this material is attached to. Points in space whose signed distance to the plane is negative are clipped (not rendered). See the WebGL / clipping /intersection example. Default is null.

Default

null
colorWrite: boolean

Whether to render the material's color. This can be used in conjunction with a mesh's .renderOrder property to create invisible objects that occlude other objects. Default is true.

Default

true
defaultAttributeValues: any

Default

{ 'color': [ 1, 1, 1 ], 'uv': [ 0, 0 ], 'uv1': [ 0, 0 ] }
defines: {
    [key: string]: any;
}

Type declaration

  • [key: string]: any

Default

{}
depthFunc: DepthModes

Which depth function to use. Default is LessEqualDepth. See the depth mode constants for all possible values.

Default

THREE.LessEqualDepth
depthTest: boolean

Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write will also be implicitly disabled.

Default

true
depthWrite: boolean

Whether rendering this material has any effect on the depth buffer. Default is true. When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts.

Default

true
dithering: boolean

Whether to apply dithering to the color to remove the appearance of banding. Default is false.

Default

false
extensions: {
    clipCullDistance: boolean;
    multiDraw: boolean;
}

Type declaration

  • clipCullDistance: boolean
  • multiDraw: boolean

Default

{
* clipCullDistance: false,
* multiDraw: false
* }
fog: boolean

Whether the material is affected by fog. true by default.

forceSinglePass: boolean

Default

false
fragmentShader: string
glslVersion: null | GLSLVersion

Default

null
id: number

Unique number of this material instance.

index0AttributeName: undefined | string

Default

undefined
isMaterial: true

Read-only flag to check if a given object is of type Material.

Remarks

This is a constant value

Default Value

true

isShaderMaterial: true

Read-only flag to check if a given object is of type ShaderMaterial.

Remarks

This is a constant value

Default Value

true

lights: boolean

Default

false
linewidth: number

Default

1
name: string

Material name. Default is an empty string.

Default

''
normalMapType: 0
opacity: number

Opacity. Default is 1.

Default

1
polygonOffset: boolean

Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature.

Default

false
polygonOffsetFactor: number

Sets the polygon offset factor. Default is 0.

Default

0
polygonOffsetUnits: number

Sets the polygon offset units. Default is 0.

Default

0
precision: null | "highp" | "mediump" | "lowp"

Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp". Defaults is null.

Default

null
premultipliedAlpha: boolean

Whether to premultiply the alpha (transparency) value. See WebGL / Materials / Transparency for an example of the difference. Default is false.

Default

false
shadowSide: null | Side

Defines which of the face sides will cast shadows. Default is null. If null, the value is opposite that of side, above.

Default

null
side: Side

Defines which of the face sides will be rendered - front, back or both. Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide.

Default

{@link THREE.FrontSide}
stencilFail: StencilOp

Which stencil operation to perform when the comparison function returns false. Default is KeepStencilOp. See the stencil operation constants for all possible values.

Default

THREE.KeepStencilOp
stencilFunc: StencilFunc

The stencil comparison function to use. Default is AlwaysStencilFunc. See stencil operation constants for all possible values.

Default

THREE.AlwaysStencilFunc
stencilFuncMask: number

The bit mask to use when comparing against the stencil buffer. Default is 0xFF.

Default

0xff
stencilRef: number

The value to use when performing stencil comparisons or stencil operations. Default is 0.

Default

0
stencilWrite: boolean

Whether rendering this material has any effect on the stencil buffer. Default is false.

Default

false
stencilWriteMask: number

The bit mask to use when writing to the stencil buffer. Default is 0xFF.

Default

0xff
stencilZFail: StencilOp

Which stencil operation to perform when the comparison function returns true but the depth test fails. Default is KeepStencilOp. See the stencil operation constants for all possible values.

Default

THREE.KeepStencilOp
stencilZPass: StencilOp

Which stencil operation to perform when the comparison function returns true and the depth test passes. Default is KeepStencilOp. See the stencil operation constants for all possible values.

Default

THREE.KeepStencilOp
toneMapped: boolean

Defines whether this material is tone mapped according to the renderer's WebGLRenderer.toneMapping toneMapping setting. It is ignored when rendering to a render target or using post processing.

Default

true
transparent: boolean

Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. When set to true, the extent to which the material is transparent is controlled by setting it's .opacity property.

Default

false
type: string

Default

'ShaderMaterial'
uniforms: {
    alphaTest: IUniform<number>;
    emissive: IUniform<Color>;
    emissiveIntensity: IUniform<number>;
    emissiveMap: IUniform<null | Texture>;
    emissiveMapUvTransform: IUniform<Matrix3>;
    giEqualizationFactor: IUniform<number>;
    litFactor: IUniform<Color>;
    map: IUniform<null | Texture>;
    mapUvTransform: IUniform<Matrix3>;
    matcapFactor: IUniform<Color>;
    matcapTexture: IUniform<null | Texture>;
    matcapTextureUvTransform: IUniform<Matrix3>;
    normalMap: IUniform<null | Texture>;
    normalMapUvTransform: IUniform<Matrix3>;
    normalScale: IUniform<Vector2>;
    opacity: IUniform<number>;
    outlineColorFactor: IUniform<Color>;
    outlineLightingMixFactor: IUniform<number>;
    outlineWidthFactor: IUniform<number>;
    outlineWidthMultiplyTexture: IUniform<null | Texture>;
    outlineWidthMultiplyTextureUvTransform: IUniform<Matrix3>;
    parametricRimColorFactor: IUniform<Color>;
    parametricRimFresnelPowerFactor: IUniform<number>;
    parametricRimLiftFactor: IUniform<number>;
    rimLightingMixFactor: IUniform<number>;
    rimMultiplyTexture: IUniform<null | Texture>;
    rimMultiplyTextureUvTransform: IUniform<Matrix3>;
    shadeColorFactor: IUniform<Color>;
    shadeMultiplyTexture: IUniform<null | Texture>;
    shadeMultiplyTextureUvTransform: IUniform<Matrix3>;
    shadingShiftFactor: IUniform<number>;
    shadingShiftTexture: IUniform<null | Texture>;
    shadingShiftTextureScale: IUniform<number>;
    shadingShiftTextureUvTransform: IUniform<Matrix3>;
    shadingToonyFactor: IUniform<number>;
    uvAnimationMaskTexture: IUniform<null | Texture>;
    uvAnimationMaskTextureUvTransform: IUniform<Matrix3>;
    uvAnimationRotationPhase: IUniform<number>;
    uvAnimationScrollXOffset: IUniform<number>;
    uvAnimationScrollYOffset: IUniform<number>;
}

Type declaration

  • alphaTest: IUniform<number>
  • emissive: IUniform<Color>
  • emissiveIntensity: IUniform<number>
  • emissiveMap: IUniform<null | Texture>
  • emissiveMapUvTransform: IUniform<Matrix3>
  • giEqualizationFactor: IUniform<number>
  • litFactor: IUniform<Color>
  • map: IUniform<null | Texture>
  • mapUvTransform: IUniform<Matrix3>
  • matcapFactor: IUniform<Color>
  • matcapTexture: IUniform<null | Texture>
  • matcapTextureUvTransform: IUniform<Matrix3>
  • normalMap: IUniform<null | Texture>
  • normalMapUvTransform: IUniform<Matrix3>
  • normalScale: IUniform<Vector2>
  • opacity: IUniform<number>
  • outlineColorFactor: IUniform<Color>
  • outlineLightingMixFactor: IUniform<number>
  • outlineWidthFactor: IUniform<number>
  • outlineWidthMultiplyTexture: IUniform<null | Texture>
  • outlineWidthMultiplyTextureUvTransform: IUniform<Matrix3>
  • parametricRimColorFactor: IUniform<Color>
  • parametricRimFresnelPowerFactor: IUniform<number>
  • parametricRimLiftFactor: IUniform<number>
  • rimLightingMixFactor: IUniform<number>
  • rimMultiplyTexture: IUniform<null | Texture>
  • rimMultiplyTextureUvTransform: IUniform<Matrix3>
  • shadeColorFactor: IUniform<Color>
  • shadeMultiplyTexture: IUniform<null | Texture>
  • shadeMultiplyTextureUvTransform: IUniform<Matrix3>
  • shadingShiftFactor: IUniform<number>
  • shadingShiftTexture: IUniform<null | Texture>
  • shadingShiftTextureScale: IUniform<number>
  • shadingShiftTextureUvTransform: IUniform<Matrix3>
  • shadingToonyFactor: IUniform<number>
  • uvAnimationMaskTexture: IUniform<null | Texture>
  • uvAnimationMaskTextureUvTransform: IUniform<Matrix3>
  • uvAnimationRotationPhase: IUniform<number>
  • uvAnimationScrollXOffset: IUniform<number>
  • uvAnimationScrollYOffset: IUniform<number>
uniformsGroups: UniformsGroup[]
uniformsNeedUpdate: boolean

Default

false
userData: Record<string, any>

An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.

Default

{}
uuid: string

UUID of this material instance. This gets automatically assigned, so this shouldn't be edited.

uvAnimationRotationSpeedFactor: number
uvAnimationScrollXSpeedFactor: number
uvAnimationScrollYSpeedFactor: number
version: number

This starts at 0 and counts how many times .needsUpdate is set to true.

Default

0
vertexColors: boolean

Defines whether vertex coloring is used. Default is false.

Default

false
vertexShader: string
visible: boolean

Defines whether this material is visible. Default is true.

Default

true
wireframe: boolean

Default

false
wireframeLinewidth: number

Default

1

Accessors

  • get alphaTest(): number
  • Gets the alpha value to be used when running an alpha test. Default is 0.

    Returns number

    Default

    0
    
  • set alphaTest(value): void
  • Sets the alpha value to be used when running an alpha test. Default is 0.

    Parameters

    • value: number

    Returns void

    Default

    0
    
  • get color(): Color
  • Returns Color

  • set color(value): void
  • Parameters

    • value: Color

    Returns void

  • get emissive(): Color
  • Returns Color

  • set emissive(value): void
  • Parameters

    • value: Color

    Returns void

  • get emissiveIntensity(): number
  • Returns number

  • set emissiveIntensity(value): void
  • Parameters

    • value: number

    Returns void

  • get emissiveMap(): null | Texture
  • Returns null | Texture

  • set emissiveMap(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get giEqualizationFactor(): number
  • Returns number

  • set giEqualizationFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get ignoreVertexColor(): boolean
  • When this is true, vertex colors will be ignored. true by default.

    Returns boolean

  • set ignoreVertexColor(value): void
  • Parameters

    • value: boolean

    Returns void

  • get isMToonMaterial(): true
  • Readonly boolean that indicates this is a [[MToonMaterial]].

    Returns true

  • get isOutline(): boolean
  • Returns boolean

  • set isOutline(b): void
  • Parameters

    • b: boolean

    Returns void

  • get map(): null | Texture
  • Returns null | Texture

  • set map(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get matcapFactor(): Color
  • Returns Color

  • set matcapFactor(value): void
  • Parameters

    • value: Color

    Returns void

  • get matcapTexture(): null | Texture
  • Returns null | Texture

  • set matcapTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • set needsUpdate(value): void
  • Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. This property is automatically set to true when instancing a new material.

    Parameters

    • value: boolean

    Returns void

    Default

    false
    
  • get normalMap(): null | Texture
  • Returns null | Texture

  • set normalMap(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get normalScale(): Vector2
  • Returns Vector2

  • set normalScale(value): void
  • Parameters

    • value: Vector2

    Returns void

  • get outlineColorFactor(): Color
  • Returns Color

  • set outlineColorFactor(value): void
  • Parameters

    • value: Color

    Returns void

  • get outlineLightingMixFactor(): number
  • Returns number

  • set outlineLightingMixFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get outlineWidthFactor(): number
  • Returns number

  • set outlineWidthFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get outlineWidthMultiplyTexture(): null | Texture
  • Returns null | Texture

  • set outlineWidthMultiplyTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get parametricRimColorFactor(): Color
  • Returns Color

  • set parametricRimColorFactor(value): void
  • Parameters

    • value: Color

    Returns void

  • get parametricRimFresnelPowerFactor(): number
  • Returns number

  • set parametricRimFresnelPowerFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get parametricRimLiftFactor(): number
  • Returns number

  • set parametricRimLiftFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get rimLightingMixFactor(): number
  • Returns number

  • set rimLightingMixFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get rimMultiplyTexture(): null | Texture
  • Returns null | Texture

  • set rimMultiplyTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get shadeColorFactor(): Color
  • Returns Color

  • set shadeColorFactor(value): void
  • Parameters

    • value: Color

    Returns void

  • get shadeMultiplyTexture(): null | Texture
  • Returns null | Texture

  • set shadeMultiplyTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get shadingShiftFactor(): number
  • Returns number

  • set shadingShiftFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get shadingShiftTexture(): null | Texture
  • Returns null | Texture

  • set shadingShiftTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get shadingShiftTextureScale(): number
  • Returns number

  • set shadingShiftTextureScale(value): void
  • Parameters

    • value: number

    Returns void

  • get shadingToonyFactor(): number
  • Returns number

  • set shadingToonyFactor(value): void
  • Parameters

    • value: number

    Returns void

  • get uvAnimationMaskTexture(): null | Texture
  • Returns null | Texture

  • set uvAnimationMaskTexture(value): void
  • Parameters

    • value: null | Texture

    Returns void

  • get uvAnimationRotationPhase(): number
  • Returns number

  • set uvAnimationRotationPhase(value): void
  • Parameters

    • value: number

    Returns void

  • get uvAnimationScrollXOffset(): number
  • Returns number

  • set uvAnimationScrollXOffset(value): void
  • Parameters

    • value: number

    Returns void

  • get uvAnimationScrollYOffset(): number
  • Returns number

  • set uvAnimationScrollYOffset(value): void
  • Parameters

    • value: number

    Returns void

  • get v0CompatShade(): boolean
  • There is a line of the shader called "comment out if you want to PBR absolutely" in VRM0.0 MToon. When this is true, the material enables the line to make it compatible with the legacy rendering of VRM. Usually not recommended to turn this on. false by default.

    Returns boolean

  • set v0CompatShade(v): void
  • There is a line of the shader called "comment out if you want to PBR absolutely" in VRM0.0 MToon. When this is true, the material enables the line to make it compatible with the legacy rendering of VRM. Usually not recommended to turn this on. false by default.

    Parameters

    • v: boolean

    Returns void

Methods

  • Adds a listener to an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<{
          dispose: {};
      }[T], T, MToonMaterial>

      The function that gets called when the event is fired.

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    Returns void

  • Return a new material with the same parameters as this material.

    Returns this

  • Parameters

    • source: this

    Returns this

  • In case onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile, so three.js can reuse a cached shader or recompile the shader as needed.

    Returns string

  • Fire an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • event: BaseEvent<T> & {
          dispose: {};
      }[T]

      The event that gets fired.

    Returns void

  • This disposes the material. Textures of a material don't get disposed. These needs to be disposed by Texture.

    Returns void

  • Checks if listener is added to an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<{
          dispose: {};
      }[T], T, MToonMaterial>

      The function that gets called when the event is fired.

    Returns boolean

  • Type Parameters

    • T extends string

    Parameters

    Returns boolean

  • An optional callback that is executed immediately before the shader program is compiled. This function is called with the associated WebGL program parameters and renderer. Useful for the modification of built-in materials.

    Parameters

    • parameters: WebGLProgramParametersWithUniforms

      WebGL program parameters

    • renderer: WebGLRenderer

      WebGLRenderer context that is initializing the material

    Returns void

  • Parameters

    • renderer: WebGLRenderer
    • scene: Scene
    • camera: Camera
    • geometry: BufferGeometry<NormalBufferAttributes>
    • object: Object3D<Object3DEventMap>
    • group: Group<Object3DEventMap>

    Returns void

  • Parameters

    • object: Object3D<Object3DEventMap>
    • parameters: WebGLProgramParametersWithUniforms
    • renderer: WebGLRenderer

    Returns void

  • Removes a listener from an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: EventListener<{
          dispose: {};
      }[T], T, MToonMaterial>

      The listener function that gets removed.

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    Returns void

  • Parameters

    • parameters: ShaderMaterialParameters

    Returns void

  • Parameters

    • meta: any

    Returns any

  • Update this material.

    Parameters

    • delta: number

      deltaTime since last update

    Returns void