API

Class PBRSubSurfaceConfiguration

Plugin that implements the sub surface component of the PBR material

Hierarchy (View Summary)

Index
applyAlbedoAfterSubSurface: boolean = PBRSubSurfaceConfiguration.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE

This property only exists for backward compatibility reasons. Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface properties (transmission, refraction, etc.). Default is false. Note however that the PBR calculation is wrong when this property is set to true, so only use it if you want to mimic the 7.0 behavior.

diffusionDistance: Color3 = ...

Defines how far each channel transmit through the media. It is defined as a color to simplify it selection.

dispersion: number = 0

Defines the Abbe number for the volume.

doNotSerialize: boolean = false

Specifies if the material plugin should be serialized, true to skip serialization

legacyTranslucency: boolean = PBRSubSurfaceConfiguration.DEFAULT_LEGACY_TRANSLUCENCY

This property only exists for backward compatibility reasons. Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface translucency. Default is false.

markAllDefinesAsDirty: () => void

Helper function to mark defines as being dirty.

maximumThickness: number = 1

Defines the maximum thickness stored in the thickness map.

minimumThickness: number = 0

Defines the minimum thickness stored in the thickness map. If no thickness map is defined, this value will be used to simulate thickness.

name: string

Defines the name of the plugin

priority: number = 500

Defines the priority of the plugin. Lower numbers run first.

refractionIntensity: number = 1

Defines the refraction intensity of the material. The refraction when enabled replaces the Diffuse part of the material. The intensity helps transitioning between diffuse and refraction.

registerForExtraEvents: boolean = false

Indicates that this plugin should be notified for the extra events (HasRenderTargetTextures / FillRenderTargetTextures / HardBindForSubMesh)

resolveIncludes: boolean = false

Indicates that any #include directive in the plugin code must be replaced by the corresponding code.

tintColor: Color3 = ...

Defines the volume tint of the material. This is used for both translucency and scattering.

tintColorAtDistance: number = 1

Defines the distance at which the tint color should be found in the media. This is used for refraction only.

translucencyColor: Nullable<Color3> = null

Defines the translucency tint of the material. If not set, the tint color will be used instead.

translucencyIntensity: number = 1

Defines the translucency intensity of the material. When translucency has been enabled, this defines how much of the "translucency" is added to the diffuse part of the material.

useThicknessAsDepth: boolean = false

Defines that the thickness should be used as a measure of the depth volume.

DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE: boolean = false

Default value used for applyAlbedoAfterSubSurface.

This property only exists for backward compatibility reasons. Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface properties (transmission, refraction, etc.). Default is false. Note however that the PBR calculation is wrong when this property is set to true, so only use it if you want to mimic the 7.0 behavior.

DEFAULT_LEGACY_TRANSLUCENCY: boolean = false

Default value used for legacyTranslucency.

This property only exists for backward compatibility reasons. Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface translucency. Default is false.

indexOfRefraction: number

Index of refraction of the material base layer. https://en.wikipedia.org/wiki/List_of_refractive_indices

This does not only impact refraction but also the Base F0 of Dielectric Materials.

From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))

invertRefractionY: boolean

Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.

isDispersionEnabled: boolean

Defines if dispersion is enabled in the material.

isRefractionEnabled: boolean

Defines if the refraction is enabled in the material.

isScatteringEnabled: boolean

Defines if the sub surface scattering is enabled in the material.

isTranslucencyEnabled: boolean

Defines if the translucency is enabled in the material.

linkRefractionWithTransparency: boolean

This parameters will make the material used its opacity to control how much it is refracting against not. Materials half opaque for instance using refraction could benefit from this control.

refractionIntensityTexture: Nullable<BaseTexture>

Stores the intensity of the refraction. If provided, it takes precedence over thicknessTexture + useMaskFromThicknessTexture

  • the green (red if useGltfStyleTextures = true) channel is the refraction intensity.
refractionTexture: Nullable<BaseTexture>

Defines the texture to use for refraction.

thicknessTexture: Nullable<BaseTexture>

Stores the average thickness of a mesh in a texture (The texture is holding the values linearly). The red (or green if useGltfStyleTextures=true) channel of the texture should contain the thickness remapped between 0 and 1. 0 would mean minimumThickness 1 would mean maximumThickness The other channels might be use as a mask to vary the different effects intensity.

translucencyColorTexture: Nullable<BaseTexture>

Defines the translucency tint color of the material as a texture. This is multiplied against the translucency color to add variety and realism to the material. If translucencyColor is not set, the tint color will be used instead.

translucencyIntensityTexture: Nullable<BaseTexture>

Stores the intensity of the translucency. If provided, it takes precedence over thicknessTexture + useMaskFromThicknessTexture

  • the blue (alpha if useGltfStyleTextures = true) channel is the translucency intensity.
useAlbedoToTintRefraction: boolean

When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)

useAlbedoToTintTranslucency: boolean

When enabled, translucent surfaces will be tinted with the albedo colour (independent of thickness)

useGltfStyleTextures: boolean

Use channels layout used by glTF:

  • thicknessTexture: the green (instead of red) channel is the thickness
  • thicknessTexture/refractionIntensityTexture: the red (instead of green) channel is the refraction intensity
  • thicknessTexture/translucencyIntensityTexture: the alpha (instead of blue) channel is the translucency intensity
useMaskFromThicknessTexture: boolean

Stores the intensity of the different subsurface effects in the thickness texture. Note that if refractionIntensityTexture and/or translucencyIntensityTexture is provided it takes precedence over thicknessTexture + useMaskFromThicknessTexture

  • the green (red if useGltfStyleTextures = true) channel is the refraction intensity.
  • the blue (alpha if useGltfStyleTextures = true) channel is the translucency intensity.
  • Returns a list of custom shader code fragments to customize the shader.

    Parameters

    • _shaderType: string

      "vertex" or "fragment"

    • _shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL

      The shader language to use.

    Returns Nullable<{ [pointName: string]: string }>

    null if no code to be added, or a list of pointName => code. Note that pointName can also be a regular expression if it starts with a !. In that case, the string found by the regular expression (if any) will be replaced by the code provided.

  • Gets the description of the uniforms to add to the ubo (if engine supports ubos) or to inject directly in the vertex/fragment shaders (if engine does not support ubos)

    Returns {
        fragment?: string;
        ubo?: { name: string; size: number; type: string }[];
        vertex?: string;
    }

    the description of the uniforms