rhodonite 0.20.2 → 0.22.0
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/README.md +10 -2
- package/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +109 -4
- package/dist/esm/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
- package/dist/esm/foundation/core/Component.d.ts +1 -8
- package/dist/esm/foundation/core/Config.d.ts +165 -6
- package/dist/esm/foundation/core/GlobalDataRepository.d.ts +12 -8
- package/dist/esm/foundation/core/MemoryManager.d.ts +12 -0
- package/dist/esm/foundation/definitions/ProcessApproach.d.ts +1 -6
- package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +0 -1
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esm/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
- package/dist/esm/foundation/materials/core/Material.d.ts +10 -14
- package/dist/esm/foundation/materials/core/MaterialRepository.d.ts +5 -0
- package/dist/esm/foundation/physics/PhysicsProperty.d.ts +9 -2
- package/dist/esm/foundation/physics/index.d.ts +0 -1
- package/dist/esm/foundation/renderer/index.d.ts +1 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esm/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esm/foundation/system/Engine.d.ts +9 -2
- package/dist/esm/foundation/system/EngineState.d.ts +1 -1
- package/dist/esm/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esm/index.js +1181 -824
- package/dist/esm/webgl/MultiDraw.d.ts +1 -1
- package/dist/esm/webgl/WebGLResourceRepository.d.ts +1 -2
- package/dist/{esmdev/webgl/WebGLStrategyDataTexture.d.ts → esm/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
- package/dist/esm/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
- package/dist/esm/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
- package/dist/esm/webgl/debug/index.d.ts +3 -0
- package/dist/esm/webgl/debug/types.d.ts +114 -0
- package/dist/esm/webgl/index.d.ts +2 -2
- package/dist/esm/webgl/main.d.ts +2 -4
- package/dist/esm/webgl/shaders/StandardShaderPart.d.ts +1 -1
- package/dist/esm/webgl/types/CommonTypes.d.ts +0 -1
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
- package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +109 -4
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
- package/dist/esmdev/foundation/core/Component.d.ts +1 -8
- package/dist/esmdev/foundation/core/Config.d.ts +165 -6
- package/dist/esmdev/foundation/core/GlobalDataRepository.d.ts +12 -8
- package/dist/esmdev/foundation/core/MemoryManager.d.ts +12 -0
- package/dist/esmdev/foundation/definitions/ProcessApproach.d.ts +1 -6
- package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +0 -1
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
- package/dist/esmdev/foundation/materials/core/Material.d.ts +10 -14
- package/dist/esmdev/foundation/materials/core/MaterialRepository.d.ts +5 -0
- package/dist/esmdev/foundation/physics/PhysicsProperty.d.ts +9 -2
- package/dist/esmdev/foundation/physics/index.d.ts +0 -1
- package/dist/esmdev/foundation/renderer/index.d.ts +1 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esmdev/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esmdev/foundation/system/Engine.d.ts +9 -2
- package/dist/esmdev/foundation/system/EngineState.d.ts +1 -1
- package/dist/esmdev/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esmdev/index.js +3419 -2172
- package/dist/esmdev/webgl/MultiDraw.d.ts +1 -1
- package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +1 -2
- package/dist/{esm/webgl/WebGLStrategyDataTexture.d.ts → esmdev/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
- package/dist/esmdev/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
- package/dist/esmdev/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
- package/dist/esmdev/webgl/debug/index.d.ts +3 -0
- package/dist/esmdev/webgl/debug/types.d.ts +114 -0
- package/dist/esmdev/webgl/index.d.ts +2 -2
- package/dist/esmdev/webgl/main.d.ts +2 -4
- package/dist/esmdev/webgl/shaders/StandardShaderPart.d.ts +1 -1
- package/dist/esmdev/webgl/types/CommonTypes.d.ts +0 -1
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
- package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/package.json +2 -1
- package/dist/esm/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
- package/dist/esm/foundation/physics/Oimo/index.d.ts +0 -1
- package/dist/esm/webgl/WebGLStrategyUniform.d.ts +0 -193
- package/dist/esmdev/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
- package/dist/esmdev/foundation/physics/Oimo/index.d.ts +0 -1
- package/dist/esmdev/webgl/WebGLStrategyUniform.d.ts +0 -193
|
@@ -2,7 +2,9 @@ import type { ComponentSID, ComponentTID, EntityUID } from '../../../types/Commo
|
|
|
2
2
|
import { Component } from '../../core/Component';
|
|
3
3
|
import type { IEntity } from '../../core/Entity';
|
|
4
4
|
import { type EntityRepository } from '../../core/EntityRepository';
|
|
5
|
+
import { type LightTypeEnum } from '../../definitions/LightType';
|
|
5
6
|
import type { ILightEntity } from '../../helpers/EntityHelper';
|
|
7
|
+
import { MutableVector4 } from '../../math/MutableVector4';
|
|
6
8
|
import { Vector3 } from '../../math/Vector3';
|
|
7
9
|
import type { Engine } from '../../system/Engine';
|
|
8
10
|
import type { ComponentToComponentMethods } from '../ComponentTypes';
|
|
@@ -13,15 +15,17 @@ import type { ComponentToComponentMethods } from '../ComponentTypes';
|
|
|
13
15
|
* the light looks towards the local -Z axis in right hand coordinate system.
|
|
14
16
|
*/
|
|
15
17
|
export declare class LightComponent extends Component {
|
|
16
|
-
|
|
18
|
+
private __type;
|
|
17
19
|
private __color;
|
|
20
|
+
/** The components of the color at the last change, to detect changes of a mutated color object. */
|
|
21
|
+
private __lastColor;
|
|
18
22
|
private __intensity;
|
|
19
23
|
private readonly __initialDirection;
|
|
20
24
|
private __direction;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
private __innerConeAngle;
|
|
26
|
+
private __outerConeAngle;
|
|
23
27
|
private __range;
|
|
24
|
-
|
|
28
|
+
private __enable;
|
|
25
29
|
private __shadowAreaSizeForDirectionalLight;
|
|
26
30
|
private __shadowZNearForDirectionalLight;
|
|
27
31
|
private __shadowCameraOffsetForDirectionalLight;
|
|
@@ -32,9 +36,13 @@ export declare class LightComponent extends Component {
|
|
|
32
36
|
private _lightProperty;
|
|
33
37
|
private static __lightNumber;
|
|
34
38
|
private __lightGizmo?;
|
|
39
|
+
/** The shadow slot assigned by a ShadowSystem. `undefined` means the default slot (see `_shadowSlot`). */
|
|
40
|
+
private __shadowSlot;
|
|
35
41
|
private __updateCount;
|
|
36
42
|
private __lastUpdateCount;
|
|
37
43
|
private __lastTransformUpdateCount;
|
|
44
|
+
/** The number of changes of all light components, per engine. */
|
|
45
|
+
private static __updateCountMap;
|
|
38
46
|
/**
|
|
39
47
|
* Creates a new LightComponent instance.
|
|
40
48
|
*
|
|
@@ -45,6 +53,56 @@ export declare class LightComponent extends Component {
|
|
|
45
53
|
* @param isReUse - Whether this component is being reused from a pool
|
|
46
54
|
*/
|
|
47
55
|
constructor(engine: Engine, entityUid: EntityUID, componentSid: ComponentSID, entityRepository: EntityRepository, isReUse: boolean);
|
|
56
|
+
/**
|
|
57
|
+
* Gets the number of changes of all light components of the engine (creation, destruction and property changes).
|
|
58
|
+
* The engine and the rendering strategies use it to process and upload the light data only when it changed.
|
|
59
|
+
*
|
|
60
|
+
* @param engine - The engine instance
|
|
61
|
+
* @returns The update count
|
|
62
|
+
*/
|
|
63
|
+
static getUpdateCount(engine: Engine): number;
|
|
64
|
+
private static __incrementUpdateCount;
|
|
65
|
+
/**
|
|
66
|
+
* Cleans up the static data of the engine.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
static _cleanupForEngine(engine: Engine): void;
|
|
70
|
+
/**
|
|
71
|
+
* Records a change of a property, so that the light data is recomputed and uploaded.
|
|
72
|
+
*/
|
|
73
|
+
private __markUpdated;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the type of the light.
|
|
76
|
+
*/
|
|
77
|
+
get type(): LightTypeEnum;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the type of the light.
|
|
80
|
+
*/
|
|
81
|
+
set type(value: LightTypeEnum);
|
|
82
|
+
/**
|
|
83
|
+
* Gets whether the light is enabled.
|
|
84
|
+
*/
|
|
85
|
+
get enable(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Sets whether the light is enabled. A disabled light does not light anything.
|
|
88
|
+
*/
|
|
89
|
+
set enable(value: boolean);
|
|
90
|
+
/**
|
|
91
|
+
* Gets the inner cone angle of the spot light (in radian).
|
|
92
|
+
*/
|
|
93
|
+
get innerConeAngle(): number;
|
|
94
|
+
/**
|
|
95
|
+
* Sets the inner cone angle of the spot light (in radian).
|
|
96
|
+
*/
|
|
97
|
+
set innerConeAngle(value: number);
|
|
98
|
+
/**
|
|
99
|
+
* Gets the outer cone angle of the spot light (in radian).
|
|
100
|
+
*/
|
|
101
|
+
get outerConeAngle(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Sets the outer cone angle of the spot light (in radian).
|
|
104
|
+
*/
|
|
105
|
+
set outerConeAngle(value: number);
|
|
48
106
|
/**
|
|
49
107
|
* Gets the component type identifier for LightComponent.
|
|
50
108
|
*
|
|
@@ -144,6 +202,48 @@ export declare class LightComponent extends Component {
|
|
|
144
202
|
* @returns The RGB color vector
|
|
145
203
|
*/
|
|
146
204
|
get color(): Vector3;
|
|
205
|
+
/**
|
|
206
|
+
* The index of the shadow data of this light in the per-material shadow arrays
|
|
207
|
+
* (`depthTextureIndexList` and `depthBiasPV`), or -1 when the light has no shadow data.
|
|
208
|
+
*
|
|
209
|
+
* @remarks
|
|
210
|
+
* A ShadowSystem assigns the slots of the lights it manages. Otherwise the slot is the component SID
|
|
211
|
+
* when it is below `Config.maxLightNumber`, which is the convention of manual shadow map setups.
|
|
212
|
+
*
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
get _shadowSlot(): number;
|
|
216
|
+
/**
|
|
217
|
+
* Sets the shadow slot of this light. `undefined` restores the default slot.
|
|
218
|
+
*
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
set _shadowSlot(slot: number | undefined);
|
|
222
|
+
/**
|
|
223
|
+
* The world position of the light as uploaded to the GPU (updated in $logic).
|
|
224
|
+
*
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
227
|
+
get _lightPositionForGpu(): MutableVector4;
|
|
228
|
+
/**
|
|
229
|
+
* The world direction of the light as uploaded to the GPU (updated in $logic).
|
|
230
|
+
*
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
get _lightDirectionForGpu(): MutableVector4;
|
|
234
|
+
/**
|
|
235
|
+
* The light property (type, effective range, cos of the inner and outer cone angles) as uploaded to the GPU
|
|
236
|
+
* (updated in $logic).
|
|
237
|
+
*
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
get _lightPropertyForGpu(): MutableVector4;
|
|
241
|
+
/**
|
|
242
|
+
* The intensity of the light (color * intensity) as uploaded to the GPU (updated in $logic).
|
|
243
|
+
*
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
get _lightIntensityForGpu(): MutableVector4;
|
|
147
247
|
/**
|
|
148
248
|
* Gets the up vector for the light in local space.
|
|
149
249
|
* This is used for light orientation calculations.
|
|
@@ -195,6 +295,11 @@ export declare class LightComponent extends Component {
|
|
|
195
295
|
* to avoid unnecessary recalculations when nothing has changed.
|
|
196
296
|
*/
|
|
197
297
|
$logic(): void;
|
|
298
|
+
/**
|
|
299
|
+
* Returns the range used for shading. Point and spot lights without a range get an automatic range
|
|
300
|
+
* when `Config.lightAutoRangeThreshold` is greater than 0.
|
|
301
|
+
*/
|
|
302
|
+
private __getEffectiveRange;
|
|
198
303
|
/**
|
|
199
304
|
* Cleans up the light component when it's being destroyed.
|
|
200
305
|
* Resets the light intensity values in the global data arrays.
|
|
@@ -73,7 +73,7 @@ export declare class PhysicsComponent extends Component {
|
|
|
73
73
|
/**
|
|
74
74
|
* Common logic method that updates the global physics simulation.
|
|
75
75
|
* This is called once per frame for all physics components and handles
|
|
76
|
-
* the overall physics world update
|
|
76
|
+
* the overall physics world update through the Rapier physics backend.
|
|
77
77
|
*/
|
|
78
78
|
static common_$logic({ engine }: {
|
|
79
79
|
engine: Engine;
|
|
@@ -29,11 +29,6 @@ export type MemberInfo = {
|
|
|
29
29
|
componentType: ComponentTypeEnum;
|
|
30
30
|
initValues: number[] | VectorN;
|
|
31
31
|
convertToBool?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Multiplier applied to the uniform array length in uniform mode
|
|
34
|
-
* (the array length becomes Config.maxSkeletalBoneNumberForUniformMode * this value).
|
|
35
|
-
*/
|
|
36
|
-
uniformArrayLengthMultiplier?: number;
|
|
37
32
|
/**
|
|
38
33
|
* Whether this array member has a per-instance length (see `Component.registerMember`).
|
|
39
34
|
*/
|
|
@@ -249,10 +244,9 @@ export declare class Component extends RnObject {
|
|
|
249
244
|
* @param componentType - The primitive data type (e.g., Float32, Int32)
|
|
250
245
|
* @param initValues - Initial values for the member field
|
|
251
246
|
* @param convertToBool - Whether to convert the member value to a boolean
|
|
252
|
-
* @param uniformArrayLengthMultiplier - Multiplier of the uniform array length in uniform mode
|
|
253
247
|
* @param isVariableLength - Whether the array member has a per-instance length
|
|
254
248
|
*/
|
|
255
|
-
static registerMember(this: typeof Component, { bufferUse, memberName, dataClassType, shaderType, compositionType, componentType, initValues, arrayLength, componentSID, convertToBool,
|
|
249
|
+
static registerMember(this: typeof Component, { bufferUse, memberName, dataClassType, shaderType, compositionType, componentType, initValues, arrayLength, componentSID, convertToBool, isVariableLength, }: {
|
|
256
250
|
bufferUse: BufferUseEnum;
|
|
257
251
|
memberName: string;
|
|
258
252
|
dataClassType: DataClassType;
|
|
@@ -263,7 +257,6 @@ export declare class Component extends RnObject {
|
|
|
263
257
|
arrayLength?: Count | undefined;
|
|
264
258
|
componentSID?: ComponentSID;
|
|
265
259
|
convertToBool?: boolean;
|
|
266
|
-
uniformArrayLengthMultiplier?: number;
|
|
267
260
|
isVariableLength?: boolean;
|
|
268
261
|
}): void;
|
|
269
262
|
/**
|
|
@@ -11,7 +11,6 @@ type ConfigInitDescription = {
|
|
|
11
11
|
maxLightNumber?: number;
|
|
12
12
|
materialCountPerBufferView?: number;
|
|
13
13
|
boneDataType?: BoneDataTypeEnum;
|
|
14
|
-
maxSkeletalBoneNumberForUniformMode?: number;
|
|
15
14
|
isUboEnabled?: boolean;
|
|
16
15
|
eventTargetDom?: HTMLElement;
|
|
17
16
|
cacheWebGpuRenderBundles?: boolean;
|
|
@@ -22,7 +21,22 @@ type ConfigInitDescription = {
|
|
|
22
21
|
bufferSizeDivisionRatiosForGPUInstanceDataUsage?: number[];
|
|
23
22
|
logLevel?: LogLevel;
|
|
24
23
|
isMultiDrawEnabled?: boolean;
|
|
24
|
+
isDepthPrepassEnabled?: boolean;
|
|
25
|
+
isClusteredForwardEnabled?: boolean;
|
|
26
|
+
clusteredForwardBuildMode?: ClusteredForwardBuildMode;
|
|
27
|
+
clusteredForwardGridSize?: [number, number, number];
|
|
28
|
+
clusteredForwardMaxViewNumber?: number;
|
|
29
|
+
clusteredForwardLightCapacityPerCluster?: number;
|
|
30
|
+
clusteredForwardMinLocalLightNumber?: number;
|
|
31
|
+
maxLightListLength?: number;
|
|
32
|
+
lightAutoRangeThreshold?: number;
|
|
25
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Where the light clusters of Clustered Forward rendering are built.
|
|
36
|
+
* - `'auto'`: WebGPU builds them with compute shaders, WebGL2 builds them on the CPU.
|
|
37
|
+
* - `'cpu'`: Both backends build them on the CPU.
|
|
38
|
+
*/
|
|
39
|
+
export type ClusteredForwardBuildMode = 'auto' | 'cpu';
|
|
26
40
|
/**
|
|
27
41
|
* Config is a configuration class that contains the configuration for the library.
|
|
28
42
|
*/
|
|
@@ -33,10 +47,133 @@ export declare class Config {
|
|
|
33
47
|
skeletalComponentCountPerBufferView: number;
|
|
34
48
|
/** The number of camera components per buffer view */
|
|
35
49
|
cameraComponentCountPerBufferView: number;
|
|
36
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The number of light components per buffer view.
|
|
52
|
+
* Every new buffer view changes the generated shader getters and recompiles all shaders,
|
|
53
|
+
* so this is large enough for scenes with many lights.
|
|
54
|
+
*/
|
|
37
55
|
lightComponentCountPerBufferView: number;
|
|
38
|
-
/**
|
|
39
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The maximum number of lights that can cast shadows at the same time.
|
|
58
|
+
* This is also the length of the per-light arrays of the MToon 0.x shader.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* 0 disables the per-light shadow map slots: the shaders compile out the shadow sampling and no shadow map
|
|
62
|
+
* textures are created. The shader arrays themselves cannot have a length of 0, so they use
|
|
63
|
+
* {@link Config.maxLightNumberOrOne} instead. Negative and NaN values are treated as 0.
|
|
64
|
+
*/
|
|
65
|
+
private __maxLightNumber;
|
|
66
|
+
/** See {@link Config.maxLightNumber}. */
|
|
67
|
+
get maxLightNumber(): number;
|
|
68
|
+
/** See {@link Config.maxLightNumber}. */
|
|
69
|
+
set maxLightNumber(value: number);
|
|
70
|
+
/**
|
|
71
|
+
* The length-safe value of {@link Config.maxLightNumber}: `maxLightNumber`, or 1 when it is 0.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* Shader arrays, material parameters and texture arrays cannot have a length of 0. The shaders use this value
|
|
75
|
+
* for their per-light array sizes and loop bounds. Shadow processing itself is controlled by
|
|
76
|
+
* {@link Config.maxLightNumber}: when it is 0, the shadow code is compiled out and no shadow slots are assigned.
|
|
77
|
+
*/
|
|
78
|
+
get maxLightNumberOrOne(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Whether Clustered Forward rendering is enabled.
|
|
81
|
+
* When enabled, each fragment evaluates only the lights whose range reaches the cluster (froxel) of the fragment.
|
|
82
|
+
* Lights without a range limit and directional lights are always evaluated.
|
|
83
|
+
*/
|
|
84
|
+
isClusteredForwardEnabled: boolean;
|
|
85
|
+
/** Where the light clusters are built. See {@link ClusteredForwardBuildMode}. */
|
|
86
|
+
clusteredForwardBuildMode: ClusteredForwardBuildMode;
|
|
87
|
+
/**
|
|
88
|
+
* The number of clusters along the screen X, screen Y and view depth axes.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* The default puts about a 40 pixel tile on a 1920x1080 canvas. The screen tiles should stay roughly 30-40 pixels
|
|
92
|
+
* at the rendered resolution: a coarser grid lets many lights share each cluster (the cost is paid by every
|
|
93
|
+
* fragment), and a finer grid increases the per-frame cluster build cost (the cost is paid once per frame, and the
|
|
94
|
+
* build is proportional to the cluster count in the current implementation).
|
|
95
|
+
*/
|
|
96
|
+
clusteredForwardGridSize: [number, number, number];
|
|
97
|
+
/**
|
|
98
|
+
* The maximum number of cameras whose light clusters are built in one frame.
|
|
99
|
+
* The other cameras evaluate all lights.
|
|
100
|
+
*/
|
|
101
|
+
clusteredForwardMaxViewNumber: number;
|
|
102
|
+
/**
|
|
103
|
+
* The light clusters are built only when the number of lights that can be culled (point and spot lights with a
|
|
104
|
+
* range, including an automatic range of {@link Config.lightAutoRangeThreshold}) and emit light (an intensity
|
|
105
|
+
* greater than 0) is at least this value. With fewer lights, every fragment evaluates all lights as in plain forward
|
|
106
|
+
* rendering, which skips the cluster build and the cluster lookup of the fragment shaders.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* The default value 1 is the measured break-even point of both backends: on Apple M2 Max (Chrome, ANGLE-Metal /
|
|
110
|
+
* Dawn-Metal) with a full-screen 2048x2048 PBR surface, the GPU frame time with and without clusters was
|
|
111
|
+
* (ratio = clustered / plain forward, lower is better; a range is the spread of several runs):
|
|
112
|
+
*
|
|
113
|
+
* | Lights | WebGL2 (radius 3 / 6) | WebGPU (radius 3 / 6) |
|
|
114
|
+
* |--------|------------------------|-----------------------|
|
|
115
|
+
* | 1 | 0.90-0.92 / 0.82-1.09 | 0.83 / 0.92 |
|
|
116
|
+
* | 2 | 0.64 / 0.76-0.84 | 0.61 / 0.76 |
|
|
117
|
+
* | 3 | 0.62 / 0.72 | 0.49 / 0.66 |
|
|
118
|
+
* | 8 | 0.42 / 0.62 | 0.32 / 0.51 |
|
|
119
|
+
*
|
|
120
|
+
* (A light with the radius 3 or 6 covers about 7% or 28% of the screen.) The cluster lookup costs about half a
|
|
121
|
+
* light in both backends. The Classic shader and a moving camera (clusters rebuilt every frame) gave the same
|
|
122
|
+
* break-even points. Lights that cover the whole screen can not be culled, so clustering them is always a few
|
|
123
|
+
* percent slower (WebGL2 2-3%, WebGPU 1-11%) whatever this value is. Raise this value for such scenes.
|
|
124
|
+
* Other GPUs may differ.
|
|
125
|
+
*/
|
|
126
|
+
clusteredForwardMinLocalLightNumber: number;
|
|
127
|
+
/**
|
|
128
|
+
* The maximum number of lights in the list of each cluster.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* Every cluster keeps at most this many lights. When the number of local lights is greater than this value, the
|
|
132
|
+
* lights are sorted by their view depth and each cluster keeps the nearest ones, so the lights that are dropped
|
|
133
|
+
* are the farthest ones. The cost of a fragment is bounded by this value.
|
|
134
|
+
*
|
|
135
|
+
* Memory per camera: about `16 * clusterCount * ceil(value / 4)` bytes, where clusterCount is the product of
|
|
136
|
+
* {@link Config.clusteredForwardGridSize} (62,208 by default). The default 96 is about 25 MB per camera.
|
|
137
|
+
*/
|
|
138
|
+
clusteredForwardLightCapacityPerCluster: number;
|
|
139
|
+
/** The maximum number of enabled lights that are shaded. The other lights are ignored. (max: 65535) */
|
|
140
|
+
maxLightListLength: number;
|
|
141
|
+
/**
|
|
142
|
+
* When greater than 0, point and spot lights without a range get an effective range where their intensity
|
|
143
|
+
* (the maximum of color * intensity, divided by the squared distance) falls to this value.
|
|
144
|
+
* This makes those lights fade out smoothly at that distance and lets Clustered Forward rendering cull them.
|
|
145
|
+
* 0 (default) disables it. Lights with a range and directional lights are not affected.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* The effective range is `R = sqrt(max(color) * intensity / lightAutoRangeThreshold)`. With the range window
|
|
149
|
+
* of the shaders (`(1 - (d / R)^4) / d^2`), the difference from the unlimited inverse-square falloff at the
|
|
150
|
+
* distance `d` is `lightAutoRangeThreshold * (d / R)^2`. So this value is the upper bound of the error added to
|
|
151
|
+
* the linear brightness (for the diffuse lighting of a white surface facing the light). The error is largest at
|
|
152
|
+
* the border of the range and smaller inside it.
|
|
153
|
+
*
|
|
154
|
+
* Reference values (without tone mapping, exposure 1):
|
|
155
|
+
*
|
|
156
|
+
* | Value | Range (intensity 1 / 10) | Effect on the image |
|
|
157
|
+
* |--------|--------------------------|---------------------|
|
|
158
|
+
* | 0.0003 | 58 / 183 | Practically lossless, but the range is so large that the lights are rarely culled. |
|
|
159
|
+
* | 0.001 | 32 / 100 | At most about 3/255 even on a black background. Not noticeable on lit surfaces. Recommended starting point. |
|
|
160
|
+
* | 0.003 | 18 / 58 | Hardly noticeable in scenes with ambient light or IBL. |
|
|
161
|
+
* | 0.01 | 10 / 32 | On a dark background, the tail of the light fades out a little early. About 3/255 on lit surfaces. |
|
|
162
|
+
*
|
|
163
|
+
* Tips:
|
|
164
|
+
* - Compare the resulting range with the visible area and the spacing of the lights. A range larger than them
|
|
165
|
+
* puts the light in almost every cluster, so it does not make rendering faster.
|
|
166
|
+
* - Scale the value with the brightness level of the scene. For example, when the light intensities are in the
|
|
167
|
+
* hundreds and the exposure brings them down, scale the value by the same factor. About 1/300 to 1/1000 of the
|
|
168
|
+
* typical brightness of the scene is a good guide.
|
|
169
|
+
* - Use a smaller value for dark scenes or when the exposure brightens dark areas, where the cut-off tail is
|
|
170
|
+
* more noticeable.
|
|
171
|
+
* - The error of specular highlights on glossy surfaces can be larger than the table above, but the light is
|
|
172
|
+
* weak near the border of the range, so it is rarely noticeable.
|
|
173
|
+
* - Set this when initializing the engine. A change at runtime takes effect for each light when the light is
|
|
174
|
+
* updated next.
|
|
175
|
+
*/
|
|
176
|
+
lightAutoRangeThreshold: number;
|
|
40
177
|
/**
|
|
41
178
|
* Number of instances of each material type to be placed consecutively in memory.
|
|
42
179
|
* This is on the memory layout, and the number of material instances that can be generated is not limited by this setting.
|
|
@@ -50,8 +187,6 @@ export declare class Config {
|
|
|
50
187
|
* and other SkeletalComponents default to Vec4x2.
|
|
51
188
|
*/
|
|
52
189
|
boneDataType: BoneDataTypeEnum | undefined;
|
|
53
|
-
/** The maximum number of bones of each skeleton that Rhodonite can handle for Uniform Mode */
|
|
54
|
-
maxSkeletalBoneNumberForUniformMode: number;
|
|
55
190
|
/** Whether the UBO is enabled */
|
|
56
191
|
isUboEnabled: boolean;
|
|
57
192
|
/** The event target DOM for mouse operation */
|
|
@@ -76,6 +211,30 @@ export declare class Config {
|
|
|
76
211
|
* vertex/index buffers and consecutive draws with the same state are issued with WEBGL_multi_draw.
|
|
77
212
|
*/
|
|
78
213
|
isMultiDrawEnabled: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Whether to render a depth prepass for the opaque primitives of the main render passes (WebGPU only).
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* The prepass draws the opaque primitives with a depth-only pipeline before the color pass, and the color pass
|
|
219
|
+
* tests the depth with `less-equal`. Hidden fragments are rejected before the fragment shader, so the cost of the
|
|
220
|
+
* prepass (vertex processing and a trivial fragment shader) is traded for the shading of the overdrawn fragments.
|
|
221
|
+
*
|
|
222
|
+
* Primitives that alpha test (Mask), alpha-to-coverage, discard for wireframe, or blend are not part of the prepass:
|
|
223
|
+
* they keep their normal draw, depth test and depth write. A material that discards in another way should not be
|
|
224
|
+
* used with this option. At exactly coplanar surfaces the visible surface can change, because the color pass passes
|
|
225
|
+
* fragments whose depth is equal to the prepass depth (a few hundred pixels on a Sponza-scale scene).
|
|
226
|
+
*
|
|
227
|
+
* Render passes with a material override (shadow maps, post effects and other helper passes) are not affected.
|
|
228
|
+
* The prepass is per render pass, so stereo rendering runs it once per eye. The WebGL2 backend ignores this option
|
|
229
|
+
* (its multi-draw path keeps the material order).
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* Measured on the 1000-point-light Sponza (WebGPU, Apple M2 Max): the GPU time fell by about 5-7% (1280x720:
|
|
233
|
+
* 4.46 -> 4.13 ms) and the frame wall time by about 0-10% (the run was thermally throttled, so treat the wall
|
|
234
|
+
* number as an upper bound). The gain grows with the amount of overdrawn shading. The default is off because the
|
|
235
|
+
* extra geometry pass hurts scenes with little overdraw or heavy vertex shaders.
|
|
236
|
+
*/
|
|
237
|
+
isDepthPrepassEnabled: boolean;
|
|
79
238
|
constructor(initDescription?: ConfigInitDescription);
|
|
80
239
|
}
|
|
81
240
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProcessApproachEnum } from '../../foundation/definitions/ProcessApproach';
|
|
2
|
-
import type { CGAPIResourceHandle, Index, IndexOf16Bytes } from '../../types/CommonTypes';
|
|
2
|
+
import type { CGAPIResourceHandle, Count, Index, IndexOf16Bytes } from '../../types/CommonTypes';
|
|
3
3
|
import type { getShaderPropertyFuncOfGlobalDataRepository, ShaderSemanticsName } from '../definitions/ShaderSemantics';
|
|
4
|
+
import { type ShaderSemanticsInfo } from '../definitions/ShaderSemanticsInfo';
|
|
4
5
|
import type { Engine } from '../system/Engine';
|
|
5
6
|
/**
|
|
6
7
|
* The repository class that manages global data used throughout the rendering pipeline.
|
|
@@ -63,13 +64,16 @@ export declare class GlobalDataRepository {
|
|
|
63
64
|
*/
|
|
64
65
|
getValue(shaderSemantic: ShaderSemanticsName, countIndex: Index): any;
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
-
* This is
|
|
68
|
-
*
|
|
69
|
-
* @param shaderProgramUid - The unique identifier of the shader program
|
|
70
|
-
* @internal
|
|
67
|
+
* Returns every registered global property with its current value and layout offset.
|
|
68
|
+
* This is intended for debugging tools; it does not allocate or modify anything.
|
|
71
69
|
*/
|
|
72
|
-
|
|
70
|
+
getPropertyTable(): Array<{
|
|
71
|
+
semantic: ShaderSemanticsName;
|
|
72
|
+
info: ShaderSemanticsInfo;
|
|
73
|
+
value: any;
|
|
74
|
+
vec4Index: IndexOf16Bytes;
|
|
75
|
+
maxCount: Count;
|
|
76
|
+
}>;
|
|
73
77
|
/**
|
|
74
78
|
* Sets up uniform locations for properties that need uniform access in data texture mode.
|
|
75
79
|
* Only sets up uniforms for properties marked with needUniformInDataTextureMode flag.
|
|
@@ -77,7 +81,7 @@ export declare class GlobalDataRepository {
|
|
|
77
81
|
* @param shaderProgramUid - The unique identifier of the shader program
|
|
78
82
|
* @internal
|
|
79
83
|
*/
|
|
80
|
-
|
|
84
|
+
_setUniformLocationsForWebGL2ModeOnly(shaderProgramUid: CGAPIResourceHandle): void;
|
|
81
85
|
/**
|
|
82
86
|
* Gets the memory location offset of a global property in 16-byte aligned units.
|
|
83
87
|
* This is used for data texture mode to determine where properties are stored in memory.
|
|
@@ -87,6 +87,18 @@ export declare class MemoryManager {
|
|
|
87
87
|
* @returns The byte offset of the existing buffers in bytes
|
|
88
88
|
*/
|
|
89
89
|
getByteOffsetOfExistingBuffers(bufferUse: BufferUseEnum, indexOfTheBufferLayer: Index): Byte;
|
|
90
|
+
/**
|
|
91
|
+
* Reads float values from the concatenated layers of a buffer usage.
|
|
92
|
+
*
|
|
93
|
+
* This is intended for debugging tools. The returned array is a copy when the range
|
|
94
|
+
* spans buffer layers, and a view into the layer otherwise.
|
|
95
|
+
*
|
|
96
|
+
* @param bufferUse - The buffer usage to read
|
|
97
|
+
* @param byteOffset - Byte offset from the start of the first layer
|
|
98
|
+
* @param count - Number of float values to read
|
|
99
|
+
* @returns The read values, or null when the range is outside the allocated buffers
|
|
100
|
+
*/
|
|
101
|
+
readFloat32Array(bufferUse: BufferUseEnum, byteOffset: Byte, count: Count): Float32Array | null;
|
|
90
102
|
/**
|
|
91
103
|
* Prints memory usage statistics for all managed buffers to the console.
|
|
92
104
|
* Shows used bytes, total bytes, and usage percentage for each buffer type.
|
|
@@ -8,17 +8,12 @@ export declare class ProcessApproachClass extends EnumClass implements EnumIO {
|
|
|
8
8
|
}
|
|
9
9
|
export type ProcessApproachEnum = ProcessApproachClass;
|
|
10
10
|
declare function from(index: number): ProcessApproachEnum | undefined;
|
|
11
|
-
declare const isDataTextureApproach: (processApproach: ProcessApproachEnum) => boolean;
|
|
12
|
-
declare const isUniformApproach: (processApproach: ProcessApproachEnum) => boolean;
|
|
13
11
|
declare const isWebGpuApproach: (processApproach: ProcessApproachEnum) => boolean;
|
|
14
12
|
declare const isWebGL2Approach: (processApproach: ProcessApproachEnum) => boolean;
|
|
15
13
|
export declare const ProcessApproach: Readonly<{
|
|
16
|
-
isDataTextureApproach: typeof isDataTextureApproach;
|
|
17
|
-
isUniformApproach: typeof isUniformApproach;
|
|
18
14
|
isWebGpuApproach: typeof isWebGpuApproach;
|
|
19
15
|
None: ProcessApproachClass;
|
|
20
|
-
|
|
21
|
-
DataTexture: ProcessApproachClass;
|
|
16
|
+
WebGL2: ProcessApproachClass;
|
|
22
17
|
WebGPU: ProcessApproachClass;
|
|
23
18
|
from: typeof from;
|
|
24
19
|
isWebGL2Approach: typeof isWebGL2Approach;
|
|
@@ -71,7 +71,6 @@ export declare const ShaderSemantics: Readonly<{
|
|
|
71
71
|
ShadingModel: ShaderSemanticsEnum;
|
|
72
72
|
SkinningMode: ShaderSemanticsEnum;
|
|
73
73
|
GeneralTexture: ShaderSemanticsEnum;
|
|
74
|
-
VertexAttributesExistenceArray: ShaderSemanticsEnum;
|
|
75
74
|
BoneQuaternion: ShaderSemanticsEnum;
|
|
76
75
|
BoneTranslateScale: ShaderSemanticsEnum;
|
|
77
76
|
BoneTranslatePackedQuat: ShaderSemanticsEnum;
|
|
@@ -26,9 +26,11 @@ export declare class PointShadowMap {
|
|
|
26
26
|
*
|
|
27
27
|
* @param entities - Array of scene graph entities to be rendered for shadow map generation
|
|
28
28
|
* @param lightEntity - The point light entity that casts shadows
|
|
29
|
+
* @param shadowSlot - The shadow slot of the light (below `Config.maxLightNumber`). Defaults to the shadow slot
|
|
30
|
+
* of the light component.
|
|
29
31
|
* @returns An array containing two render passes: [frontRenderPass, backRenderPass]
|
|
30
32
|
*/
|
|
31
|
-
getRenderPasses(entities: ISceneGraphEntity[], lightEntity: ISceneGraphEntity & ILightEntityMethods): RenderPass[];
|
|
33
|
+
getRenderPasses(entities: ISceneGraphEntity[], lightEntity: ISceneGraphEntity & ILightEntityMethods, shadowSlot?: number): RenderPass[];
|
|
32
34
|
/**
|
|
33
35
|
* Gets the framebuffer used for storing shadow moment data.
|
|
34
36
|
* This framebuffer contains the encoded depth moments for variance shadow mapping.
|
|
@@ -15,6 +15,8 @@ export declare class ShadowSystem {
|
|
|
15
15
|
private __lightTypes;
|
|
16
16
|
private __lightEnables;
|
|
17
17
|
private __lightCastShadows;
|
|
18
|
+
private __lightSids;
|
|
19
|
+
private __isShadowSlotShortageWarned;
|
|
18
20
|
/** Reused by setDepthBiasPV() on every frame. */
|
|
19
21
|
private __depthBiasPVArray?;
|
|
20
22
|
private __depthBiasPV?;
|
|
@@ -42,6 +44,17 @@ export declare class ShadowSystem {
|
|
|
42
44
|
* @returns Array of Expression objects containing the shadow mapping render passes
|
|
43
45
|
*/
|
|
44
46
|
getExpressions(entities: ISceneGraphEntity[]): Expression[];
|
|
47
|
+
/**
|
|
48
|
+
* Assigns the shadow slots (the indices of the per-material shadow arrays) to the lights.
|
|
49
|
+
*
|
|
50
|
+
* A shadow casting light keeps the slot equal to its component SID when the SID is below
|
|
51
|
+
* `Config.maxLightNumber` (the convention of manual shadow map setups), and the other shadow casting lights
|
|
52
|
+
* use the free slots. Lights that do not cast shadows get no slot.
|
|
53
|
+
*
|
|
54
|
+
* @param lightComponents - The live light components
|
|
55
|
+
* @param hasShadowCasters - Whether any entity is rendered to the shadow maps
|
|
56
|
+
*/
|
|
57
|
+
private __assignShadowSlots;
|
|
45
58
|
/**
|
|
46
59
|
* Sets the blurred shadow map texture for directional and spot lights on all entity materials.
|
|
47
60
|
* Creates a linear sampler and assigns the shadow map texture to the 'depthTexture' parameter.
|
|
@@ -12,7 +12,7 @@ import type { Material } from '../core/Material';
|
|
|
12
12
|
export declare class CustomMaterialContent extends AbstractMaterialContent {
|
|
13
13
|
private __diffuseIblCubeMapSampler;
|
|
14
14
|
private __specularIblCubeMapSampler;
|
|
15
|
-
/** Material and values of the last IBL parameter write (
|
|
15
|
+
/** Material and values of the last IBL parameter write (WebGL2 mode). */
|
|
16
16
|
private __lastIblMaterial?;
|
|
17
17
|
private __lastIblMaterialStateVersion;
|
|
18
18
|
private __lastIblValues;
|
|
@@ -2,10 +2,7 @@ import { type ShaderityObject } from 'shaderity';
|
|
|
2
2
|
import type { RenderingArgWebGL } from '../../../webgl/types/CommonTypes';
|
|
3
3
|
import type { BlendShapeComponent } from '../../components/BlendShape/BlendShapeComponent';
|
|
4
4
|
import type { CameraComponent } from '../../components/Camera/CameraComponent';
|
|
5
|
-
import type { LightComponent } from '../../components/Light/LightComponent';
|
|
6
5
|
import type { MeshComponent } from '../../components/Mesh/MeshComponent';
|
|
7
|
-
import type { SkeletalComponent } from '../../components/Skeletal/SkeletalComponent';
|
|
8
|
-
import type { Config } from '../../core/Config';
|
|
9
6
|
import { RnObject } from '../../core/RnObject';
|
|
10
7
|
import type { ShaderSemanticsInfo } from '../../definitions/ShaderSemanticsInfo';
|
|
11
8
|
import { type ShaderTypeEnum } from '../../definitions/ShaderType';
|
|
@@ -39,10 +36,6 @@ export declare abstract class AbstractMaterialContent extends RnObject {
|
|
|
39
36
|
private __isMorphing;
|
|
40
37
|
private __isSkinning;
|
|
41
38
|
private __isLighting;
|
|
42
|
-
private static __lightPositions;
|
|
43
|
-
private static __lightDirections;
|
|
44
|
-
private static __lightIntensities;
|
|
45
|
-
private static __lightProperties;
|
|
46
39
|
private static __materialContentCount;
|
|
47
40
|
private __materialContentUid;
|
|
48
41
|
/** Shader caches managed per-Engine. Key is Engine.objectUID */
|
|
@@ -172,7 +165,7 @@ export declare abstract class AbstractMaterialContent extends RnObject {
|
|
|
172
165
|
* @param material - The material instance
|
|
173
166
|
* @param CameraComponentClass - The camera component class
|
|
174
167
|
*/
|
|
175
|
-
protected setupBasicInfo(
|
|
168
|
+
protected setupBasicInfo(_engine: Engine, args: RenderingArgWebGL, shaderProgram: WebGLProgram, _firstTime: boolean, _material: Material, _CameraComponentClass: typeof CameraComponent): void;
|
|
176
169
|
/**
|
|
177
170
|
* Sets the world transformation matrix uniform in the shader.
|
|
178
171
|
* @param shaderProgram - The WebGL shader program
|
|
@@ -213,21 +206,6 @@ export declare abstract class AbstractMaterialContent extends RnObject {
|
|
|
213
206
|
* @param displayIdx - The display index for VR rendering
|
|
214
207
|
*/
|
|
215
208
|
setProjection(shaderProgram: WebGLProgram, cameraComponent: CameraComponent, isVr: boolean, displayIdx: number): void;
|
|
216
|
-
/**
|
|
217
|
-
* Sets skeletal animation uniforms in the shader.
|
|
218
|
-
* @param shaderProgram - The WebGL shader program
|
|
219
|
-
* @param setUniform - Whether to set uniform values
|
|
220
|
-
* @param skeletalComponent - The skeletal component containing bone data
|
|
221
|
-
*/
|
|
222
|
-
protected setSkinning(config: Config, shaderProgram: WebGLProgram, setUniform: boolean, skeletalComponent?: SkeletalComponent): void;
|
|
223
|
-
/**
|
|
224
|
-
* Sets lighting information uniforms in the shader.
|
|
225
|
-
* @param shaderProgram - The WebGL shader program
|
|
226
|
-
* @param lightComponents - Array of light components
|
|
227
|
-
* @param material - The material instance
|
|
228
|
-
* @param setUniform - Whether to set uniform values
|
|
229
|
-
*/
|
|
230
|
-
protected setLightsInfo(config: Config, shaderProgram: WebGLProgram, lightComponents: LightComponent[], _material: Material, setUniform: boolean): void;
|
|
231
209
|
/**
|
|
232
210
|
* Sets morph target animation uniforms in the shader.
|
|
233
211
|
* @param shaderProgram - The WebGL shader program
|