@onerjs/addons 8.27.3 → 8.27.5
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/atmosphere/atmosphere.d.ts +6 -1
- package/atmosphere/atmosphere.js +39 -8
- package/atmosphere/atmosphere.js.map +1 -1
- package/atmosphere/atmospherePBRMaterialPlugin.js +22 -11
- package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -1
- package/atmosphere/diffuseSkyIrradianceLut.js +3 -1
- package/atmosphere/diffuseSkyIrradianceLut.js.map +1 -1
- package/atmosphere/transmittanceLut.js +2 -1
- package/atmosphere/transmittanceLut.js.map +1 -1
- package/navigation/common/getters.js +1 -1
- package/navigation/common/getters.js.map +1 -1
- package/navigation/factory/common.d.ts +7 -5
- package/navigation/factory/common.js +6 -4
- package/navigation/factory/common.js.map +1 -1
- package/navigation/factory/factory.single-thread.d.ts +6 -1
- package/navigation/factory/factory.single-thread.js +3 -2
- package/navigation/factory/factory.single-thread.js.map +1 -1
- package/navigation/plugin/RecastNavigationJSPlugin.js +3 -1
- package/navigation/plugin/RecastNavigationJSPlugin.js.map +1 -1
- package/package.json +2 -2
|
@@ -72,6 +72,7 @@ export declare class Atmosphere implements IDisposable {
|
|
|
72
72
|
private _aerialPerspectiveRenderingGroup;
|
|
73
73
|
private _globeAtmosphereRenderingGroup;
|
|
74
74
|
private _isEnabled;
|
|
75
|
+
private _aerialPerspectiveLutHasBeenRendered;
|
|
75
76
|
private _hasRenderedMultiScatteringLut;
|
|
76
77
|
private _multiScatteringEffectWrapper;
|
|
77
78
|
private _multiScatteringLutRenderTarget;
|
|
@@ -93,6 +94,10 @@ export declare class Atmosphere implements IDisposable {
|
|
|
93
94
|
* @returns True if the atmosphere is supported, false otherwise.
|
|
94
95
|
*/
|
|
95
96
|
static IsSupported(engine: AbstractEngine): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The unique ID of this atmosphere instance.
|
|
99
|
+
*/
|
|
100
|
+
readonly uniqueId: number;
|
|
96
101
|
/**
|
|
97
102
|
* Called after the atmosphere variables have been updated for the specified camera.
|
|
98
103
|
*/
|
|
@@ -283,7 +288,6 @@ export declare class Atmosphere implements IDisposable {
|
|
|
283
288
|
* Gets the camera-related variables for this atmosphere. Updated each frame.
|
|
284
289
|
*/
|
|
285
290
|
get cameraAtmosphereVariables(): AtmospherePerCameraVariables;
|
|
286
|
-
readonly uniqueId: number;
|
|
287
291
|
/**
|
|
288
292
|
* Constructs the {@link Atmosphere}.
|
|
289
293
|
* @param name - The name of this instance.
|
|
@@ -382,6 +386,7 @@ export declare class Atmosphere implements IDisposable {
|
|
|
382
386
|
* Draws the aerial perspective LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
383
387
|
*/
|
|
384
388
|
private _drawAerialPerspectiveLut;
|
|
389
|
+
private _clearAerialPerspectiveLut;
|
|
385
390
|
/**
|
|
386
391
|
* Draws the sky view LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
387
392
|
*/
|
package/atmosphere/atmosphere.js
CHANGED
|
@@ -26,6 +26,8 @@ import "./Shaders/ShadersInclude/atmosphereUboDeclaration.js";
|
|
|
26
26
|
import "./Shaders/ShadersInclude/atmosphereVertexDeclaration.js";
|
|
27
27
|
import "./Shaders/ShadersInclude/depthFunctions.js";
|
|
28
28
|
const MaterialPlugin = "atmo-pbr";
|
|
29
|
+
const AerialPerspectiveLutLayers = 32;
|
|
30
|
+
let UniqueId = 0;
|
|
29
31
|
/**
|
|
30
32
|
* Renders a physically based atmosphere.
|
|
31
33
|
* Use {@link IsSupported} to check if the atmosphere is supported before creating an instance.
|
|
@@ -210,7 +212,7 @@ export class Atmosphere {
|
|
|
210
212
|
}
|
|
211
213
|
const scene = this.scene;
|
|
212
214
|
const name = "atmo-aerialPerspective";
|
|
213
|
-
const renderTarget = (this._aerialPerspectiveLutRenderTarget = CreateRenderTargetTexture(name, { width: 16, height: 64, layers:
|
|
215
|
+
const renderTarget = (this._aerialPerspectiveLutRenderTarget = CreateRenderTargetTexture(name, { width: 16, height: 64, layers: AerialPerspectiveLutLayers }, scene, {}));
|
|
214
216
|
this._aerialPerspectiveLutEffectWrapper = CreateAerialPerspectiveEffectWrapper(this._engine, this.uniformBuffer);
|
|
215
217
|
return renderTarget;
|
|
216
218
|
}
|
|
@@ -497,6 +499,7 @@ export class Atmosphere {
|
|
|
497
499
|
this._atmosphereUniformBufferAsArray = [];
|
|
498
500
|
this._effectRenderer = null;
|
|
499
501
|
this._isEnabled = true;
|
|
502
|
+
this._aerialPerspectiveLutHasBeenRendered = false;
|
|
500
503
|
this._hasRenderedMultiScatteringLut = false;
|
|
501
504
|
this._multiScatteringEffectWrapper = null;
|
|
502
505
|
this._multiScatteringLutRenderTarget = null;
|
|
@@ -512,6 +515,10 @@ export class Atmosphere {
|
|
|
512
515
|
this._onBeforeCameraRenderObserver = null;
|
|
513
516
|
this._onBeforeDrawPhaseObserver = null;
|
|
514
517
|
this._onAfterRenderingGroupObserver = null;
|
|
518
|
+
/**
|
|
519
|
+
* The unique ID of this atmosphere instance.
|
|
520
|
+
*/
|
|
521
|
+
this.uniqueId = UniqueId++;
|
|
515
522
|
/**
|
|
516
523
|
* Called after the atmosphere variables have been updated for the specified camera.
|
|
517
524
|
*/
|
|
@@ -556,7 +563,6 @@ export class Atmosphere {
|
|
|
556
563
|
this.getDiffuseSkyIrradianceToRef = (directionToLight, pointRadius, pointGeocentricNormal, lightIrradiance, result) => this._diffuseSkyIrradianceLut?.getDiffuseSkyIrradianceToRef(directionToLight, pointRadius, pointGeocentricNormal, lightIrradiance, result) ??
|
|
557
564
|
((result.r = 0), (result.g = 0), (result.b = 0), result);
|
|
558
565
|
const engine = (this._engine = scene.getEngine());
|
|
559
|
-
this.uniqueId = scene.getUniqueId();
|
|
560
566
|
if (engine.isWebGPU) {
|
|
561
567
|
throw new Error("Atmosphere is not supported on WebGPU.");
|
|
562
568
|
}
|
|
@@ -988,9 +994,18 @@ export class Atmosphere {
|
|
|
988
994
|
if (this._isSkyViewLutEnabled) {
|
|
989
995
|
this._drawSkyViewLut();
|
|
990
996
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
this.
|
|
997
|
+
if (this._isAerialPerspectiveLutEnabled) {
|
|
998
|
+
// Only need to render aerial perspective LUT when inside the atmosphere.
|
|
999
|
+
if (this._cameraAtmosphereVariables.clampedCameraRadius <= this._physicalProperties.atmosphereRadius) {
|
|
1000
|
+
this._drawAerialPerspectiveLut();
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
// Make sure to clear the LUT to some initial value if this would have otherwise been the first time rendering it.
|
|
1004
|
+
if (!this._aerialPerspectiveLutHasBeenRendered) {
|
|
1005
|
+
this._clearAerialPerspectiveLut();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
this._aerialPerspectiveLutHasBeenRendered = true;
|
|
994
1009
|
}
|
|
995
1010
|
}
|
|
996
1011
|
this.onAfterRenderLutsForCameraObservable.notifyObservers();
|
|
@@ -1093,10 +1108,9 @@ export class Atmosphere {
|
|
|
1093
1108
|
const multiScatteringLut = this._multiScatteringLutRenderTarget;
|
|
1094
1109
|
DrawEffect(this._engine, this._effectRenderer, this._aerialPerspectiveLutEffectWrapper, this._aerialPerspectiveLutRenderTarget, (effectRenderer, renderTarget, effect, engine) => {
|
|
1095
1110
|
this.bindUniformBufferToEffect(effect);
|
|
1096
|
-
const layers = 32;
|
|
1097
1111
|
effect.setTexture("transmittanceLut", transmittanceLut);
|
|
1098
1112
|
effect.setTexture("multiScatteringLut", multiScatteringLut);
|
|
1099
|
-
for (let layer = 0; layer <
|
|
1113
|
+
for (let layer = 0; layer < AerialPerspectiveLutLayers; layer++) {
|
|
1100
1114
|
engine.bindFramebuffer(renderTarget, undefined, undefined, undefined, true, undefined, layer);
|
|
1101
1115
|
effectRenderer.bindBuffers(effect);
|
|
1102
1116
|
effect.setFloat("layerIdx", layer);
|
|
@@ -1104,6 +1118,17 @@ export class Atmosphere {
|
|
|
1104
1118
|
}
|
|
1105
1119
|
});
|
|
1106
1120
|
}
|
|
1121
|
+
_clearAerialPerspectiveLut() {
|
|
1122
|
+
const renderTarget = this._aerialPerspectiveLutRenderTarget?.renderTarget;
|
|
1123
|
+
if (renderTarget) {
|
|
1124
|
+
const engine = this._engine;
|
|
1125
|
+
const clearColor = { r: 0, g: 0, b: 0, a: 0 };
|
|
1126
|
+
for (let layer = 0; layer < AerialPerspectiveLutLayers; layer++) {
|
|
1127
|
+
engine.bindFramebuffer(renderTarget, undefined, undefined, undefined, true, undefined, layer);
|
|
1128
|
+
engine.clear(clearColor, true, false, false);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1107
1132
|
/**
|
|
1108
1133
|
* Draws the sky view LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
1109
1134
|
*/
|
|
@@ -1147,13 +1172,19 @@ const CreateEffectWrapper = (engine, name, fragmentShader, uniformNames, sampler
|
|
|
1147
1172
|
});
|
|
1148
1173
|
};
|
|
1149
1174
|
const CreateRenderTargetTexture = (name, size, scene, options) => {
|
|
1175
|
+
const caps = scene.getEngine().getCaps();
|
|
1176
|
+
const textureType = caps.textureHalfFloatRender
|
|
1177
|
+
? Constants.TEXTURETYPE_HALF_FLOAT
|
|
1178
|
+
: caps.textureFloatRender
|
|
1179
|
+
? Constants.TEXTURETYPE_FLOAT
|
|
1180
|
+
: Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
1150
1181
|
const rtOptions = {
|
|
1151
1182
|
generateMipMaps: false,
|
|
1152
1183
|
generateDepthBuffer: false,
|
|
1153
1184
|
generateStencilBuffer: false,
|
|
1154
1185
|
gammaSpace: false,
|
|
1155
1186
|
samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,
|
|
1156
|
-
type:
|
|
1187
|
+
type: textureType,
|
|
1157
1188
|
format: Constants.TEXTUREFORMAT_RGBA,
|
|
1158
1189
|
...options,
|
|
1159
1190
|
};
|