Class PBRSubSurfaceConfiguration
Hierarchy (View Summary)
- MaterialPluginBase
- PBRSubSurfaceConfiguration
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new PBRSubSurfaceConfiguration(
material: PBRBaseMaterial,
addToPluginList?: boolean,
): PBRSubSurfaceConfigurationParameters
- material: PBRBaseMaterial
- addToPluginList: boolean = true
Returns PBRSubSurfaceConfiguration
Properties
apply Albedo After Sub Surface
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.
diffusion Distance
Defines how far each channel transmit through the media. It is defined as a color to simplify it selection.
dispersion
Defines the Abbe number for the volume.
do Not Serialize
Specifies if the material plugin should be serialized, true to skip serialization
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.
Readonlymark All Defines As Dirty
Helper function to mark defines as being dirty.
maximum Thickness
Defines the maximum thickness stored in the thickness map.
minimum Thickness
Defines the minimum thickness stored in the thickness map. If no thickness map is defined, this value will be used to simulate thickness.
name
Defines the name of the plugin
priority
Defines the priority of the plugin. Lower numbers run first.
refraction Intensity
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.
register For Extra Events
Indicates that this plugin should be notified for the extra events (HasRenderTargetTextures / FillRenderTargetTextures / HardBindForSubMesh)
resolve Includes
Indicates that any #include directive in the plugin code must be replaced by the corresponding code.
tint Color
Defines the volume tint of the material. This is used for both translucency and scattering.
tint Color At Distance
Defines the distance at which the tint color should be found in the media. This is used for refraction only.
translucency Color
Defines the translucency tint of the material. If not set, the tint color will be used instead.
translucency Intensity
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.
use Thickness As Depth
Defines that the thickness should be used as a measure of the depth volume.
StaticDEFAULT_ APPLY_ ALBEDO_ AFTERSUBSURFACE
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.
StaticDEFAULT_ LEGACY_ TRANSLUCENCY
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.
Accessors
disable Alpha Blending
-
get disableAlphaBlending(): boolean
Returns true if alpha blending should be disabled.
Returns boolean
index Of Refraction
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))
invert Refraction Y
Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
is Dispersion Enabled
Defines if dispersion is enabled in the material.
is Refraction Enabled
Defines if the refraction is enabled in the material.
is Scattering Enabled
Defines if the sub surface scattering is enabled in the material.
is Translucency Enabled
Defines if the translucency is enabled in the material.
legacy Transluceny
-
get legacyTransluceny(): boolean
-
set legacyTransluceny(value: boolean): void
Parameters
- value: boolean
Returns void
link Refraction With Transparency
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.
refraction Intensity Texture
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.
refraction Texture
Defines the texture to use for refraction.
scattering Diffusion Profile
thickness Texture
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.
translucency Color Texture
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.
translucency Intensity Texture
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.
use Albedo To Tint Refraction
When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
use Albedo To Tint Translucency
When enabled, translucent surfaces will be tinted with the albedo colour (independent of thickness)
use Gltf Style Textures
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
use Mask From Thickness Texture
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.
volume Index Of Refraction
-
get volumeIndexOfRefraction(): number
Index of refraction of the material's volume. https://en.wikipedia.org/wiki/List_of_refractive_indices
This ONLY impacts refraction. If not provided or given a non-valid value, the volume will use the same IOR as the surface.
Returns number
-
set volumeIndexOfRefraction(value: number): void
Parameters
- value: number
Returns void
Methods
add Fallbacks
-
addFallbacks(
defines: MaterialSubSurfaceDefines,
fallbacks: EffectFallbacks,
currentRank: number,
): numberAdd fallbacks to the effect fallbacks list.
Parameters
- defines: MaterialSubSurfaceDefines
defines the Base texture to use.
- fallbacks: EffectFallbacks
defines the current fallback list.
- currentRank: number
defines the current fallback rank.
Returns number
the new fallback rank.
- defines: MaterialSubSurfaceDefines
bind For Sub Mesh
-
bindForSubMesh(
uniformBuffer: UniformBuffer,
scene: Scene,
engine: Engine,
subMesh: SubMesh,
): voidBinds subsurface data for a sub mesh.
Parameters
- uniformBuffer: UniformBuffer
defines the uniform buffer to update
- scene: Scene
defines the scene to use for texture binding
- engine: Engine
defines the engine used for binding
- subMesh: SubMesh
defines the sub mesh being rendered
Returns void
- uniformBuffer: UniformBuffer
collect Defines
-
Collects all defines.
Parameters
- defines: { [name: string]: { default: any; type: string } }
The object to append to.
Returns void
- defines: { [name: string]: { default: any; type: string } }
copy To
-
Makes a duplicate of the current configuration into another one.
Parameters
- plugin: MaterialPluginBase
define the config where to copy the info
Returns void
- plugin: MaterialPluginBase
dispose
-
Disposes the subsurface textures.
Parameters
OptionalforceDisposeTextures: booleandefines whether to dispose the textures
Returns void
fill Render Target Textures
-
Fills the list of render target textures.
Parameters
- renderTargets: SmartArray<RenderTargetTexture>
the list of render targets to update
Returns void
- renderTargets: SmartArray<RenderTargetTexture>
get Active Textures
-
Adds the active subsurface textures.
Parameters
- activeTextures: BaseTexture[]
defines the list of active textures to update
Returns void
- activeTextures: BaseTexture[]
get Animatables
-
Adds the animatable subsurface textures.
Parameters
- animatables: IAnimatable[]
defines the list of animatables to update
Returns void
- animatables: IAnimatable[]
get Attributes
-
Gets the attributes used by the plugin.
Parameters
- _attributes: string[]
list that the attribute names should be added to.
- _scene: Scene
the scene that the material belongs to.
- _mesh: AbstractMesh
the mesh being rendered.
Returns void
- _attributes: string[]
get Class Name
-
Gets the current class name useful for serialization or dynamic coding.
Returns string
The class name.
get Custom Code
-
getCustomCode(
_shaderType: string,
_shaderLanguage?: ShaderLanguage,
): Nullable<{ [pointName: string]: string }>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
pointNamecan 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. - _shaderType: string
get Samplers
-
Adds the subsurface sampler names.
Parameters
- samplers: string[]
defines the list of sampler names to update
Returns void
- samplers: string[]
get Uniform Buffers Names
-
Gets the uniform buffers names added by the plugin.
Parameters
- _ubos: string[]
list that the ubo names should be added to.
Returns void
- _ubos: string[]
get Uniforms
-
getUniforms(): {
fragment?: string;
ubo?: { name: string; size: number; type: string }[];
vertex?: string;
}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
hard Bind For Sub Mesh
-
hardBindForSubMesh(
uniformBuffer: UniformBuffer,
scene: Scene,
engine: Engine,
subMesh: SubMesh,
): voidBinds the material data (this function is called even if mustRebind() returns false)
Parameters
- uniformBuffer: UniformBuffer
defines the Uniform buffer to fill in.
- scene: Scene
defines the scene the material belongs to.
- engine: Engine
defines the engine the material belongs to.
- subMesh: SubMesh
the submesh to bind data for
Returns void
- uniformBuffer: UniformBuffer
has Render Target Textures
-
Gets a boolean indicating that current material needs to register RTT
Returns boolean
true if this uses a render target otherwise false.
has Texture
-
Checks whether subsurface rendering uses a texture.
Parameters
- texture: BaseTexture
defines the texture to check
Returns boolean
true if the texture is used by subsurface rendering
- texture: BaseTexture
is Compatible
-
Gets a boolean indicating that the plugin is compatible with a given shader language.
Returns boolean
true if the plugin is compatible with the shader language
is Ready For Sub Mesh
-
Checks whether the subsurface textures are ready for the sub mesh.
Parameters
- defines: MaterialSubSurfaceDefines
defines the material defines to inspect
- scene: Scene
defines the scene to use for readiness checks
Returns boolean
true if subsurface is ready
- defines: MaterialSubSurfaceDefines
parse
-
Parses a plugin configuration from a serialized object.
Parameters
- source: any
Serialized object.
- scene: Scene
Defines the scene we are parsing for
- rootUrl: string
Defines the rootUrl to load from
Returns void
- source: any
prepare Defines
-
Sets the defines for the next rendering
Parameters
- _defines: MaterialDefines
the list of "defines" to update.
- _scene: Scene
defines the scene to the material belongs to.
- _mesh: AbstractMesh
the mesh being rendered
Returns void
- _defines: MaterialDefines
prepare Defines Before Attributes
-
Updates shader defines for subsurface rendering before attributes are processed.
Parameters
- defines: MaterialSubSurfaceDefines
defines the material defines to update
- scene: Scene
defines the scene to use for texture checks
Returns void
- defines: MaterialSubSurfaceDefines
serialize
-
Serializes this plugin configuration.
Returns any
- An object with the serialized config.
Plugin that implements the sub surface component of the PBR material