@galacean/engine-core 2.0.0-alpha.30 → 2.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-core",
3
- "version": "2.0.0-alpha.30",
3
+ "version": "2.0.0-alpha.31",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -18,10 +18,10 @@
18
18
  "types/**/*"
19
19
  ],
20
20
  "dependencies": {
21
- "@galacean/engine-math": "2.0.0-alpha.30"
21
+ "@galacean/engine-math": "2.0.0-alpha.31"
22
22
  },
23
23
  "devDependencies": {
24
- "@galacean/engine-design": "2.0.0-alpha.30"
24
+ "@galacean/engine-design": "2.0.0-alpha.31"
25
25
  },
26
26
  "scripts": {
27
27
  "b:types": "tsc"
package/types/Engine.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IHardwareRenderer, IInputOptions, IPhysics, IShaderLab, IXRDevice } from "@galacean/engine-design";
1
+ import { IHardwareRenderer, IInputOptions, IPhysics, IShaderCompiler, IXRDevice } from "@galacean/engine-design";
2
2
  import { Canvas } from "./Canvas";
3
3
  import { EngineSettings } from "./EngineSettings";
4
4
  import { Entity } from "./Entity";
@@ -148,8 +148,8 @@ export interface EngineConfiguration {
148
148
  physics?: IPhysics;
149
149
  /** XR Device. */
150
150
  xrDevice?: IXRDevice;
151
- /** Shader lab. */
152
- shaderLab?: IShaderLab;
151
+ /** Shader compiler. */
152
+ shaderCompiler?: IShaderCompiler;
153
153
  /** Input options. */
154
154
  input?: IInputOptions;
155
155
  }
package/types/index.d.ts CHANGED
@@ -54,7 +54,6 @@ export * from "./material/index";
54
54
  export * from "./texture/index";
55
55
  export * from "./graphic/index";
56
56
  export * from "./2d/index";
57
- export * from "./shaderlib/index";
58
57
  export * from "./animation/index";
59
58
  export * from "./mesh/index";
60
59
  export * from "./sky/index";
@@ -69,6 +68,7 @@ export * from "./renderingHardwareInterface/index";
69
68
  export * from "./physics/index";
70
69
  export * from "./Utils";
71
70
  export * from "./audio/index";
71
+ export { Polyfill } from "./Polyfill";
72
72
  export { ShaderMacroCollection } from "./shader/ShaderMacroCollection";
73
73
  export * from "./postProcess";
74
74
  export { AntiAliasing } from "./enums/AntiAliasing";
