Class DitheredTileFadeMaterialPlugin
Hierarchy (View Summary)
- MaterialPluginBase
- DitheredTileFadeMaterialPlugin
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new DitheredTileFadeMaterialPlugin(
material: DitheredTileFadeSupportedMaterial,
): DitheredTileFadeMaterialPluginCreates and attaches a dithered fade plugin.
Parameters
- material: DitheredTileFadeSupportedMaterial
The Standard or PBR material that the plugin will extend.
Returns DitheredTileFadeMaterialPlugin
Throws
If the material is unsupported or already has a dithered tile fade plugin. Use GetOrCreate when reuse is intended.
- material: DitheredTileFadeSupportedMaterial
Properties
do Not Serialize
Specifies if the material plugin should be serialized, true to skip serialization
Readonlymark All Defines As Dirty
Helper function to mark defines as being dirty.
name
Defines the name of the plugin
priority
Defines the priority of the plugin. Lower numbers run first.
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.
Static ReadonlyName
The name used to register the plugin on a material.
Accessors
is Enabled
-
get isEnabled(): boolean
Gets whether configured fades are applied. Disabling the plugin makes every mesh fully visible without discarding its stored bounds.
Returns boolean
-
set isEnabled(value: boolean): void
Sets whether configured fades are applied. This uniform-only change does not recompile the material.
Parameters
- value: boolean
Returns void
Methods
add Fallbacks
-
Add fallbacks to the effect fallbacks list.
Parameters
- defines: MaterialDefines
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: MaterialDefines
bind For Sub Mesh
-
bindForSubMesh(
_uniformBuffer: UniformBuffer,
_scene: Scene,
_engine: AbstractEngine,
_subMesh: SubMesh,
): voidBinds the material data.
Parameters
- _uniformBuffer: UniformBuffer
defines the Uniform buffer to fill in.
- _scene: Scene
defines the scene the material belongs to.
- _engine: AbstractEngine
the engine this scene belongs to.
- _subMesh: SubMesh
the submesh to bind data for
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 } }
commit Thin Instance Fade Bounds
-
Uploads thin-instance fade changes after one or more setters used
refresh = false.Parameters
- mesh: Mesh
The source mesh whose fade attribute buffer changed.
Returns void
- mesh: Mesh
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
copy To Material
-
Copies material-level configuration to another supported material.
Per-mesh bounds are intentionally not copied because they belong to the source tile meshes.
Parameters
- material: DitheredTileFadeSupportedMaterial
The destination material, including a material clone.
Returns DitheredTileFadeMaterialPlugin
The destination material's dithered tile fade plugin.
- material: DitheredTileFadeSupportedMaterial
dispose
-
Releases all weakly held runtime fade state and disables fading.
The plugin remains attached to its material and can be reused through GetOrCreate.
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
-
Returns an array of the actively used textures.
Parameters
- _activeTextures: BaseTexture[]
Array of BaseTextures
Returns void
- _activeTextures: BaseTexture[]
get Animatables
-
Returns the animatable textures.
Parameters
- _animatables: IAnimatable[]
Array of animatable textures.
Returns void
- _animatables: IAnimatable[]
get Attributes
-
Registers the per-instance fade attribute when a mesh is rendered as a hardware or thin instance batch.
Parameters
- attributes: string[]
The attributes used to compile the material.
- _scene: Scene
The scene containing the mesh.
- mesh: AbstractMesh
The mesh being compiled.
Returns void
- attributes: string[]
get Class Name
-
Gets the class name.
Returns string
The class name.
get Custom Code
-
getCustomCode(
shaderType: string,
shaderLanguage?: ShaderLanguage,
): Nullable<{ [pointName: string]: string }>Gets the shader code injected by the plugin.
Parameters
- shaderType: string
The shader stage being customized.
- shaderLanguage: ShaderLanguage = ShaderLanguage.GLSL
The material shader language.
Returns Nullable<{ [pointName: string]: string }>
Fragment customizations, or null for the vertex stage.
- shaderType: string
get Fade Bounds To Ref
-
Copies a mesh's current bounds without allocating.
Parameters
- mesh: DitheredTileFadeMesh
The mesh whose bounds are queried.
- result: IDitheredTileFadeBounds
The object that receives the bounds.
Returns boolean
True when the mesh has explicit bounds. Otherwise false is returned with the source mesh's bounds for a hardware instance, or [0, 1].
- mesh: DitheredTileFadeMesh
get Samplers
-
Gets the samplers used by the plugin.
Parameters
- _samplers: string[]
list that the sampler names should be added to.
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
-
Gets the uniforms used by the plugin.
Returns { externalUniforms: string[] }
The external uniform names.
hard Bind For Sub Mesh
-
hardBindForSubMesh(
_uniformBuffer: UniformBuffer,
_scene: Scene,
_engine: AbstractEngine,
subMesh: SubMesh,
): voidUploads the current mesh's bounds for every draw, including shared and frozen materials.
Parameters
- _uniformBuffer: UniformBuffer
The material uniform buffer.
- _scene: Scene
The scene being rendered.
- _engine: AbstractEngine
The engine being used.
- subMesh: SubMesh
The submesh being bound.
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 to see if a texture is used in the material.
Parameters
- _texture: BaseTexture
Base texture to use.
Returns boolean
- Boolean specifying if a texture is used in the material.
- _texture: BaseTexture
is Compatible
-
Checks whether the plugin supports a shader language.
Parameters
- shaderLanguage: ShaderLanguage
The shader language to check.
Returns boolean
True for GLSL and WGSL.
- shaderLanguage: ShaderLanguage
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
-
prepareDefinesBeforeAttributes(
_defines: MaterialDefines,
_scene: Scene,
_mesh: AbstractMesh,
): voidSets the defines for the next rendering. Called before PrepareDefinesForAttributes is called.
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
reset
-
Removes all explicit mesh bounds while keeping the plugin enabled.
Returns void
reset Fade
-
Removes a mesh's explicit bounds. A hardware instance inherits its source mesh's bounds; a source mesh uses [0, 1].
Parameters
- mesh: DitheredTileFadeMesh
The mesh to reset.
Returns void
- mesh: DitheredTileFadeMesh
reset Thin Instance Fade
-
Removes one thin instance's explicit bounds so it inherits the source mesh's bounds.
Parameters
- mesh: Mesh
The source mesh containing the thin instance.
- index: number
The thin instance index.
- refresh: boolean = true
Whether to immediately upload the updated attribute buffer.
Returns void
- mesh: Mesh
serialize
-
Serializes this plugin configuration.
Returns any
- An object with the serialized config.
set Fade Bounds
-
Sets both normalized Bayer interval bounds for a mesh.
Parameters
- mesh: DitheredTileFadeMesh
The tile mesh or hardware instance whose draw calls use the bounds.
- lowerBound: number
The inclusive lower bound in the range [0, 1].
- upperBound: number
The exclusive upper bound in the range [0, 1].
Returns void
- mesh: DitheredTileFadeMesh
set Fade Lower Bound
-
Sets the normalized inclusive lower Bayer interval bound for a mesh.
Parameters
- mesh: DitheredTileFadeMesh
The tile mesh or hardware instance whose draw calls use the bound.
- lowerBound: number
The inclusive lower bound in the range [0, 1].
Returns void
- mesh: DitheredTileFadeMesh
set Fade Upper Bound
-
Sets the normalized exclusive upper Bayer interval bound for a mesh.
Parameters
- mesh: DitheredTileFadeMesh
The tile mesh or hardware instance whose draw calls use the bound.
- upperBound: number
The exclusive upper bound in the range [0, 1].
Returns void
- mesh: DitheredTileFadeMesh
set Thin Instance Fade Bounds
-
setThinInstanceFadeBounds(
mesh: Mesh,
index: number,
lowerBound: number,
upperBound: number,
refresh?: boolean,
): voidSets normalized Bayer interval bounds for one thin instance.
Parameters
- mesh: Mesh
The source mesh containing the thin instance.
- index: number
The thin instance index.
- lowerBound: number
The inclusive lower bound in the range [0, 1].
- upperBound: number
The exclusive upper bound in the range [0, 1].
- refresh: boolean = true
Whether to immediately upload the updated attribute buffer.
Returns void
- mesh: Mesh
set Thin Instance Fade Bounds Buffer
-
Sets normalized Bayer interval bounds for all thin instances from packed lower/upper pairs.
Parameters
- mesh: Mesh
The source mesh containing the thin instances.
- bounds: Float32Array
Packed lower/upper pairs, with two values per thin instance.
Returns void
- mesh: Mesh
StaticGet Or Create
-
Gets the plugin already attached to a material, or creates and attaches one.
Parameters
- material: DitheredTileFadeSupportedMaterial
The Standard or PBR material to extend.
Returns DitheredTileFadeMaterialPlugin
The material's dithered fade plugin.
- material: DitheredTileFadeSupportedMaterial
Applies an opaque, screen-space dithered fade for tile LOD meshes that share a Standard or PBR material.
The plugin keeps depth writing and the material's alpha mode unchanged. It affects the material color and integrated prepass outputs, but not standalone depth, shadow, picking, outline, or custom passes. Tile renderers using those passes must provide equivalent pass-specific coverage or exclude fading tiles from them.
Per-mesh bounds are runtime state. Material cloning and serialization do not copy them; use copyToMaterial to copy the enabled state to a cloned material and then configure bounds for the cloned tile meshes.
See
https://playground.babylonjs.com/#HI17VI#0