@galacean/engine-core 2.0.0-alpha.6 → 2.0.0-alpha.60
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/dist/main.js +28967 -22183
- package/dist/main.js.map +1 -1
- package/dist/module.js +28951 -22175
- package/dist/module.js.map +1 -1
- package/package.json +3 -5
- package/types/2d/assembler/ISpriteAssembler.d.ts +1 -0
- package/types/2d/assembler/ISpriteRenderer.d.ts +3 -2
- package/types/2d/assembler/SimpleSpriteAssembler.d.ts +1 -0
- package/types/2d/assembler/SlicedSpriteAssembler.d.ts +1 -0
- package/types/2d/assembler/TiledSpriteAssembler.d.ts +1 -0
- package/types/2d/atlas/FontAtlas.d.ts +23 -1
- package/types/2d/atlas/SpriteAtlas.d.ts +8 -0
- package/types/2d/sprite/Sprite.d.ts +30 -4
- package/types/2d/sprite/SpriteMask.d.ts +49 -1
- package/types/2d/sprite/SpriteRenderer.d.ts +35 -1
- package/types/2d/text/CharInfo.d.ts +20 -1
- package/types/2d/text/CharRenderInfo.d.ts +15 -1
- package/types/2d/text/Font.d.ts +11 -1
- package/types/2d/text/ITextRenderer.d.ts +3 -0
- package/types/2d/text/SubFont.d.ts +35 -1
- package/types/2d/text/TextRenderer.d.ts +54 -1
- package/types/2d/text/TextUtils.d.ts +89 -1
- package/types/Background.d.ts +19 -2
- package/types/BasicResources.d.ts +58 -0
- package/types/Camera.d.ts +79 -1
- package/types/Canvas.d.ts +36 -7
- package/types/Component.d.ts +35 -2
- package/types/ComponentsDependencies.d.ts +38 -1
- package/types/ComponentsManager.d.ts +20 -0
- package/types/Engine.d.ts +114 -7
- package/types/EngineEventType.d.ts +13 -0
- package/types/Entity.d.ts +112 -21
- package/types/Polyfill.d.ts +12 -1
- package/types/RenderPipeline/BasicRenderPipeline.d.ts +4 -2
- package/types/RenderPipeline/BatcherManager.d.ts +23 -1
- package/types/RenderPipeline/Blitter.d.ts +1 -1
- package/types/RenderPipeline/CullingResults.d.ts +17 -1
- package/types/RenderPipeline/DepthOnlyPass.d.ts +15 -1
- package/types/RenderPipeline/InstanceBuffer.d.ts +28 -0
- package/types/RenderPipeline/MaskManager.d.ts +36 -1
- package/types/RenderPipeline/OpaqueTexturePass.d.ts +16 -1
- package/types/RenderPipeline/PipelineUtils.d.ts +11 -1
- package/types/RenderPipeline/PrimitiveChunk.d.ts +27 -1
- package/types/RenderPipeline/PrimitiveChunkManager.d.ts +16 -1
- package/types/RenderPipeline/RenderContext.d.ts +46 -1
- package/types/RenderPipeline/RenderElement.d.ts +26 -6
- package/types/RenderPipeline/RenderQueue.d.ts +23 -1
- package/types/RenderPipeline/RenderTargetPool.d.ts +17 -1
- package/types/RenderPipeline/SubPrimitiveChunk.d.ts +14 -1
- package/types/RenderPipeline/VertexArea.d.ts +10 -1
- package/types/RenderPipeline/VertexMergeBatcher.d.ts +11 -0
- package/types/RenderPipeline/enums/RenderQueueMaskType.d.ts +9 -1
- package/types/RenderPipeline/index.d.ts +4 -1
- package/types/Renderer.d.ts +82 -19
- package/types/Scene.d.ts +34 -7
- package/types/SceneManager.d.ts +18 -6
- package/types/Script.d.ts +41 -0
- package/types/Signal.d.ts +71 -0
- package/types/SystemInfo.d.ts +14 -2
- package/types/Transform.d.ts +26 -1
- package/types/UpdateFlag.d.ts +4 -1
- package/types/UpdateFlagManager.d.ts +41 -1
- package/types/Utils.d.ts +20 -0
- package/types/VirtualCamera.d.ts +16 -1
- package/types/animation/AnimationClip.d.ts +13 -2
- package/types/animation/AnimationClipCurveBinding.d.ts +17 -2
- package/types/animation/AnimationEvent.d.ts +2 -2
- package/types/animation/Animator.d.ts +49 -10
- package/types/animation/AnimatorController.d.ts +20 -2
- package/types/animation/AnimatorControllerLayer.d.ts +17 -2
- package/types/animation/AnimatorControllerParameter.d.ts +4 -0
- package/types/animation/AnimatorState.d.ts +46 -2
- package/types/animation/AnimatorStateInstance.d.ts +46 -0
- package/types/animation/AnimatorStateMachine.d.ts +17 -2
- package/types/animation/AnimatorStateTransition.d.ts +9 -0
- package/types/animation/AnimatorStateTransitionCollection.d.ts +23 -1
- package/types/animation/Keyframe.d.ts +1 -1
- package/types/animation/StateMachineScript.d.ts +2 -0
- package/types/animation/animationCurve/AnimationArrayCurve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationBoolCurve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationColorCurve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationCurve.d.ts +9 -1
- package/types/animation/animationCurve/AnimationFloatArrayCurve.d.ts +38 -0
- package/types/animation/animationCurve/AnimationFloatCurve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationQuaternionCurve.d.ts +41 -0
- package/types/animation/animationCurve/AnimationRectCurve.d.ts +18 -0
- package/types/animation/animationCurve/AnimationRefCurve.d.ts +20 -2
- package/types/animation/animationCurve/AnimationStringCurve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationVector2Curve.d.ts +39 -0
- package/types/animation/animationCurve/AnimationVector3Curve.d.ts +43 -0
- package/types/animation/animationCurve/AnimationVector4Curve.d.ts +39 -0
- package/types/animation/animationCurve/interfaces/IAnimationCurveCalculator.d.ts +18 -1
- package/types/animation/enums/AnimatorStatePlayState.d.ts +8 -1
- package/types/animation/index.d.ts +1 -0
- package/types/animation/internal/AnimationCurveLayerOwner.d.ts +15 -1
- package/types/animation/internal/AnimationEventHandler.d.ts +8 -1
- package/types/animation/internal/AnimatorLayerData.d.ts +28 -1
- package/types/animation/internal/AnimatorStateData.d.ts +14 -1
- package/types/animation/internal/AnimatorStatePlayData.d.ts +27 -1
- package/types/animation/internal/AnimatorTempValue.d.ts +12 -1
- package/types/animation/internal/animationCurveOwner/AnimationCurveOwner.d.ts +39 -0
- package/types/animation/internal/animationCurveOwner/assembler/BlendShapeWeightsAnimationCurveOwnerAssembler.d.ts +12 -1
- package/types/animation/internal/animationCurveOwner/assembler/IAnimationCurveOwnerAssembler.d.ts +10 -1
- package/types/animation/internal/animationCurveOwner/assembler/PositionAnimationCurveOwnerAssembler.d.ts +13 -1
- package/types/animation/internal/animationCurveOwner/assembler/RotationAnimationCurveOwnerAssembler.d.ts +13 -1
- package/types/animation/internal/animationCurveOwner/assembler/ScaleAnimationCurveOwnerAssembler.d.ts +13 -1
- package/types/animation/internal/animationCurveOwner/assembler/UniversalAnimationCurveOwnerAssembler.d.ts +23 -1
- package/types/asset/AssetPromise.d.ts +4 -4
- package/types/asset/AssetType.d.ts +7 -9
- package/types/asset/GraphicsResource.d.ts +10 -0
- package/types/asset/IReferable.d.ts +8 -0
- package/types/asset/JSONAsset.d.ts +1 -1
- package/types/asset/LoadItem.d.ts +1 -1
- package/types/asset/Loader.d.ts +2 -2
- package/types/asset/ReferResource.d.ts +28 -0
- package/types/asset/RenderingStatistics.d.ts +8 -0
- package/types/asset/ResourceManager.d.ts +117 -9
- package/types/audio/AudioClip.d.ts +8 -0
- package/types/audio/AudioManager.d.ts +18 -0
- package/types/audio/AudioSource.d.ts +20 -2
- package/types/base/Constant.d.ts +2 -19
- package/types/base/DataObject.d.ts +6 -0
- package/types/base/EngineObject.d.ts +4 -0
- package/types/base/Time.d.ts +13 -0
- package/types/base/index.d.ts +1 -0
- package/types/clone/CloneDecorators.d.ts +37 -0
- package/types/clone/CloneUtil.d.ts +30 -0
- package/types/clone/ComponentCloner.d.ts +4 -10
- package/types/clone/ICloneHook.d.ts +12 -0
- package/types/enums/CameraType.d.ts +9 -1
- package/types/env-probe/CubeProbe.d.ts +2 -0
- package/types/env-probe/Probe.d.ts +1 -1
- package/types/graphic/Buffer.d.ts +23 -3
- package/types/graphic/BufferUtil.d.ts +8 -0
- package/types/graphic/ElementRangeMapping.d.ts +9 -0
- package/types/graphic/IndexBufferBinding.d.ts +4 -0
- package/types/graphic/Mesh.d.ts +58 -1
- package/types/graphic/Primitive.d.ts +50 -1
- package/types/graphic/TransformFeedback.d.ts +46 -0
- package/types/graphic/TransformFeedbackPrimitive.d.ts +57 -0
- package/types/graphic/TransformFeedbackSimulator.d.ts +55 -0
- package/types/graphic/VertexBufferBinding.d.ts +4 -0
- package/types/graphic/VertexElement.d.ts +1 -0
- package/types/graphic/enums/BufferBindFlag.d.ts +5 -3
- package/types/index.d.ts +7 -4
- package/types/input/InputManager.d.ts +25 -6
- package/types/input/enums/PointerButton.d.ts +8 -0
- package/types/input/keyboard/KeyboardManager.d.ts +41 -1
- package/types/input/pointer/Pointer.d.ts +37 -1
- package/types/input/pointer/PointerEventData.d.ts +4 -0
- package/types/input/pointer/PointerManager.d.ts +58 -0
- package/types/input/pointer/emitter/IHitResult.d.ts +11 -1
- package/types/input/pointer/emitter/PhysicsPointerEventEmitter.d.ts +20 -1
- package/types/input/wheel/WheelManager.d.ts +34 -1
- package/types/lighting/AmbientLight.d.ts +9 -8
- package/types/lighting/DirectLight.d.ts +17 -0
- package/types/lighting/KHR_lights.d.ts +13 -1
- package/types/lighting/Light.d.ts +2 -0
- package/types/lighting/LightManager.d.ts +57 -0
- package/types/lighting/PointLight.d.ts +17 -0
- package/types/lighting/SpotLight.d.ts +17 -0
- package/types/lighting/ambientOcclusion/AmbientOcclusion.d.ts +4 -0
- package/types/lighting/ambientOcclusion/ScalableAmbientObscurancePass.d.ts +37 -1
- package/types/material/BaseMaterial.d.ts +15 -11
- package/types/material/Material.d.ts +6 -9
- package/types/mesh/BlendShape.d.ts +14 -1
- package/types/mesh/BlendShapeFrame.d.ts +11 -4
- package/types/mesh/BlendShapeManager.d.ts +100 -1
- package/types/mesh/BufferMesh.d.ts +2 -2
- package/types/mesh/MeshRenderer.d.ts +42 -0
- package/types/mesh/MeshTangentUtils.d.ts +9 -0
- package/types/mesh/ModelMesh.d.ts +28 -12
- package/types/mesh/PrimitiveMesh.d.ts +266 -104
- package/types/mesh/PrimitiveMeshOptions.d.ts +415 -0
- package/types/mesh/Skin.d.ts +12 -3
- package/types/mesh/SkinnedMeshRenderer.d.ts +27 -1
- package/types/mesh/enums/PrimitiveMeshCapMode.d.ts +21 -0
- package/types/mesh/index.d.ts +2 -0
- package/types/mesh/primitive/MeshPathUtils.d.ts +13 -0
- package/types/mesh/primitive/PolygonUtils.d.ts +44 -0
- package/types/mesh/primitive/PrimitiveMeshBuilder.d.ts +25 -0
- package/types/mesh/primitive/PrimitiveMeshRestorer.d.ts +15 -0
- package/types/mesh/primitive/SubdivisionUtils.d.ts +9 -0
- package/types/particle/ParticleBounds.d.ts +87 -0
- package/types/particle/ParticleBufferUtils.d.ts +33 -1
- package/types/particle/ParticleGenerator.d.ts +142 -24
- package/types/particle/ParticleMaterial.d.ts +3 -1
- package/types/particle/ParticleRenderer.d.ts +62 -6
- package/types/particle/ParticleSubEmitterSpawnState.d.ts +36 -0
- package/types/particle/ParticleSystemManager.d.ts +17 -0
- package/types/particle/ParticleTransformFeedbackSimulator.d.ts +48 -0
- package/types/particle/enums/ParticleInheritVelocityMode.d.ts +14 -0
- package/types/particle/enums/ParticleRandomSubSeeds.d.ts +26 -1
- package/types/particle/enums/ParticleScaleMode.d.ts +5 -5
- package/types/particle/enums/ParticleSubEmitterInheritProperty.d.ts +17 -0
- package/types/particle/enums/ParticleSubEmitterType.d.ts +12 -0
- package/types/particle/enums/attributes/BillboardParticleVertexAttribute.d.ts +6 -1
- package/types/particle/enums/attributes/ParticleFeedbackVertexAttribute.d.ts +10 -0
- package/types/particle/enums/attributes/ParticleInstanceVertexAttribute.d.ts +19 -1
- package/types/particle/index.d.ts +9 -0
- package/types/particle/modules/BirthSubEmitterCommand.d.ts +29 -0
- package/types/particle/modules/BirthSubEmitterState.d.ts +9 -0
- package/types/particle/modules/Burst.d.ts +23 -2
- package/types/particle/modules/ColorOverLifetimeModule.d.ts +19 -0
- package/types/particle/modules/CustomDataModule.d.ts +90 -0
- package/types/particle/modules/DeathSubEmitterCommand.d.ts +19 -0
- package/types/particle/modules/EmissionModule.d.ts +51 -4
- package/types/particle/modules/EmissionState.d.ts +13 -0
- package/types/particle/modules/ForceOverLifetimeModule.d.ts +16 -1
- package/types/particle/modules/InheritVelocityModule.d.ts +86 -0
- package/types/particle/modules/LimitVelocityOverLifetimeModule.d.ts +163 -0
- package/types/particle/modules/MainModule.d.ts +56 -11
- package/types/particle/modules/NoiseModule.d.ts +114 -0
- package/types/particle/modules/ParticleCompositeCurve.d.ts +46 -4
- package/types/particle/modules/ParticleCompositeGradient.d.ts +8 -2
- package/types/particle/modules/ParticleCurve.d.ts +31 -2
- package/types/particle/modules/ParticleGeneratorModule.d.ts +9 -3
- package/types/particle/modules/ParticleGradient.d.ts +22 -5
- package/types/particle/modules/RotationOverLifetimeModule.d.ts +27 -3
- package/types/particle/modules/SizeOverLifetimeModule.d.ts +25 -0
- package/types/particle/modules/SubEmitter.d.ts +32 -0
- package/types/particle/modules/SubEmittersModule.d.ts +111 -0
- package/types/particle/modules/TextureSheetAnimationModule.d.ts +14 -1
- package/types/particle/modules/VelocityOverLifetimeModule.d.ts +124 -3
- package/types/particle/modules/shape/BaseShape.d.ts +65 -2
- package/types/particle/modules/shape/BoxShape.d.ts +13 -2
- package/types/particle/modules/shape/CircleShape.d.ts +13 -1
- package/types/particle/modules/shape/ConeShape.d.ts +13 -4
- package/types/particle/modules/shape/HemisphereShape.d.ts +13 -0
- package/types/particle/modules/shape/MeshShape.d.ts +26 -3
- package/types/particle/modules/shape/ShapeUtils.d.ts +13 -1
- package/types/particle/modules/shape/SphereShape.d.ts +13 -0
- package/types/physics/CharacterController.d.ts +24 -3
- package/types/physics/Collider.d.ts +47 -3
- package/types/physics/Collision.d.ts +3 -0
- package/types/physics/DynamicCollider.d.ts +33 -7
- package/types/physics/HitResult.d.ts +2 -2
- package/types/physics/PhysicsMaterial.d.ts +11 -2
- package/types/physics/PhysicsScene.d.ts +99 -7
- package/types/physics/StaticCollider.d.ts +5 -0
- package/types/physics/enums/HingeJointFlag.d.ts +14 -1
- package/types/physics/joint/HingeJoint.d.ts +4 -0
- package/types/physics/joint/Joint.d.ts +22 -2
- package/types/physics/joint/JointLimits.d.ts +2 -1
- package/types/physics/joint/JointMotor.d.ts +2 -1
- package/types/physics/shape/ColliderShape.d.ts +44 -7
- package/types/physics/shape/MeshColliderShape.d.ts +13 -12
- package/types/postProcess/FinalPass.d.ts +20 -1
- package/types/postProcess/PostProcess.d.ts +11 -6
- package/types/postProcess/PostProcessEffect.d.ts +6 -1
- package/types/postProcess/PostProcessEffectParameter.d.ts +23 -3
- package/types/postProcess/PostProcessManager.d.ts +43 -0
- package/types/postProcess/PostProcessPass.d.ts +3 -2
- package/types/postProcess/PostProcessUberPass.d.ts +2 -1
- package/types/postProcess/effects/BloomEffect.d.ts +26 -1
- package/types/postProcess/effects/TonemappingEffect.d.ts +3 -0
- package/types/renderingHardwareInterface/IHardwareRenderer.d.ts +74 -0
- package/types/renderingHardwareInterface/IPlatformBuffer.d.ts +1 -0
- package/types/renderingHardwareInterface/IPlatformPrimitive.d.ts +6 -0
- package/types/renderingHardwareInterface/IPlatformShaderProgram.d.ts +4 -0
- package/types/renderingHardwareInterface/IPlatformTexture2D.d.ts +0 -1
- package/types/renderingHardwareInterface/IPlatformTextureCube.d.ts +0 -1
- package/types/renderingHardwareInterface/IPlatformTransformFeedback.d.ts +36 -0
- package/types/renderingHardwareInterface/IPlatformTransformFeedbackPrimitive.d.ts +39 -0
- package/types/renderingHardwareInterface/index.d.ts +5 -0
- package/types/shader/BuiltinShaders.d.ts +27 -0
- package/types/shader/Shader.d.ts +52 -25
- package/types/shader/ShaderBlockProperty.d.ts +19 -0
- package/types/shader/ShaderData.d.ts +43 -4
- package/types/shader/ShaderFactory.d.ts +77 -0
- package/types/shader/ShaderMacro.d.ts +17 -2
- package/types/shader/ShaderMacroCollection.d.ts +57 -1
- package/types/shader/ShaderMacroProcessor.d.ts +54 -0
- package/types/shader/ShaderPass.d.ts +42 -13
- package/types/shader/ShaderProgram.d.ts +92 -1
- package/types/shader/ShaderProgramMap.d.ts +20 -0
- package/types/shader/ShaderProperty.d.ts +17 -0
- package/types/shader/ShaderTagKey.d.ts +2 -0
- package/types/shader/ShaderUniform.d.ts +49 -1
- package/types/shader/ShaderUniformBlock.d.ts +9 -1
- package/types/shader/enums/ConstantBufferBindingPoint.d.ts +7 -0
- package/types/shader/enums/ShaderLanguage.d.ts +1 -3
- package/types/shader/enums/ShaderPreprocessorDirective.d.ts +22 -0
- package/types/shader/index.d.ts +3 -1
- package/types/shader/state/BlendState.d.ts +16 -1
- package/types/shader/state/DepthState.d.ts +16 -1
- package/types/shader/state/RasterState.d.ts +19 -1
- package/types/shader/state/RenderState.d.ts +13 -2
- package/types/shader/state/RenderTargetBlendState.d.ts +2 -1
- package/types/shader/state/StencilState.d.ts +15 -1
- package/types/shadow/CascadedShadowCasterPass.d.ts +5 -3
- package/types/shadow/ShadowSliceData.d.ts +13 -1
- package/types/shadow/ShadowUtils.d.ts +41 -1
- package/types/sky/Sky.d.ts +13 -4
- package/types/sky/SkyBoxMaterial.d.ts +0 -7
- package/types/texture/RenderTarget.d.ts +28 -3
- package/types/texture/Texture.d.ts +46 -12
- package/types/texture/Texture2D.d.ts +4 -1
- package/types/texture/Texture2DArray.d.ts +4 -1
- package/types/texture/TextureCube.d.ts +4 -1
- package/types/texture/TextureUtils.d.ts +15 -1
- package/types/texture/enums/TextureFormat.d.ts +1 -9
- package/types/trail/TrailRenderer.d.ts +13 -8
- package/types/ui/IUICanvas.d.ts +16 -1
- package/types/utils/DisorderedArray.d.ts +3 -1
- package/types/xr/XRManager.d.ts +28 -0
- package/types/RenderPipeline/BatchUtils.d.ts +0 -1
- package/types/RenderPipeline/SubRenderElement.d.ts +0 -22
- package/types/clone/CloneManager.d.ts +0 -31
- package/types/clone/enums/CloneMode.d.ts +0 -13
- package/types/mesh/PrimitiveMeshRestorer.d.ts +0 -1
- package/types/physics/enums/ColliderShapeChangeFlag.d.ts +0 -1
- package/types/shader/ShaderPool.d.ts +0 -1
- package/types/shader/ShaderProgramPool.d.ts +0 -1
- package/types/shader/state/index.d.ts +0 -6
- package/types/shaderlib/ShaderFactory.d.ts +0 -20
- package/types/shaderlib/ShaderLib.d.ts +0 -73
- package/types/shaderlib/index.d.ts +0 -1
- package/types/shaderlib/particle/index.d.ts +0 -15
- package/types/shaderlib/pbr/index.d.ts +0 -11
- package/types/shaderlib/shadow/index.d.ts +0 -8
package/types/shader/Shader.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { IShaderCompiler, IPrecompiledShader } from "@galacean/engine-design";
|
|
1
2
|
import { Engine } from "../Engine";
|
|
2
3
|
import { IReferable } from "../asset/IReferable";
|
|
3
4
|
import { ShaderMacro } from "./ShaderMacro";
|
|
5
|
+
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
|
4
6
|
import { ShaderPass } from "./ShaderPass";
|
|
5
7
|
import { ShaderProperty } from "./ShaderProperty";
|
|
6
8
|
import { SubShader } from "./SubShader";
|
|
@@ -10,57 +12,74 @@ import { ShaderLanguage } from "./enums/ShaderLanguage";
|
|
|
10
12
|
*/
|
|
11
13
|
export declare class Shader implements IReferable {
|
|
12
14
|
readonly name: string;
|
|
15
|
+
/** @internal */
|
|
16
|
+
static readonly _compileMacros: ShaderMacroCollection;
|
|
17
|
+
/** @internal */
|
|
18
|
+
static _shaderCompiler?: IShaderCompiler;
|
|
13
19
|
private static _shaderMap;
|
|
14
20
|
/**
|
|
15
21
|
* Create a shader by source code.
|
|
16
22
|
*
|
|
17
23
|
* @remarks
|
|
18
24
|
*
|
|
19
|
-
*
|
|
25
|
+
* The shader compiler must be enabled first as follows:
|
|
20
26
|
* ```ts
|
|
21
|
-
* // Import
|
|
22
|
-
* import {
|
|
23
|
-
* // Create engine with
|
|
24
|
-
* const engine = await WebGLEngine.create({ canvas: "canvas",
|
|
27
|
+
* // Import the shader compiler
|
|
28
|
+
* import { ShaderCompiler } from "@galacean/engine-shader-compiler";
|
|
29
|
+
* // Create engine with the shader compiler
|
|
30
|
+
* const engine = await WebGLEngine.create({ canvas: "canvas", shaderCompiler: new ShaderCompiler() });
|
|
25
31
|
* ...
|
|
26
32
|
* ```
|
|
27
33
|
*
|
|
28
34
|
* @param shaderSource - Shader code
|
|
29
35
|
* @param platformTarget - Shader platform target, @defaultValue ShaderLanguage.GLSLES300
|
|
30
|
-
* @
|
|
31
|
-
* @returns Shader
|
|
36
|
+
* @returns A new shader. Shaders with the same name remain independent objects.
|
|
32
37
|
*
|
|
33
38
|
* @throws
|
|
34
|
-
* Throw string exception if
|
|
39
|
+
* Throw string exception if the shader compiler has not been enabled properly.
|
|
35
40
|
*/
|
|
36
|
-
static create(shaderSource: string, platformTarget?: ShaderLanguage
|
|
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;
|
|
41
|
+
static create(shaderSource: string, platformTarget?: ShaderLanguage): Shader;
|
|
45
42
|
/**
|
|
46
43
|
* Create a shader.
|
|
47
44
|
* @param name - Name of the shader
|
|
48
45
|
* @param shaderPasses - Shader passes
|
|
49
|
-
* @returns
|
|
46
|
+
* @returns A new shader. Shaders with the same name remain independent objects.
|
|
50
47
|
*/
|
|
51
48
|
static create(name: string, shaderPasses: ShaderPass[]): Shader;
|
|
52
49
|
/**
|
|
53
50
|
* Create a shader.
|
|
54
51
|
* @param name - Name of the shader
|
|
55
52
|
* @param subShaders - Sub shaders
|
|
56
|
-
* @returns
|
|
53
|
+
* @returns A new shader. Shaders with the same name remain independent objects.
|
|
57
54
|
*/
|
|
58
55
|
static create(name: string, subShaders: SubShader[]): Shader;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a shader while retaining loader-owned source location metadata for relative includes.
|
|
58
|
+
* @param shaderSource - Complete ShaderLab source.
|
|
59
|
+
* @param platformTarget - Shader backend target.
|
|
60
|
+
* @param sourceFile - Canonical source location supplied by an asset loader or authoring tool.
|
|
61
|
+
* @returns A new shader.
|
|
62
|
+
* @throws When the shader compiler is unavailable or a pass cannot be compiled.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
static _createFromSource(shaderSource: string, platformTarget?: ShaderLanguage, sourceFile?: string): Shader;
|
|
59
66
|
/**
|
|
60
67
|
* Find a shader by name.
|
|
61
68
|
* @param name - Name of the shader
|
|
69
|
+
* @returns The most recently registered live shader with this name, or `undefined` if none exists.
|
|
70
|
+
* @remarks Retain the shader object when a material must use a specific shader among namesakes.
|
|
71
|
+
*/
|
|
72
|
+
static find(name: string): Shader | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
static _createFromPrecompiled(data: IPrecompiledShader): Shader;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
62
79
|
*/
|
|
63
|
-
static
|
|
80
|
+
static _clear(engine: Engine): void;
|
|
81
|
+
private static _resolveUsePass;
|
|
82
|
+
private static _applyRenderStates;
|
|
64
83
|
private static _applyConstRenderStates;
|
|
65
84
|
private _refCount;
|
|
66
85
|
private _destroyed;
|
|
@@ -78,19 +97,27 @@ export declare class Shader implements IReferable {
|
|
|
78
97
|
* Compile shader variant by macro name list.
|
|
79
98
|
*
|
|
80
99
|
* @remarks
|
|
81
|
-
*
|
|
100
|
+
* Skips Transform Feedback passes, which require a runtime-provided output layout.
|
|
82
101
|
*
|
|
83
102
|
* @param engine - Engine to which the shader variant belongs
|
|
84
103
|
* @param macros - Macro name list
|
|
85
|
-
* @returns
|
|
104
|
+
* @returns Whether the variant is valid; false if all passes are skipped.
|
|
86
105
|
*/
|
|
87
106
|
compileVariant(engine: Engine, macros: string[]): boolean;
|
|
88
107
|
/**
|
|
89
|
-
* Destroy
|
|
90
|
-
* @param force - Whether to
|
|
91
|
-
* @returns Whether the
|
|
108
|
+
* Destroy this shader and remove it from name lookup.
|
|
109
|
+
* @param force - Whether to destroy the shader even while it is in use
|
|
110
|
+
* @returns Whether the shader was destroyed or had already been destroyed.
|
|
92
111
|
*/
|
|
93
112
|
destroy(force?: boolean): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
_getReferCount(): number;
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
_addReferCount(value: number): void;
|
|
94
121
|
/**
|
|
95
122
|
* @deprecated Please use `ShaderMacro.getByName` instead
|
|
96
123
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Shader block property, used to identify uniform blocks by id.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ShaderBlockProperty {
|
|
6
|
+
private static _counter;
|
|
7
|
+
private static _nameMap;
|
|
8
|
+
/**
|
|
9
|
+
* Get shader block property by name.
|
|
10
|
+
* @param name - Name of the uniform block
|
|
11
|
+
* @returns Shader block property
|
|
12
|
+
*/
|
|
13
|
+
static getByName(name: string): ShaderBlockProperty;
|
|
14
|
+
/** Uniform block name. */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** @internal */
|
|
17
|
+
readonly _uniqueId: number;
|
|
18
|
+
private constructor();
|
|
19
|
+
}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
|
+
import { DataObject } from "../base/DataObject";
|
|
1
2
|
import { IClone } from "@galacean/engine-design";
|
|
2
3
|
import { Color, Matrix, Vector2, Vector3, Vector4 } from "@galacean/engine-math";
|
|
3
4
|
import { IReferable } from "../asset/IReferable";
|
|
5
|
+
import type { ICloneHook } from "../clone/ICloneHook";
|
|
4
6
|
import { Texture } from "../texture/Texture";
|
|
5
7
|
import { ShaderMacro } from "./ShaderMacro";
|
|
8
|
+
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
|
6
9
|
import { ShaderProperty } from "./ShaderProperty";
|
|
10
|
+
import { ShaderDataGroup } from "./enums/ShaderDataGroup";
|
|
11
|
+
import { ShaderPropertyType } from "./enums/ShaderPropertyType";
|
|
7
12
|
/**
|
|
8
13
|
* Shader data collection,Correspondence includes shader properties data and macros data.
|
|
9
14
|
*/
|
|
10
|
-
export declare class ShaderData implements IReferable, IClone {
|
|
15
|
+
export declare class ShaderData extends DataObject implements IReferable, IClone, ICloneHook<ShaderData> {
|
|
16
|
+
/** @internal */
|
|
17
|
+
_group: ShaderDataGroup;
|
|
18
|
+
/** @internal */
|
|
19
|
+
_propertyValueMap: Record<number, ShaderPropertyValueType>;
|
|
20
|
+
/** @internal */
|
|
21
|
+
_macroCollection: ShaderMacroCollection;
|
|
22
|
+
private _batchSharedFields;
|
|
11
23
|
private _macroMap;
|
|
12
24
|
private _refCount;
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
constructor(group: ShaderDataGroup);
|
|
13
29
|
/**
|
|
14
30
|
* Get float by shader property name.
|
|
15
31
|
* @param propertyName - Shader property name
|
|
@@ -261,13 +277,13 @@ export declare class ShaderData implements IReferable, IClone {
|
|
|
261
277
|
* @param propertyName - Shader property name
|
|
262
278
|
* @param value - Texture
|
|
263
279
|
*/
|
|
264
|
-
setTexture(propertyName: string, value: Texture): void;
|
|
280
|
+
setTexture(propertyName: string, value: Texture | null): void;
|
|
265
281
|
/**
|
|
266
282
|
* Set texture by shader property.
|
|
267
283
|
* @param property - Shader property, use `ShaderProperty.getByName` to get
|
|
268
284
|
* @param value - Texture
|
|
269
285
|
*/
|
|
270
|
-
setTexture(property: ShaderProperty, value: Texture): void;
|
|
286
|
+
setTexture(property: ShaderProperty, value: Texture | null): void;
|
|
271
287
|
/**
|
|
272
288
|
* Get texture array by shader property name.
|
|
273
289
|
* @param propertyName - Shader property name
|
|
@@ -346,5 +362,28 @@ export declare class ShaderData implements IReferable, IClone {
|
|
|
346
362
|
getProperties(out: ShaderProperty[]): void;
|
|
347
363
|
clone(): ShaderData;
|
|
348
364
|
cloneTo(target: ShaderData): void;
|
|
365
|
+
/**
|
|
366
|
+
* @internal
|
|
367
|
+
* @inheritdoc
|
|
368
|
+
*/
|
|
369
|
+
_onClone(target: ShaderData): void;
|
|
370
|
+
/**
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
_setPropertyValue<T extends ShaderPropertyValueType>(property: string | ShaderProperty, type: ShaderPropertyType, value: T): void;
|
|
374
|
+
/**
|
|
375
|
+
* @internal
|
|
376
|
+
*/
|
|
377
|
+
_matchesRendererBatchShared(other: ShaderData): boolean;
|
|
378
|
+
/**
|
|
379
|
+
* @internal
|
|
380
|
+
*/
|
|
381
|
+
_getReferCount(): number;
|
|
382
|
+
/**
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
_addReferCount(value: number): void;
|
|
386
|
+
private _addTexturesReferCount;
|
|
387
|
+
private _updateRendererBatchSharedFields;
|
|
349
388
|
}
|
|
350
|
-
export type ShaderPropertyValueType = number | Vector2 | Vector3 | Vector4 | Color | Matrix | Texture | Texture[] | Int32Array | Float32Array;
|
|
389
|
+
export type ShaderPropertyValueType = null | number | Vector2 | Vector3 | Vector4 | Color | Matrix | Texture | Texture[] | Int32Array | Float32Array;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Engine } from "../Engine";
|
|
2
|
+
import { ShaderProperty } from "./ShaderProperty";
|
|
3
|
+
/**
|
|
4
|
+
* Shader registry and GLSL utilities. Holds the `#include` lookup table
|
|
5
|
+
* the runtime preprocessor reads and the GPU-instancing UBO injector that
|
|
6
|
+
* `ShaderPass` runs over compiled GLSL source.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ShaderFactory {
|
|
9
|
+
static readonly RENDERER_INSTANCE_BLOCK_NAME = "RendererInstanceData";
|
|
10
|
+
static readonly uniformBlockBindingMap: Record<number, number>;
|
|
11
|
+
static readonly includeMap: Record<string, string>;
|
|
12
|
+
private static readonly _std140TypeInfoMap;
|
|
13
|
+
private static readonly _derivedDefines;
|
|
14
|
+
private static readonly _builtinRendererUniforms;
|
|
15
|
+
private static readonly _cameraMatrixCandidates;
|
|
16
|
+
private static readonly _uboUniformRegex;
|
|
17
|
+
private static _packFuncMap;
|
|
18
|
+
/**
|
|
19
|
+
* Register a chunk source so `#include` resolves it.
|
|
20
|
+
* @param includeName - The path key referenced in `#include "..."`.
|
|
21
|
+
* @param includeSource - GLSL chunk source text.
|
|
22
|
+
* @throws Error when the key is empty, malformed, or already registered after normalization.
|
|
23
|
+
*/
|
|
24
|
+
static registerInclude(includeName: string, includeSource: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Remove a registered shader chunk.
|
|
27
|
+
* @param includeName - The path key passed to `registerInclude`.
|
|
28
|
+
* @throws Error when the key is empty or malformed.
|
|
29
|
+
*/
|
|
30
|
+
static unregisterInclude(includeName: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Remove a registered shader chunk.
|
|
33
|
+
* @param includeName - The path key passed to `registerInclude`.
|
|
34
|
+
* @deprecated Use `unregisterInclude`.
|
|
35
|
+
* @throws Error when the key is empty or malformed.
|
|
36
|
+
*/
|
|
37
|
+
static unRegisterInclude(includeName: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Scan VS/FS for renderer-group `uniform` declarations, replace them with a shared
|
|
40
|
+
* std140 UBO (instanced array), and emit `#define` remapping so original uniform
|
|
41
|
+
* names resolve to `rendererData[instanceID].field`.
|
|
42
|
+
*
|
|
43
|
+
* Inputs are expected to be already preprocessor-evaluated (no `#ifdef` left).
|
|
44
|
+
*/
|
|
45
|
+
static injectInstanceUBO(engine: Engine, vertexSource: string, fragmentSource: string): {
|
|
46
|
+
vertexSource: string;
|
|
47
|
+
fragmentSource: string;
|
|
48
|
+
instanceLayout: InstanceBufferLayout | null;
|
|
49
|
+
};
|
|
50
|
+
private static _scanInstanceUniforms;
|
|
51
|
+
private static _buildLayout;
|
|
52
|
+
private static _buildMissingCameraDecls;
|
|
53
|
+
private static _buildUBODeclaration;
|
|
54
|
+
private static _buildFieldDefines;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export interface InstanceFieldInfo {
|
|
60
|
+
property: ShaderProperty;
|
|
61
|
+
type: string;
|
|
62
|
+
offset: number;
|
|
63
|
+
/** offset / 4, precomputed to avoid repeated division in upload loop */
|
|
64
|
+
offsetInElements: number;
|
|
65
|
+
useIntView: boolean;
|
|
66
|
+
pack: InstancePackFunc;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export interface InstanceBufferLayout {
|
|
72
|
+
instanceFields: InstanceFieldInfo[];
|
|
73
|
+
instanceMaxCount: number;
|
|
74
|
+
structSize: number;
|
|
75
|
+
}
|
|
76
|
+
type InstancePackFunc = (view: Float32Array | Int32Array, offset: number, value: any) => void;
|
|
77
|
+
export {};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
|
1
2
|
/**
|
|
2
3
|
* Shader macro。
|
|
3
4
|
*/
|
|
4
5
|
export declare class ShaderMacro {
|
|
6
|
+
/** @internal */
|
|
7
|
+
static _macroMaskMap: ShaderMacro[][];
|
|
8
|
+
/** @internal */
|
|
9
|
+
static _macroNameIdMap: Record<string, number>;
|
|
5
10
|
private static _macroNameCounter;
|
|
6
11
|
private static _macroCounter;
|
|
7
12
|
private static _macroMap;
|
|
@@ -17,10 +22,20 @@ export declare class ShaderMacro {
|
|
|
17
22
|
* @param value - Value of the shader macro
|
|
18
23
|
* @returns Shader macro
|
|
19
24
|
*/
|
|
20
|
-
static getByName(name: string, value: string): ShaderMacro;
|
|
25
|
+
static getByName(name: string, value: string | undefined): ShaderMacro;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
static _getMacrosElements(macros: ShaderMacroCollection, out: ShaderMacro[]): void;
|
|
21
30
|
/** Name. */
|
|
22
31
|
readonly name: string;
|
|
23
32
|
/** Value. */
|
|
24
|
-
readonly value: string;
|
|
33
|
+
readonly value: string | undefined;
|
|
34
|
+
/** @internal */
|
|
35
|
+
_nameId: number;
|
|
36
|
+
/** @internal */
|
|
37
|
+
_maskIndex: number;
|
|
38
|
+
/** @internal */
|
|
39
|
+
_maskValue: number;
|
|
25
40
|
private constructor();
|
|
26
41
|
}
|
|
@@ -1 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import { ShaderMacro } from "./ShaderMacro";
|
|
2
|
+
/**
|
|
3
|
+
* Shader macro collection.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class ShaderMacroCollection {
|
|
7
|
+
/**
|
|
8
|
+
* Union of two macro collection.
|
|
9
|
+
* @param left - input macro collection
|
|
10
|
+
* @param right - input macro collection
|
|
11
|
+
* @param out - union output macro collection
|
|
12
|
+
*/
|
|
13
|
+
static unionCollection(left: ShaderMacroCollection, right: ShaderMacroCollection, out: ShaderMacroCollection): void;
|
|
14
|
+
/** @internal */
|
|
15
|
+
_mask: number[];
|
|
16
|
+
/** @internal */
|
|
17
|
+
_length: number;
|
|
18
|
+
/**
|
|
19
|
+
* Enable one macro in this macro collection.
|
|
20
|
+
* @param macro - ShaderMacro
|
|
21
|
+
*/
|
|
22
|
+
enable(macro: ShaderMacro): void;
|
|
23
|
+
/**
|
|
24
|
+
* Disable one macro in this macro collection.
|
|
25
|
+
* @param macro - ShaderMacro
|
|
26
|
+
*/
|
|
27
|
+
disable(macro: ShaderMacro): void;
|
|
28
|
+
/**
|
|
29
|
+
* Union of this and other macro collection.
|
|
30
|
+
* @param macroCollection - macro collection
|
|
31
|
+
*/
|
|
32
|
+
unionCollection(macroCollection: ShaderMacroCollection): void;
|
|
33
|
+
/**
|
|
34
|
+
* Complementarity of this and other macro collection.
|
|
35
|
+
* @param macroCollection - macro collection
|
|
36
|
+
*/
|
|
37
|
+
complementaryCollection(macroCollection: ShaderMacroCollection): void;
|
|
38
|
+
/**
|
|
39
|
+
* Intersection of this and other macro collection.
|
|
40
|
+
* @param macroCollection - macro collection
|
|
41
|
+
*/
|
|
42
|
+
intersectionCollection(macroCollection: ShaderMacroCollection): void;
|
|
43
|
+
/**
|
|
44
|
+
* Whether macro is enabled in this macro collection.
|
|
45
|
+
* @param macro - ShaderMacro
|
|
46
|
+
*/
|
|
47
|
+
isEnable(macro: ShaderMacro): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether this macro collection is equal to another.
|
|
50
|
+
* @param other - macro collection to compare
|
|
51
|
+
*/
|
|
52
|
+
isEqual(other: ShaderMacroCollection): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Clear this macro collection.
|
|
55
|
+
*/
|
|
56
|
+
clear(): void;
|
|
57
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ShaderInstruction } from "@galacean/engine-design";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare class ShaderMacroProcessor {
|
|
6
|
+
private static _valueMacros;
|
|
7
|
+
private static _funcMacros;
|
|
8
|
+
private static _shaderChunks;
|
|
9
|
+
private static readonly _declarationGroups;
|
|
10
|
+
private static readonly _activeDeclarations;
|
|
11
|
+
private static readonly _ownedChunks;
|
|
12
|
+
private static readonly _references;
|
|
13
|
+
private static readonly _reachableDeclarations;
|
|
14
|
+
private static readonly _pendingDeclarations;
|
|
15
|
+
private static _out;
|
|
16
|
+
private static _macroFirstChars;
|
|
17
|
+
private static _macroFirstCharsDirty;
|
|
18
|
+
private static readonly _expressionContext;
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate a flat instruction array with active macros.
|
|
21
|
+
* Macros are expanded immediately when text chunks are collected,
|
|
22
|
+
* using the current macro state at that point (conforming to GLSL/C99 §6.10 standard).
|
|
23
|
+
* Declaration ownership filters buffered text after execution; it never skips macro directives.
|
|
24
|
+
* @param instructions - Pre-parsed instruction array
|
|
25
|
+
* @param macros - Active runtime macros
|
|
26
|
+
* @returns Pure GLSL string with all conditionals resolved and macros expanded
|
|
27
|
+
*/
|
|
28
|
+
static evaluate(instructions: ShaderInstruction[], macros: Map<string, string>): string;
|
|
29
|
+
/**
|
|
30
|
+
* Expand macros in a single text chunk using the current macro state.
|
|
31
|
+
* Returns the chunk as-is if no expandable macros exist.
|
|
32
|
+
*/
|
|
33
|
+
private static _expandChunk;
|
|
34
|
+
/**
|
|
35
|
+
* Evaluate a compound condition tree.
|
|
36
|
+
*/
|
|
37
|
+
private static _evalCondition;
|
|
38
|
+
private static _evalDeferredCondition;
|
|
39
|
+
private static _compareValues;
|
|
40
|
+
/**
|
|
41
|
+
* Concatenate shader chunks with consecutive blank lines collapsed to a single newline.
|
|
42
|
+
*/
|
|
43
|
+
private static _concatChunks;
|
|
44
|
+
/**
|
|
45
|
+
* Check if char code is a valid identifier start.
|
|
46
|
+
* Matches: [A-Z] | [a-z] | _
|
|
47
|
+
*/
|
|
48
|
+
private static _isIdentifierStart;
|
|
49
|
+
/**
|
|
50
|
+
* Check if char code is a valid identifier part.
|
|
51
|
+
* Matches: [A-Z] | [a-z] | [0-9] | _
|
|
52
|
+
*/
|
|
53
|
+
private static _isIdentifierPart;
|
|
54
|
+
}
|
|
@@ -1,25 +1,54 @@
|
|
|
1
|
+
import type { ShaderInstruction } from "@galacean/engine-design";
|
|
2
|
+
import { Engine } from "../Engine";
|
|
3
|
+
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
|
1
4
|
import { ShaderPart } from "./ShaderPart";
|
|
5
|
+
import { ShaderProgramMap } from "./ShaderProgramMap";
|
|
6
|
+
import { ShaderProgram } from "./ShaderProgram";
|
|
7
|
+
import { ShaderProperty } from "./ShaderProperty";
|
|
8
|
+
import { ShaderLanguage } from "./enums/ShaderLanguage";
|
|
9
|
+
import { RenderState } from "./state/RenderState";
|
|
2
10
|
/**
|
|
3
11
|
* Shader pass containing vertex and fragment source.
|
|
4
12
|
*/
|
|
5
13
|
export declare class ShaderPass extends ShaderPart {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private
|
|
14
|
+
/** @internal */
|
|
15
|
+
static _shaderPassCounter: number;
|
|
16
|
+
private static _shaderMacroList;
|
|
17
|
+
private static _macroMap;
|
|
18
|
+
/** @internal - Flat instruction array for vertex shader. */
|
|
19
|
+
_vertexShaderInstructions: ShaderInstruction[];
|
|
20
|
+
/** @internal */
|
|
21
|
+
_fragmentShaderInstructions: ShaderInstruction[];
|
|
22
|
+
/** @internal */
|
|
23
|
+
_shaderPassId: number;
|
|
24
|
+
/** @internal Pass-level render state — always present, populated from ShaderLab declarations. */
|
|
25
|
+
_renderState: RenderState;
|
|
26
|
+
/** @internal */
|
|
27
|
+
_renderStateDataMap: Record<number, ShaderProperty>;
|
|
28
|
+
/** @internal */
|
|
29
|
+
_shaderProgramMaps: ShaderProgramMap[];
|
|
30
|
+
private readonly _vertexOutputNames?;
|
|
9
31
|
/**
|
|
10
|
-
* Create a shader pass.
|
|
32
|
+
* Create a shader pass from precompiled instructions.
|
|
11
33
|
* @param name - Shader pass name
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
34
|
+
* @param vertexShaderInstructions - Precompiled vertex instruction array
|
|
35
|
+
* @param fragmentShaderInstructions - Precompiled fragment instruction array
|
|
36
|
+
* @param _platformTarget - Target shader language
|
|
14
37
|
* @param tags - Tags
|
|
38
|
+
* @param vertexOutputNames - Source output names mapped to generated GLSL names
|
|
15
39
|
*/
|
|
16
|
-
constructor(name: string,
|
|
40
|
+
constructor(name: string, vertexShaderInstructions: ShaderInstruction[], fragmentShaderInstructions: ShaderInstruction[], _platformTarget: ShaderLanguage, tags?: Record<string, number | string | boolean>, vertexOutputNames?: Readonly<Record<string, string>>);
|
|
17
41
|
/**
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
_getShaderProgram(engine: Engine, macroCollection: ShaderMacroCollection, feedbackVaryings?: string[]): ShaderProgram;
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
_destroy(): void;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
22
51
|
*/
|
|
23
|
-
|
|
24
|
-
private
|
|
52
|
+
_compileShaderProgram(engine: Engine, macroCollection: ShaderMacroCollection, feedbackVaryings?: string[]): ShaderProgram;
|
|
53
|
+
private _compileShaderSource;
|
|
25
54
|
}
|
|
@@ -1 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IPlatformShaderProgram } from "../renderingHardwareInterface";
|
|
2
|
+
import { Engine } from "../Engine";
|
|
3
|
+
import { ShaderData } from "./ShaderData";
|
|
4
|
+
import { ShaderUniformBlock } from "./ShaderUniformBlock";
|
|
5
|
+
import { InstanceBufferLayout } from "./ShaderFactory";
|
|
6
|
+
/**
|
|
7
|
+
* Shader program, corresponding to the GPU shader program.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ShaderProgram implements IPlatformShaderProgram {
|
|
11
|
+
private static _counter;
|
|
12
|
+
private static _addLineNum;
|
|
13
|
+
id: number;
|
|
14
|
+
readonly sceneUniformBlock: ShaderUniformBlock;
|
|
15
|
+
readonly cameraUniformBlock: ShaderUniformBlock;
|
|
16
|
+
readonly rendererUniformBlock: ShaderUniformBlock;
|
|
17
|
+
readonly materialUniformBlock: ShaderUniformBlock;
|
|
18
|
+
readonly renderElementUniformBlock: ShaderUniformBlock;
|
|
19
|
+
readonly otherUniformBlock: ShaderUniformBlock;
|
|
20
|
+
/** @internal */
|
|
21
|
+
_uploadRenderCount: number;
|
|
22
|
+
/** @internal */
|
|
23
|
+
_uploadSceneId: number;
|
|
24
|
+
/** @internal */
|
|
25
|
+
_uploadCameraId: number;
|
|
26
|
+
/** @internal */
|
|
27
|
+
_uploadRendererId: number;
|
|
28
|
+
/** @internal */
|
|
29
|
+
_uploadMaterialId: number;
|
|
30
|
+
/** @internal */
|
|
31
|
+
_instanceLayout: InstanceBufferLayout | null;
|
|
32
|
+
attributeLocation: Record<string, GLint>;
|
|
33
|
+
uniformBlockIds: number[];
|
|
34
|
+
private _isValid;
|
|
35
|
+
private _engine;
|
|
36
|
+
private _gl;
|
|
37
|
+
private _glProgram;
|
|
38
|
+
private _activeTextureUint;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this shader program is valid.
|
|
41
|
+
*/
|
|
42
|
+
get isValid(): boolean;
|
|
43
|
+
constructor(engine: Engine, vertexSource: string, fragmentSource: string, transformFeedbackVaryings?: string[]);
|
|
44
|
+
/**
|
|
45
|
+
* Upload all shader data in shader uniform block.
|
|
46
|
+
* @param uniformBlock - shader Uniform block
|
|
47
|
+
* @param shaderData - shader data
|
|
48
|
+
*/
|
|
49
|
+
uploadAll(uniformBlock: ShaderUniformBlock, shaderData: ShaderData): void;
|
|
50
|
+
/**
|
|
51
|
+
* Upload constant shader data in shader uniform block.
|
|
52
|
+
* @param uniformBlock - shader Uniform block
|
|
53
|
+
* @param shaderData - shader data
|
|
54
|
+
*/
|
|
55
|
+
uploadUniforms(uniformBlock: ShaderUniformBlock, shaderData: ShaderData): void;
|
|
56
|
+
/**
|
|
57
|
+
* Upload texture shader data in shader uniform block.
|
|
58
|
+
* @param uniformBlock - shader Uniform block
|
|
59
|
+
* @param shaderData - shader data
|
|
60
|
+
*/
|
|
61
|
+
uploadTextures(uniformBlock: ShaderUniformBlock, shaderData: ShaderData): void;
|
|
62
|
+
/**
|
|
63
|
+
* Upload ungroup texture shader data in shader uniform block.
|
|
64
|
+
*/
|
|
65
|
+
uploadUnGroupTextures(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Grouping other data.
|
|
68
|
+
*/
|
|
69
|
+
groupingOtherUniformBlock(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Bind this shader program.
|
|
72
|
+
* @returns Whether the shader program is switched.
|
|
73
|
+
*/
|
|
74
|
+
bind(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Destroy this shader program.
|
|
77
|
+
*/
|
|
78
|
+
destroy(): void;
|
|
79
|
+
private _groupingSubOtherUniforms;
|
|
80
|
+
private _groupingUniform;
|
|
81
|
+
/**
|
|
82
|
+
* Init and link program with shader.
|
|
83
|
+
*/
|
|
84
|
+
private _createProgram;
|
|
85
|
+
private _createShader;
|
|
86
|
+
/**
|
|
87
|
+
* record the location of uniform/attribute.
|
|
88
|
+
*/
|
|
89
|
+
private _recordLocation;
|
|
90
|
+
private _getUniformInfos;
|
|
91
|
+
private _getAttributeInfos;
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Engine } from "../Engine";
|
|
2
|
+
import { ShaderMacroCollection } from "./ShaderMacroCollection";
|
|
3
|
+
import { ShaderProgram } from "./ShaderProgram";
|
|
4
|
+
/**
|
|
5
|
+
* Map keyed by ShaderMacroCollection bitmask, caching ShaderProgram instances.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class ShaderProgramMap {
|
|
9
|
+
engine: Engine;
|
|
10
|
+
private _cacheHierarchyDepth;
|
|
11
|
+
private _cacheMap;
|
|
12
|
+
private _lastQueryMap;
|
|
13
|
+
private _lastQueryKey;
|
|
14
|
+
constructor(engine: Engine);
|
|
15
|
+
get(macros: ShaderMacroCollection): ShaderProgram | null;
|
|
16
|
+
cache(value: ShaderProgram): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
private _recursiveForEach;
|
|
19
|
+
private _resizeCacheMapHierarchy;
|
|
20
|
+
}
|