@@ -18,14 +18,17 @@ export declare class BaseMaterial extends Material {
18
18
  protected static _emissiveTextureProp: ShaderProperty;
19
19
  protected static _alphaCutoffProp: ShaderProperty;
20
20
  private static _alphaCutoffMacro;
21
+ private static _blendEnabledProp;
22
+ private static _depthWriteEnabledProp;
23
+ private static _renderQueueTypeProp;
24
+ private static _sourceColorBlendFactorProp;
25
+ private static _destinationColorBlendFactorProp;
26
+ private static _sourceAlphaBlendFactorProp;
27
+ private static _destinationAlphaBlendFactorProp;
28
+ private static _rasterStateCullModeProp;
21
29
  private _renderFace;
22
30
  protected _isTransparent: boolean;
23
31
  private _blendMode;
24
- /**
25
- * Shader used by the material.
26
- */
27
- get shader(): Shader;
28
- set shader(value: Shader);
29
32
  /**
30
33
  * Whether transparent of first shader pass render state.
31
34
  */
@@ -58,22 +61,19 @@ export declare class BaseMaterial extends Material {
58
61
  constructor(engine: Engine, shader: Shader);
59
62
  /**
60
63
  * Set if is transparent of the shader pass render state.
61
- * @param passIndex - Shader pass index
62
64
  * @param isTransparent - If is transparent
63
65
  */
64
- setIsTransparent(passIndex: number, isTransparent: boolean): void;
66
+ setIsTransparent(isTransparent: boolean): void;
65
67
  /**
66
68
  * Set the blend mode of shader pass render state.
67
- * @param passIndex - Shader pass index
68
69
  * @param blendMode - Blend mode
69
70
  */
70
- setBlendMode(passIndex: number, blendMode: BlendMode): void;
71
+ setBlendMode(blendMode: BlendMode): void;
71
72
  /**
72
73
  * Set the render face of shader pass render state.
73
- * @param passIndex - Shader pass index
74
74
  * @param renderFace - Render face
75
75
  */
76
- setRenderFace(passIndex: number, renderFace: RenderFace): void;
76
+ setRenderFace(renderFace: RenderFace): void;
77
77
  /**
78
78
  * Clone and return the instance.
79
79
  */
@@ -3,7 +3,6 @@ import { Engine } from "../Engine";
3
3
  import { ReferResource } from "../asset/ReferResource";
4
4
  import { Shader } from "../shader/Shader";
5
5
  import { ShaderData } from "../shader/ShaderData";
6
- import { RenderState } from "../shader/state/RenderState";
7
6
  /**
8
7
  * Material.
9
8
  */
@@ -20,14 +19,6 @@ export declare class Material extends ReferResource implements IClone {
20
19
  */
21
20
  get shader(): Shader;
22
21
  set shader(value: Shader);
23
- /**
24
- * First Render state.
25
- */
26
- get renderState(): RenderState;
27
- /**
28
- * Render states.
29
- */
30
- get renderStates(): Readonly<RenderState[]>;
31
22
  /**
32
23
  * Create a material instance.
33
24
  * @param engine - Engine to which the material belongs
@@ -4,7 +4,7 @@ import { RenderTarget, Texture2D } from "../texture";
4
4
  import { PostProcessManager } from "./PostProcessManager";
5
5
  import { PostProcessPass } from "./PostProcessPass";
6
6
  export declare class PostProcessUberPass extends PostProcessPass {
7
- static readonly UBER_SHADER_NAME = "UberPost";
7
+ static readonly UBER_SHADER_NAME = "PostProcess/Uber";
8
8
  private _uberMaterial;
9
9
  private _bloomMaterial;
10
10
  private _mipDownRT;
@@ -10,7 +10,7 @@ export declare enum BloomDownScaleMode {
10
10
  Quarter = 1
11
11
  }
12
12
  export declare class BloomEffect extends PostProcessEffect {
13
- static readonly SHADER_NAME = "PostProcessEffect Bloom";
13
+ static readonly SHADER_NAME = "PostProcess/Bloom";
14
14
  /**
15
15
  * Controls whether to use bicubic sampling instead of bilinear sampling for the upSampling passes.
16
16
  * @remarks This is slightly more expensive but helps getting smoother visuals.
@@ -16,32 +16,24 @@ export declare class Shader implements IReferable {
16
16
  *
17
17
  * @remarks
18
18
  *
19
- * ShaderLab must be enabled first as follows:
19
+ * The shader compiler must be enabled first as follows:
20
20
  * ```ts
21
- * // Import shaderLab
22
- * import { ShaderLab } from "@galacean/engine-shaderlab";
23
- * // Create engine with shaderLab
24
- * const engine = await WebGLEngine.create({ canvas: "canvas", shader: new ShaderLab() });
21
+ * // Import the shader compiler
22
+ * import { ShaderCompiler } from "@galacean/engine-shader-compiler";
23
+ * // Create engine with the shader compiler
24
+ * const engine = await WebGLEngine.create({ canvas: "canvas", shaderCompiler: new ShaderCompiler() });
25
25
  * ...
26
26
  * ```
27
27
  *
28
28
  * @param shaderSource - Shader code
29
29
  * @param platformTarget - Shader platform target, @defaultValue ShaderLanguage.GLSLES300
30
- * @param path - Shader location path
30
+ * @param path - Shader location path, used to resolve relative `#include` paths in ShaderLab source
31
31
  * @returns Shader
32
32
  *
33
33
  * @throws
34
- * Throw string exception if shaderLab has not been enabled properly.
34
+ * Throw string exception if the shader compiler has not been enabled properly.
35
35
  */
36
36
  static create(shaderSource: string, platformTarget?: ShaderLanguage, path?: string): Shader;
37
- /**
38
- * Create a shader.
39
- * @param name - Name of the shader
40
- * @param vertexSource - Vertex source code
41
- * @param fragmentSource - Fragment source code
42
- * @returns Shader
43
- */
44
- static create(name: string, vertexSource: string, fragmentSource: string): Shader;
45
37
  /**
46
38
  * Create a shader.
47
39
  * @param name - Name of the shader
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Shader registry and GLSL utilities. Holds the `#include` lookup table
3
+ * the runtime preprocessor reads, and the GLSL ES 100 → 300 syntax
4
+ * converter the WebGL2 path uses.
5
+ */
6
+ export declare class ShaderFactory {
7
+ static readonly includeMap: Record<string, string>;
8
+ static readonly shaderExtension: string;
9
+ private static readonly _has300OutInFragReg;
10
+ /**
11
+ * Register a chunk source so `#include` resolves it.
12
+ * @param includeName - The path key referenced in `#include "..."`.
13
+ * @param includeSource - GLSL chunk source text.
14
+ */
15
+ static registerInclude(includeName: string, includeSource: string): void;
16
+ /**
17
+ * Remove a registered shader chunk.
18
+ * @param includeName - The path key passed to `registerInclude`.
19
+ */
20
+ static unRegisterInclude(includeName: string): void;
21
+ /**
22
+ * Convert lower GLSL version to GLSL 300 es.
23
+ * @param shader - code
24
+ * @param isFrag - Whether it is a fragment shader.
25
+ */
26
+ static convertTo300(shader: string, isFrag?: boolean): string;
27
+ private static _replaceMRTShader;
28
+ }
@@ -5,25 +5,8 @@ import { ShaderLanguage } from "./enums/ShaderLanguage";
5
5
  * Shader pass containing vertex and fragment source.
6
6
  */
7
7
  export declare class ShaderPass extends ShaderPart {
8
- private _vertexSource?;
9
- private _fragmentSource?;
10
8
  private static _shaderMacroList;
11
9
  private static _macroMap;
12
- /**
13
- * Create a shader pass.
14
- * @param name - Shader pass name
15
- * @param vertexSource - Vertex shader source
16
- * @param fragmentSource - Fragment shader source
17
- * @param tags - Tags
18
- */
19
- constructor(name: string, vertexSource: string, fragmentSource: string, tags?: Record<string, number | string | boolean>);
20
- /**
21
- * Create a shader pass.
22
- * @param vertexSource - Vertex shader source
23
- * @param fragmentSource - Fragment shader source
24
- * @param tags - Tags
25
- */
26
- constructor(vertexSource: string, fragmentSource: string, tags?: Record<string, number | string | boolean>);
27
10
  /**
28
11
  * Create a shader pass from precompiled instructions.
29
12
  * @param name - Shader pass name
@@ -34,6 +17,5 @@ export declare class ShaderPass extends ShaderPart {
34
17
  */
35
18
  constructor(name: string, vertexShaderInstructions: ShaderInstruction[], fragmentShaderInstructions: ShaderInstruction[], platformTarget: ShaderLanguage, tags?: Record<string, number | string | boolean>);
36
19
  private _getCanonicalShaderProgram;
37
- private _compilePlatformSource;
38
- private _compileShaderLabSource;
20
+ private _compileShaderSource;
39
21
  }
@@ -11,9 +11,9 @@ export { ShaderPropertyType } from "./enums/ShaderPropertyType";
11
11
  export { StencilOperation } from "./enums/StencilOperation";
12
12
  export { Shader } from "./Shader";
13
13
  export { ShaderData } from "./ShaderData";
14
+ export { ShaderFactory } from "./ShaderFactory";
14
15
  export { ShaderMacro } from "./ShaderMacro";
15
16
  export { ShaderPass } from "./ShaderPass";
16
17
  export { ShaderProperty } from "./ShaderProperty";
17
18
  export { ShaderTagKey } from "./ShaderTagKey";
18
- export * from "./state";
19
19
  export { SubShader } from "./SubShader";
@@ -17,5 +17,4 @@ export declare class RenderState {
17
17
  readonly rasterState: RasterState;
18
18
  /** Render queue type. */
19
19
  renderQueueType: RenderQueueType;
20
- private _applyStatesByShaderData;
21
20
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export { BlendState } from "./BlendState";
2
- export { DepthState } from "./DepthState";
3
- export { RasterState } from "./RasterState";
4
- export { RenderState } from "./RenderState";
5
- export { RenderTargetBlendState } from "./RenderTargetBlendState";
6
- export { StencilState } from "./StencilState";
@@ -1,20 +0,0 @@
1
- import { ShaderMacro } from "../shader/ShaderMacro";
2
- export declare class ShaderFactory {
3
- private static readonly _has300OutInFragReg;
4
- static parseCustomMacros(macros: ShaderMacro[]): string;
5
- static registerInclude(includeName: string, includeSource: string): void;
6
- static unRegisterInclude(includeName: string): void;
7
- /**
8
- * @param regex The default regex is for engine's builtin glsl `#include` syntax,
9
- * since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
10
- */
11
- static parseIncludes(src: string, regex?: RegExp): string;
12
- /**
13
- * Convert lower GLSL version to GLSL 300 es.
14
- * @param shader - code
15
- * @param isFrag - Whether it is a fragment shader.
16
- * */
17
- static convertTo300(shader: string, isFrag?: boolean): string;
18
- private static _has300Output;
19
- private static _replaceMRTShader;
20
- }
@@ -1,62 +0,0 @@
1
- export declare const ShaderLib: {
2
- particle_common: string;
3
- velocity_over_lifetime_module: string;
4
- rotation_over_lifetime_module: string;
5
- size_over_lifetime_module: string;
6
- color_over_lifetime_module: string;
7
- texture_sheet_animation_module: string;
8
- force_over_lifetime_module: string;
9
- limit_velocity_over_lifetime_module: string;
10
- noise_module: string;
11
- particle_feedback_simulation: string;
12
- sphere_billboard: string;
13
- stretched_billboard: string;
14
- vertical_billboard: string;
15
- horizontal_billboard: string;
16
- particle_mesh: string;
17
- normal_get: string;
18
- pbr_frag_define: string;
19
- pbr_helper: string;
20
- brdf: string;
21
- direct_irradiance_frag_define: string;
22
- ibl_frag_define: string;
23
- pbr_frag: string;
24
- btdf: string;
25
- refraction: string;
26
- ShadowCoord: string;
27
- ShadowFragmentDeclaration: string;
28
- shadow_sample_tent: string;
29
- ShadowVertexDeclaration: string;
30
- ShadowVertex: string;
31
- common: string;
32
- common_vert: string;
33
- transform_declare: string;
34
- camera_declare: string;
35
- color_share: string;
36
- normal_share: string;
37
- uv_share: string;
38
- worldpos_share: string;
39
- FogVertexDeclaration: string;
40
- FogFragmentDeclaration: string;
41
- PositionClipSpaceDeclaration: string;
42
- begin_normal_vert: string;
43
- begin_position_vert: string;
44
- position_vert: string;
45
- color_vert: string;
46
- normal_vert: string;
47
- skinning_vert: string;
48
- blendShape_input: string;
49
- blendShape_vert: string;
50
- uv_vert: string;
51
- worldpos_vert: string;
52
- FogVertex: string;
53
- light_frag_define: string;
54
- mobile_material_frag: string;
55
- FogFragment: string;
56
- PositionClipSpaceVertex: string;
57
- begin_mobile_frag: string;
58
- begin_viewdir_frag: string;
59
- mobile_blinnphong_frag: string;
60
- noise_common: string;
61
- noise_simplex_3D_grad: string;
62
- };
@@ -1 +0,0 @@
1
- export { ShaderFactory } from "./ShaderFactory";
@@ -1,18 +0,0 @@
1
- declare const _default: {
2
- particle_common: string;
3
- velocity_over_lifetime_module: string;
4
- rotation_over_lifetime_module: string;
5
- size_over_lifetime_module: string;
6
- color_over_lifetime_module: string;
7
- texture_sheet_animation_module: string;
8
- force_over_lifetime_module: string;
9
- limit_velocity_over_lifetime_module: string;
10
- noise_module: string;
11
- particle_feedback_simulation: string;
12
- sphere_billboard: string;
13
- stretched_billboard: string;
14
- vertical_billboard: string;
15
- horizontal_billboard: string;
16
- particle_mesh: string;
17
- };
18
- export default _default;
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- pbr_frag_define: string;
3
- pbr_helper: string;
4
- brdf: string;
5
- direct_irradiance_frag_define: string;
6
- ibl_frag_define: string;
7
- pbr_frag: string;
8
- btdf: string;
9
- refraction: string;
10
- };
11
- export default _default;
@@ -1,8 +0,0 @@
1
- declare const _default: {
2
- ShadowCoord: string;
3
- ShadowFragmentDeclaration: string;
4
- shadow_sample_tent: string;
5
- ShadowVertexDeclaration: string;
6
- ShadowVertex: string;
7
- };
8
- export default _default;