123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871 |
- import type { IAnimatable } from "../Animations/animatable.interface";
- import type { SmartArray } from "../Misc/smartArray";
- import { Observable } from "../Misc/observable";
- import type { Nullable } from "../types";
- import type { Matrix } from "../Maths/math.vector";
- import { SubMesh } from "../Meshes/subMesh";
- import type { AbstractMesh } from "../Meshes/abstractMesh";
- import { UniformBuffer } from "./uniformBuffer";
- import type { Effect } from "./effect";
- import type { BaseTexture } from "../Materials/Textures/baseTexture";
- import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
- import type { MaterialDefines } from "./materialDefines";
- import type { IInspectable } from "../Misc/iInspectable";
- import { Plane } from "../Maths/math.plane";
- import type { ShadowDepthWrapper } from "./shadowDepthWrapper";
- import type { IMaterialContext } from "../Engines/IMaterialContext";
- import { DrawWrapper } from "./drawWrapper";
- import { MaterialStencilState } from "./materialStencilState";
- import type { Scene } from "../scene";
- import type { AbstractScene } from "../abstractScene";
- import type { MaterialPluginDisposed, MaterialPluginIsReadyForSubMesh, MaterialPluginGetDefineNames, MaterialPluginBindForSubMesh, MaterialPluginGetActiveTextures, MaterialPluginHasTexture, MaterialPluginGetAnimatables, MaterialPluginPrepareDefines, MaterialPluginPrepareEffect, MaterialPluginPrepareUniformBuffer, MaterialPluginCreated, MaterialPluginFillRenderTargetTextures, MaterialPluginHasRenderTargetTextures, MaterialPluginHardBindForSubMesh } from "./materialPluginEvent";
- import type { ShaderCustomProcessingFunction } from "../Engines/Processors/shaderProcessingOptions";
- import type { IClipPlanesHolder } from "../Misc/interfaces/iClipPlanesHolder";
- import type { PrePassRenderer } from "../Rendering/prePassRenderer";
- import type { Mesh } from "../Meshes/mesh";
- import type { Animation } from "../Animations/animation";
- /**
- * Options for compiling materials.
- */
- export interface IMaterialCompilationOptions {
- /**
- * Defines whether clip planes are enabled.
- */
- clipPlane: boolean;
- /**
- * Defines whether instances are enabled.
- */
- useInstances: boolean;
- }
- /**
- * Options passed when calling customShaderNameResolve
- */
- export interface ICustomShaderNameResolveOptions {
- /**
- * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
- */
- processFinalCode?: Nullable<ShaderCustomProcessingFunction>;
- }
- /**
- * Base class for the main features of a material in Babylon.js
- */
- export declare class Material implements IAnimatable, IClipPlanesHolder {
- /**
- * Returns the triangle fill mode
- */
- static readonly TriangleFillMode = 0;
- /**
- * Returns the wireframe mode
- */
- static readonly WireFrameFillMode = 1;
- /**
- * Returns the point fill mode
- */
- static readonly PointFillMode = 2;
- /**
- * Returns the point list draw mode
- */
- static readonly PointListDrawMode = 3;
- /**
- * Returns the line list draw mode
- */
- static readonly LineListDrawMode = 4;
- /**
- * Returns the line loop draw mode
- */
- static readonly LineLoopDrawMode = 5;
- /**
- * Returns the line strip draw mode
- */
- static readonly LineStripDrawMode = 6;
- /**
- * Returns the triangle strip draw mode
- */
- static readonly TriangleStripDrawMode = 7;
- /**
- * Returns the triangle fan draw mode
- */
- static readonly TriangleFanDrawMode = 8;
- /**
- * Stores the clock-wise side orientation
- */
- static readonly ClockWiseSideOrientation = 0;
- /**
- * Stores the counter clock-wise side orientation
- */
- static readonly CounterClockWiseSideOrientation = 1;
- /**
- * The dirty texture flag value
- */
- static readonly TextureDirtyFlag = 1;
- /**
- * The dirty light flag value
- */
- static readonly LightDirtyFlag = 2;
- /**
- * The dirty fresnel flag value
- */
- static readonly FresnelDirtyFlag = 4;
- /**
- * The dirty attribute flag value
- */
- static readonly AttributesDirtyFlag = 8;
- /**
- * The dirty misc flag value
- */
- static readonly MiscDirtyFlag = 16;
- /**
- * The dirty prepass flag value
- */
- static readonly PrePassDirtyFlag = 32;
- /**
- * The all dirty flag value
- */
- static readonly AllDirtyFlag = 63;
- /**
- * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
- */
- static readonly MATERIAL_OPAQUE = 0;
- /**
- * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
- */
- static readonly MATERIAL_ALPHATEST = 1;
- /**
- * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
- */
- static readonly MATERIAL_ALPHABLEND = 2;
- /**
- * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
- * They are also discarded below the alpha cutoff threshold to improve performances.
- */
- static readonly MATERIAL_ALPHATESTANDBLEND = 3;
- /**
- * The Whiteout method is used to blend normals.
- * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
- */
- static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0;
- /**
- * The Reoriented Normal Mapping method is used to blend normals.
- * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
- */
- static readonly MATERIAL_NORMALBLENDMETHOD_RNM = 1;
- /**
- * Event observable which raises global events common to all materials (like MaterialPluginEvent.Created)
- */
- static OnEventObservable: Observable<Material>;
- /**
- * Custom callback helping to override the default shader used in the material.
- */
- customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
- /**
- * Custom shadow depth material to use for shadow rendering instead of the in-built one
- */
- shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
- /**
- * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
- * This means that the material can keep using a previous shader while a new one is being compiled.
- * This is mostly used when shader parallel compilation is supported (true by default)
- */
- allowShaderHotSwapping: boolean;
- /**
- * The ID of the material
- */
- id: string;
- /**
- * Gets or sets the unique id of the material
- */
- uniqueId: number;
- /** @internal */
- _loadedUniqueId: string;
- /**
- * The name of the material
- */
- name: string;
- /**
- * Gets or sets user defined metadata
- */
- metadata: any;
- /** @internal */
- _internalMetadata: any;
- /**
- * For internal use only. Please do not use.
- */
- reservedDataStore: any;
- /**
- * Specifies if the ready state should be checked on each call
- */
- checkReadyOnEveryCall: boolean;
- /**
- * Specifies if the ready state should be checked once
- */
- checkReadyOnlyOnce: boolean;
- /**
- * The state of the material
- */
- state: string;
- /**
- * If the material can be rendered to several textures with MRT extension
- */
- get canRenderToMRT(): boolean;
- /**
- * The alpha value of the material
- */
- protected _alpha: number;
- /**
- * List of inspectable custom properties (used by the Inspector)
- * @see https://doc.babylonjs.com/toolsAndResources/inspector#extensibility
- */
- inspectableCustomProperties: IInspectable[];
- /**
- * Sets the alpha value of the material
- */
- set alpha(value: number);
- /**
- * Gets the alpha value of the material
- */
- get alpha(): number;
- /**
- * Specifies if back face culling is enabled
- */
- protected _backFaceCulling: boolean;
- /**
- * Sets the culling state (true to enable culling, false to disable)
- */
- set backFaceCulling(value: boolean);
- /**
- * Gets the culling state
- */
- get backFaceCulling(): boolean;
- /**
- * Specifies if back or front faces should be culled (when culling is enabled)
- */
- protected _cullBackFaces: boolean;
- /**
- * Sets the type of faces that should be culled (true for back faces, false for front faces)
- */
- set cullBackFaces(value: boolean);
- /**
- * Gets the type of faces that should be culled
- */
- get cullBackFaces(): boolean;
- private _blockDirtyMechanism;
- /**
- * Block the dirty-mechanism for this specific material
- * When set to false after being true the material will be marked as dirty.
- */
- get blockDirtyMechanism(): boolean;
- set blockDirtyMechanism(value: boolean);
- /**
- * This allows you to modify the material without marking it as dirty after every change.
- * This function should be used if you need to make more than one dirty-enabling change to the material - adding a texture, setting a new fill mode and so on.
- * The callback will pass the material as an argument, so you can make your changes to it.
- * @param callback the callback to be executed that will update the material
- */
- atomicMaterialsUpdate(callback: (material: this) => void): void;
- /**
- * Stores the value for side orientation
- */
- sideOrientation: number;
- /**
- * Callback triggered when the material is compiled
- */
- onCompiled: Nullable<(effect: Effect) => void>;
- /**
- * Callback triggered when an error occurs
- */
- onError: Nullable<(effect: Effect, errors: string) => void>;
- /**
- * Callback triggered to get the render target textures
- */
- getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
- /**
- * Gets a boolean indicating that current material needs to register RTT
- */
- get hasRenderTargetTextures(): boolean;
- /**
- * Specifies if the material should be serialized
- */
- doNotSerialize: boolean;
- /**
- * @internal
- */
- _storeEffectOnSubMeshes: boolean;
- /**
- * Stores the animations for the material
- */
- animations: Nullable<Array<Animation>>;
- /**
- * An event triggered when the material is disposed
- */
- onDisposeObservable: Observable<Material>;
- /**
- * An observer which watches for dispose events
- */
- private _onDisposeObserver;
- private _onUnBindObservable;
- /**
- * Called during a dispose event
- */
- set onDispose(callback: () => void);
- private _onBindObservable;
- /**
- * An event triggered when the material is bound
- */
- get onBindObservable(): Observable<AbstractMesh>;
- /**
- * An observer which watches for bind events
- */
- private _onBindObserver;
- /**
- * Called during a bind event
- */
- set onBind(callback: (Mesh: AbstractMesh) => void);
- /**
- * An event triggered when the material is unbound
- */
- get onUnBindObservable(): Observable<Material>;
- protected _onEffectCreatedObservable: Nullable<Observable<{
- effect: Effect;
- subMesh: Nullable<SubMesh>;
- }>>;
- /**
- * An event triggered when the effect is (re)created
- */
- get onEffectCreatedObservable(): Observable<{
- effect: Effect;
- subMesh: Nullable<SubMesh>;
- }>;
- /**
- * Stores the value of the alpha mode
- */
- private _alphaMode;
- /**
- * Sets the value of the alpha mode.
- *
- * | Value | Type | Description |
- * | --- | --- | --- |
- * | 0 | ALPHA_DISABLE | |
- * | 1 | ALPHA_ADD | |
- * | 2 | ALPHA_COMBINE | |
- * | 3 | ALPHA_SUBTRACT | |
- * | 4 | ALPHA_MULTIPLY | |
- * | 5 | ALPHA_MAXIMIZED | |
- * | 6 | ALPHA_ONEONE | |
- * | 7 | ALPHA_PREMULTIPLIED | |
- * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
- * | 9 | ALPHA_INTERPOLATE | |
- * | 10 | ALPHA_SCREENMODE | |
- *
- */
- set alphaMode(value: number);
- /**
- * Gets the value of the alpha mode
- */
- get alphaMode(): number;
- /**
- * Stores the state of the need depth pre-pass value
- */
- private _needDepthPrePass;
- /**
- * Sets the need depth pre-pass value
- */
- set needDepthPrePass(value: boolean);
- /**
- * Gets the depth pre-pass value
- */
- get needDepthPrePass(): boolean;
- /**
- * Can this material render to prepass
- */
- get isPrePassCapable(): boolean;
- /**
- * Specifies if depth writing should be disabled
- */
- disableDepthWrite: boolean;
- /**
- * Specifies if color writing should be disabled
- */
- disableColorWrite: boolean;
- /**
- * Specifies if depth writing should be forced
- */
- forceDepthWrite: boolean;
- /**
- * Specifies the depth function that should be used. 0 means the default engine function
- */
- depthFunction: number;
- /**
- * Specifies if there should be a separate pass for culling
- */
- separateCullingPass: boolean;
- /**
- * Stores the state specifying if fog should be enabled
- */
- private _fogEnabled;
- /**
- * Sets the state for enabling fog
- */
- set fogEnabled(value: boolean);
- /**
- * Gets the value of the fog enabled state
- */
- get fogEnabled(): boolean;
- /**
- * Stores the size of points
- */
- pointSize: number;
- /**
- * Stores the z offset Factor value
- */
- zOffset: number;
- /**
- * Stores the z offset Units value
- */
- zOffsetUnits: number;
- get wireframe(): boolean;
- /**
- * Sets the state of wireframe mode
- */
- set wireframe(value: boolean);
- /**
- * Gets the value specifying if point clouds are enabled
- */
- get pointsCloud(): boolean;
- /**
- * Sets the state of point cloud mode
- */
- set pointsCloud(value: boolean);
- /**
- * Gets the material fill mode
- */
- get fillMode(): number;
- /**
- * Sets the material fill mode
- */
- set fillMode(value: number);
- /**
- * Gets or sets the active clipplane 1
- */
- clipPlane: Nullable<Plane>;
- /**
- * Gets or sets the active clipplane 2
- */
- clipPlane2: Nullable<Plane>;
- /**
- * Gets or sets the active clipplane 3
- */
- clipPlane3: Nullable<Plane>;
- /**
- * Gets or sets the active clipplane 4
- */
- clipPlane4: Nullable<Plane>;
- /**
- * Gets or sets the active clipplane 5
- */
- clipPlane5: Nullable<Plane>;
- /**
- * Gets or sets the active clipplane 6
- */
- clipPlane6: Nullable<Plane>;
- /**
- * Gives access to the stencil properties of the material
- */
- readonly stencil: MaterialStencilState;
- protected _useLogarithmicDepth: boolean;
- /**
- * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
- * You can try switching to logarithmic depth.
- * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/advanced/logarithmicDepthBuffer
- */
- get useLogarithmicDepth(): boolean;
- set useLogarithmicDepth(value: boolean);
- /**
- * @internal
- * Stores the effects for the material
- */
- _materialContext: IMaterialContext | undefined;
- protected _drawWrapper: DrawWrapper;
- /** @internal */
- _getDrawWrapper(): DrawWrapper;
- /**
- * @internal
- */
- _setDrawWrapper(drawWrapper: DrawWrapper): void;
- /**
- * Specifies if uniform buffers should be used
- */
- private _useUBO;
- /**
- * Stores a reference to the scene
- */
- private _scene;
- protected _needToBindSceneUbo: boolean;
- /**
- * Stores the fill mode state
- */
- private _fillMode;
- /**
- * Specifies if the depth write state should be cached
- */
- private _cachedDepthWriteState;
- /**
- * Specifies if the color write state should be cached
- */
- private _cachedColorWriteState;
- /**
- * Specifies if the depth function state should be cached
- */
- private _cachedDepthFunctionState;
- /**
- * Stores the uniform buffer
- * @internal
- */
- _uniformBuffer: UniformBuffer;
- /** @internal */
- _indexInSceneMaterialArray: number;
- /** @internal */
- meshMap: Nullable<{
- [id: string]: AbstractMesh | undefined;
- }>;
- /** @internal */
- _parentContainer: Nullable<AbstractScene>;
- /** @internal */
- _dirtyCallbacks: {
- [code: number]: () => void;
- };
- /** @internal */
- _uniformBufferLayoutBuilt: boolean;
- protected _eventInfo: MaterialPluginCreated & MaterialPluginDisposed & MaterialPluginHasTexture & MaterialPluginIsReadyForSubMesh & MaterialPluginGetDefineNames & MaterialPluginPrepareEffect & MaterialPluginPrepareDefines & MaterialPluginPrepareUniformBuffer & MaterialPluginBindForSubMesh & MaterialPluginGetAnimatables & MaterialPluginGetActiveTextures & MaterialPluginFillRenderTargetTextures & MaterialPluginHasRenderTargetTextures & MaterialPluginHardBindForSubMesh;
- /** @internal */
- _callbackPluginEventGeneric: (id: number, info: MaterialPluginGetActiveTextures | MaterialPluginGetAnimatables | MaterialPluginHasTexture | MaterialPluginDisposed | MaterialPluginGetDefineNames | MaterialPluginPrepareEffect | MaterialPluginPrepareUniformBuffer) => void;
- /** @internal */
- _callbackPluginEventIsReadyForSubMesh: (eventData: MaterialPluginIsReadyForSubMesh) => void;
- /** @internal */
- _callbackPluginEventPrepareDefines: (eventData: MaterialPluginPrepareDefines) => void;
- /** @internal */
- _callbackPluginEventPrepareDefinesBeforeAttributes: (eventData: MaterialPluginPrepareDefines) => void;
- /** @internal */
- _callbackPluginEventHardBindForSubMesh: (eventData: MaterialPluginHardBindForSubMesh) => void;
- /** @internal */
- _callbackPluginEventBindForSubMesh: (eventData: MaterialPluginBindForSubMesh) => void;
- /** @internal */
- _callbackPluginEventHasRenderTargetTextures: (eventData: MaterialPluginHasRenderTargetTextures) => void;
- /** @internal */
- _callbackPluginEventFillRenderTargetTextures: (eventData: MaterialPluginFillRenderTargetTextures) => void;
- /**
- * Creates a material instance
- * @param name defines the name of the material
- * @param scene defines the scene to reference
- * @param doNotAdd specifies if the material should be added to the scene
- */
- constructor(name: string, scene?: Nullable<Scene>, doNotAdd?: boolean);
- /**
- * Returns a string representation of the current material
- * @param fullDetails defines a boolean indicating which levels of logging is desired
- * @returns a string with material information
- */
- toString(fullDetails?: boolean): string;
- /**
- * Gets the class name of the material
- * @returns a string with the class name of the material
- */
- getClassName(): string;
- /** @internal */
- get _isMaterial(): boolean;
- /**
- * Specifies if updates for the material been locked
- */
- get isFrozen(): boolean;
- /**
- * Locks updates for the material
- */
- freeze(): void;
- /**
- * Unlocks updates for the material
- */
- unfreeze(): void;
- /**
- * Specifies if the material is ready to be used
- * @param mesh defines the mesh to check
- * @param useInstances specifies if instances should be used
- * @returns a boolean indicating if the material is ready to be used
- */
- isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
- /**
- * Specifies that the submesh is ready to be used
- * @param mesh defines the mesh to check
- * @param subMesh defines which submesh to check
- * @param useInstances specifies that instances should be used
- * @returns a boolean indicating that the submesh is ready or not
- */
- isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
- /**
- * Returns the material effect
- * @returns the effect associated with the material
- */
- getEffect(): Nullable<Effect>;
- /**
- * Returns the current scene
- * @returns a Scene
- */
- getScene(): Scene;
- /**
- * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
- */
- protected _forceAlphaTest: boolean;
- /**
- * The transparency mode of the material.
- */
- protected _transparencyMode: Nullable<number>;
- /**
- * Gets the current transparency mode.
- */
- get transparencyMode(): Nullable<number>;
- /**
- * Sets the transparency mode of the material.
- *
- * | Value | Type | Description |
- * | ----- | ----------------------------------- | ----------- |
- * | 0 | OPAQUE | |
- * | 1 | ALPHATEST | |
- * | 2 | ALPHABLEND | |
- * | 3 | ALPHATESTANDBLEND | |
- *
- */
- set transparencyMode(value: Nullable<number>);
- /**
- * Returns true if alpha blending should be disabled.
- */
- protected get _disableAlphaBlending(): boolean;
- /**
- * Specifies whether or not this material should be rendered in alpha blend mode.
- * @returns a boolean specifying if alpha blending is needed
- */
- needAlphaBlending(): boolean;
- /**
- * Specifies if the mesh will require alpha blending
- * @param mesh defines the mesh to check
- * @returns a boolean specifying if alpha blending is needed for the mesh
- */
- needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
- /**
- * Specifies whether or not this material should be rendered in alpha test mode.
- * @returns a boolean specifying if an alpha test is needed.
- */
- needAlphaTesting(): boolean;
- /**
- * Specifies if material alpha testing should be turned on for the mesh
- * @param mesh defines the mesh to check
- * @returns a boolean specifying if alpha testing should be turned on for the mesh
- */
- protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
- /**
- * Gets the texture used for the alpha test
- * @returns the texture to use for alpha testing
- */
- getAlphaTestTexture(): Nullable<BaseTexture>;
- /**
- * Marks the material to indicate that it needs to be re-calculated
- * @param forceMaterialDirty - Forces the material to be marked as dirty for all components (same as this.markAsDirty(Material.AllDirtyFlag)). You should use this flag if the material is frozen and you want to force a recompilation.
- */
- markDirty(forceMaterialDirty?: boolean): void;
- /**
- * @internal
- */
- _preBind(effect?: Effect | DrawWrapper, overrideOrientation?: Nullable<number>): boolean;
- /**
- * Binds the material to the mesh
- * @param world defines the world transformation matrix
- * @param mesh defines the mesh to bind the material to
- */
- bind(world: Matrix, mesh?: Mesh): void;
- /**
- * Initializes the uniform buffer layout for the shader.
- */
- buildUniformLayout(): void;
- /**
- * Binds the submesh to the material
- * @param world defines the world transformation matrix
- * @param mesh defines the mesh containing the submesh
- * @param subMesh defines the submesh to bind the material to
- */
- bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
- /**
- * Binds the world matrix to the material
- * @param world defines the world transformation matrix
- */
- bindOnlyWorldMatrix(world: Matrix): void;
- /**
- * Binds the view matrix to the effect
- * @param effect defines the effect to bind the view matrix to
- */
- bindView(effect: Effect): void;
- /**
- * Binds the view projection and projection matrices to the effect
- * @param effect defines the effect to bind the view projection and projection matrices to
- */
- bindViewProjection(effect: Effect): void;
- /**
- * Binds the view matrix to the effect
- * @param effect defines the effect to bind the view matrix to
- * @param variableName name of the shader variable that will hold the eye position
- */
- bindEyePosition(effect: Effect, variableName?: string): void;
- /**
- * Processes to execute after binding the material to a mesh
- * @param mesh defines the rendered mesh
- * @param effect defines the effect used to bind the material
- * @param _subMesh defines the subMesh that the material has been bound for
- */
- protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>, _subMesh?: SubMesh): void;
- /**
- * Unbinds the material from the mesh
- */
- unbind(): void;
- /**
- * Returns the animatable textures.
- * @returns - Array of animatable textures.
- */
- getAnimatables(): IAnimatable[];
- /**
- * Gets the active textures from the material
- * @returns an array of textures
- */
- getActiveTextures(): BaseTexture[];
- /**
- * Specifies if the material uses a texture
- * @param texture defines the texture to check against the material
- * @returns a boolean specifying if the material uses the texture
- */
- hasTexture(texture: BaseTexture): boolean;
- /**
- * Makes a duplicate of the material, and gives it a new name
- * @param name defines the new name for the duplicated material
- * @returns the cloned material
- */
- clone(name: string): Nullable<Material>;
- protected _clonePlugins(targetMaterial: Material, rootUrl: string): void;
- /**
- * Gets the meshes bound to the material
- * @returns an array of meshes bound to the material
- */
- getBindedMeshes(): AbstractMesh[];
- /**
- * Force shader compilation
- * @param mesh defines the mesh associated with this material
- * @param onCompiled defines a function to execute once the material is compiled
- * @param options defines the options to configure the compilation
- * @param onError defines a function to execute if the material fails compiling
- */
- forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
- /**
- * Force shader compilation
- * @param mesh defines the mesh that will use this material
- * @param options defines additional options for compiling the shaders
- * @returns a promise that resolves when the compilation completes
- */
- forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
- private static readonly _AllDirtyCallBack;
- private static readonly _ImageProcessingDirtyCallBack;
- private static readonly _TextureDirtyCallBack;
- private static readonly _FresnelDirtyCallBack;
- private static readonly _MiscDirtyCallBack;
- private static readonly _PrePassDirtyCallBack;
- private static readonly _LightsDirtyCallBack;
- private static readonly _AttributeDirtyCallBack;
- private static _FresnelAndMiscDirtyCallBack;
- private static _TextureAndMiscDirtyCallBack;
- private static readonly _DirtyCallbackArray;
- private static readonly _RunDirtyCallBacks;
- /**
- * Marks a define in the material to indicate that it needs to be re-computed
- * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
- */
- markAsDirty(flag: number): void;
- /**
- * Resets the draw wrappers cache for all submeshes that are using this material
- */
- resetDrawCache(): void;
- /**
- * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
- * @param func defines a function which checks material defines against the submeshes
- */
- protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
- /**
- * Indicates that the scene should check if the rendering now needs a prepass
- */
- protected _markScenePrePassDirty(): void;
- /**
- * Indicates that we need to re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsAllDirty(): void;
- /**
- * Indicates that image processing needs to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsImageProcessingDirty(): void;
- /**
- * Indicates that textures need to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsTexturesDirty(): void;
- /**
- * Indicates that fresnel needs to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsFresnelDirty(): void;
- /**
- * Indicates that fresnel and misc need to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
- /**
- * Indicates that lights need to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsLightsDirty(): void;
- /**
- * Indicates that attributes need to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsAttributesDirty(): void;
- /**
- * Indicates that misc needs to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsMiscDirty(): void;
- /**
- * Indicates that prepass needs to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsPrePassDirty(): void;
- /**
- * Indicates that textures and misc need to be re-calculated for all submeshes
- */
- protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
- protected _checkScenePerformancePriority(): void;
- /**
- * Sets the required values to the prepass renderer.
- * @param prePassRenderer defines the prepass renderer to setup.
- * @returns true if the pre pass is needed.
- */
- setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
- /**
- * Disposes the material
- * @param forceDisposeEffect specifies if effects should be forcefully disposed
- * @param forceDisposeTextures specifies if textures should be forcefully disposed
- * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
- */
- dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
- /**
- * @internal
- */
- private releaseVertexArrayObject;
- /**
- * Serializes this material
- * @returns the serialized material object
- */
- serialize(): any;
- protected _serializePlugins(serializationObject: any): void;
- /**
- * Creates a material from parsed material data
- * @param parsedMaterial defines parsed material data
- * @param scene defines the hosting scene
- * @param rootUrl defines the root URL to use to load textures
- * @returns a new material
- */
- static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
- protected static _ParsePlugins(serializationObject: any, material: Material, scene: Scene, rootUrl: string): void;
- }
|