diff --git a/packages/dev/core/src/Engines/thinEngine.ts b/packages/dev/core/src/Engines/thinEngine.ts index 45b17bbded8..a084633c27e 100644 --- a/packages/dev/core/src/Engines/thinEngine.ts +++ b/packages/dev/core/src/Engines/thinEngine.ts @@ -2924,7 +2924,7 @@ export class ThinEngine { * @returns the new Effect */ public createEffect( - baseName: IShaderPath & { vertexToken?: string; fragmentToken?: string }, + baseName: string | (IShaderPath & { vertexToken?: string; fragmentToken?: string }), attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], diff --git a/packages/dev/core/src/Engines/webgpuEngine.ts b/packages/dev/core/src/Engines/webgpuEngine.ts index 1b3264f1478..6993734872b 100644 --- a/packages/dev/core/src/Engines/webgpuEngine.ts +++ b/packages/dev/core/src/Engines/webgpuEngine.ts @@ -1766,7 +1766,7 @@ export class WebGPUEngine extends Engine { * @returns the new Effect */ public createEffect( - baseName: IShaderPath & { vertexToken?: string; fragmentToken?: string }, + baseName: string | (IShaderPath & { vertexToken?: string; fragmentToken?: string }), attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], diff --git a/packages/dev/core/src/Materials/effect.ts b/packages/dev/core/src/Materials/effect.ts index 0dc995f8460..34ed1563e4f 100644 --- a/packages/dev/core/src/Materials/effect.ts +++ b/packages/dev/core/src/Materials/effect.ts @@ -28,36 +28,34 @@ import type { PostProcess } from "../PostProcesses/postProcess"; * * object: `{ vertex: "custom", fragment: "custom" }`, used with `Effect.ShadersStore["customVertexShader"]` and `Effect.ShadersStore["customFragmentShader"]` * * string: `"./COMMON_NAME"`, used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder. */ -export type IShaderPath = - | { - /** - * Directly pass the shader code - */ - vertexSource?: string; - /** - * Directly pass the shader code - */ - fragmentSource?: string; - /** - * Used with Effect.ShadersStore. If the `vertex` is set to `"custom`, then - * Babylon.js will read from Effect.ShadersStore["customVertexShader"] - */ - vertex?: string; - /** - * Used with Effect.ShadersStore. If the `fragment` is set to `"custom`, then - * Babylon.js will read from Effect.ShadersStore["customFragmentShader"] - */ - fragment?: string; - /** - * Used with shader code in script tags - */ - vertexElement?: string; - /** - * Used with shader code in script tags - */ - fragmentElement?: string; - } - | string; +export type IShaderPath = { + /** + * Directly pass the shader code + */ + vertexSource?: string; + /** + * Directly pass the shader code + */ + fragmentSource?: string; + /** + * Used with Effect.ShadersStore. If the `vertex` is set to `"custom`, then + * Babylon.js will read from Effect.ShadersStore["customVertexShader"] + */ + vertex?: string; + /** + * Used with Effect.ShadersStore. If the `fragment` is set to `"custom`, then + * Babylon.js will read from Effect.ShadersStore["customFragmentShader"] + */ + fragment?: string; + /** + * Used with shader code in script tags + */ + vertexElement?: string; + /** + * Used with shader code in script tags + */ + fragmentElement?: string; +}; /** * Options to be used when creating an effect. @@ -145,7 +143,7 @@ export class Effect implements IDisposable { /** * Name of the effect. */ - public name: IShaderPath; + public name: IShaderPath | string; /** * String container all the define statements that should be set on the shader. */ @@ -275,7 +273,7 @@ export class Effect implements IDisposable { * @param shaderLanguage the language the shader is written in (default: GLSL) */ constructor( - baseName: IShaderPath, + baseName: IShaderPath | string, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers: Nullable = null, diff --git a/packages/dev/core/src/Materials/shaderMaterial.ts b/packages/dev/core/src/Materials/shaderMaterial.ts index e0bd8640127..a8f79784dcc 100644 --- a/packages/dev/core/src/Materials/shaderMaterial.ts +++ b/packages/dev/core/src/Materials/shaderMaterial.ts @@ -108,7 +108,7 @@ export interface IShaderMaterialOptions { * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/shaders/shaderMaterial */ export class ShaderMaterial extends PushMaterial { - private _shaderPath: IShaderPath; + private _shaderPath: IShaderPath | string; private _options: IShaderMaterialOptions; private _textures: { [name: string]: BaseTexture } = {}; private _textureArrays: { [name: string]: BaseTexture[] } = {}; @@ -162,7 +162,7 @@ export class ShaderMaterial extends PushMaterial { * @param options Define the options used to create the shader * @param storeEffectOnSubMeshes true to store effect on submeshes, false to store the effect directly in the material class. */ - constructor(name: string, scene: Scene, shaderPath: IShaderPath, options: Partial = {}, storeEffectOnSubMeshes = true) { + constructor(name: string, scene: Scene, shaderPath: IShaderPath | string, options: Partial = {}, storeEffectOnSubMeshes = true) { super(name, scene, storeEffectOnSubMeshes); this._shaderPath = shaderPath; @@ -186,7 +186,7 @@ export class ShaderMaterial extends PushMaterial { * Gets the shader path used to define the shader code * It can be modified to trigger a new compilation */ - public get shaderPath(): IShaderPath { + public get shaderPath() { return this._shaderPath; } @@ -194,7 +194,7 @@ export class ShaderMaterial extends PushMaterial { * Sets the shader path used to define the shader code * It can be modified to trigger a new compilation */ - public set shaderPath(shaderPath: IShaderPath) { + public set shaderPath(shaderPath: IShaderPath | string) { this._shaderPath = shaderPath; }