@babylonjs/addons 8.46.2 → 8.47.1
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/Shaders/ShadersInclude/atmosphereFunctions.js +7 -11
- package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js.map +1 -1
- package/atmosphere/Shaders/compositeAerialPerspective.fragment.js +1 -2
- package/atmosphere/Shaders/compositeAerialPerspective.fragment.js.map +1 -1
- package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js +2 -4
- package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js.map +1 -1
- package/atmosphere/Shaders/compositeSky.fragment.js +2 -4
- package/atmosphere/Shaders/compositeSky.fragment.js.map +1 -1
- package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js +1 -2
- package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js.map +1 -1
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.d.ts +5 -0
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.js +67 -0
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.js.map +1 -0
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.d.ts +5 -0
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js +56 -0
- package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js.map +1 -0
- package/atmosphere/ShadersWGSL/fullscreenTriangle.vertex.d.ts +6 -0
- package/atmosphere/ShadersWGSL/fullscreenTriangle.vertex.js +31 -0
- package/atmosphere/ShadersWGSL/fullscreenTriangle.vertex.js.map +1 -0
- package/atmosphere/ShadersWGSL/transmittance.fragment.d.ts +8 -0
- package/atmosphere/ShadersWGSL/transmittance.fragment.js +21 -0
- package/atmosphere/ShadersWGSL/transmittance.fragment.js.map +1 -0
- package/atmosphere/atmosphere.d.ts +1 -6
- package/atmosphere/atmosphere.js +46 -51
- package/atmosphere/atmosphere.js.map +1 -1
- package/atmosphere/atmospherePBRMaterialPlugin.d.ts +8 -1
- package/atmosphere/atmospherePBRMaterialPlugin.js +89 -23
- package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -1
- package/atmosphere/transmittanceLut.d.ts +4 -2
- package/atmosphere/transmittanceLut.js +18 -3
- package/atmosphere/transmittanceLut.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js";
|
|
2
|
+
import "@babylonjs/core/ShadersWGSL/ShadersInclude/helperFunctions.js";
|
|
3
|
+
import "../ShadersWGSL/ShadersInclude/atmosphereFunctions.js";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const transmittancePixelShaderWGSL: {
|
|
6
|
+
name: string;
|
|
7
|
+
shader: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
|
|
3
|
+
import "../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js";
|
|
4
|
+
import "@babylonjs/core/ShadersWGSL/ShadersInclude/helperFunctions.js";
|
|
5
|
+
import "../ShadersWGSL/ShadersInclude/atmosphereFunctions.js";
|
|
6
|
+
const name = "transmittancePixelShader";
|
|
7
|
+
const shader = `#define RENDER_TRANSMITTANCE
|
|
8
|
+
#define EXCLUDE_RAY_MARCHING_FUNCTIONS
|
|
9
|
+
#include<atmosphereUboDeclaration>
|
|
10
|
+
#include<helperFunctions>
|
|
11
|
+
#include<atmosphereFunctions>
|
|
12
|
+
varying vUV: vec2f;@fragment
|
|
13
|
+
fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderTransmittance(input.vUV);}
|
|
14
|
+
`;
|
|
15
|
+
// Sideeffect
|
|
16
|
+
if (!ShaderStore.ShadersStoreWGSL[name]) {
|
|
17
|
+
ShaderStore.ShadersStoreWGSL[name] = shader;
|
|
18
|
+
}
|
|
19
|
+
/** @internal */
|
|
20
|
+
export const transmittancePixelShaderWGSL = { name, shader };
|
|
21
|
+
//# sourceMappingURL=transmittance.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transmittance.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/transmittance.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,uEAAyD;AACzD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,MAAM,GAAG;;;;;;;CAOd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"transmittancePixelShader\";\nconst shader = `#define RENDER_TRANSMITTANCE\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#include<atmosphereUboDeclaration>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderTransmittance(input.vUV);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const transmittancePixelShaderWGSL = { name, shader };\n"]}
|
|
@@ -335,11 +335,6 @@ export declare class Atmosphere implements IDisposable {
|
|
|
335
335
|
* @returns The result color.
|
|
336
336
|
*/
|
|
337
337
|
getDiffuseSkyIrradianceToRef: <T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, lightIrradiance: number, result: T) => T;
|
|
338
|
-
/**
|
|
339
|
-
* Creates a new {@link EffectWrapper} for the multiple scattering LUT
|
|
340
|
-
* @returns The newly created {@link EffectWrapper}.
|
|
341
|
-
*/
|
|
342
|
-
private _createMultiScatteringEffectWrapper;
|
|
343
338
|
/**
|
|
344
339
|
* Draws the multiple scattering LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
345
340
|
*/
|
|
@@ -380,7 +375,7 @@ export declare class Atmosphere implements IDisposable {
|
|
|
380
375
|
*/
|
|
381
376
|
bindUniformBufferToEffect(effect: Effect): void;
|
|
382
377
|
/**
|
|
383
|
-
* Updates the atmosphere's uniform buffer.
|
|
378
|
+
* Updates the values in the atmosphere's uniform buffer.
|
|
384
379
|
*/
|
|
385
380
|
updateUniformBuffer(): void;
|
|
386
381
|
/**
|
package/atmosphere/atmosphere.js
CHANGED
|
@@ -40,7 +40,7 @@ export class Atmosphere {
|
|
|
40
40
|
* @returns True if the atmosphere is supported, false otherwise.
|
|
41
41
|
*/
|
|
42
42
|
static IsSupported(engine) {
|
|
43
|
-
return !engine._badOS &&
|
|
43
|
+
return !engine._badOS && (engine.isWebGPU || engine.version >= 2);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Controls the overall brightness of the atmosphere rendering.
|
|
@@ -563,10 +563,7 @@ export class Atmosphere {
|
|
|
563
563
|
this.getDiffuseSkyIrradianceToRef = (directionToLight, pointRadius, pointGeocentricNormal, lightIrradiance, result) => this._diffuseSkyIrradianceLut?.getDiffuseSkyIrradianceToRef(directionToLight, pointRadius, pointGeocentricNormal, lightIrradiance, result) ??
|
|
564
564
|
((result.r = 0), (result.g = 0), (result.b = 0), result);
|
|
565
565
|
const engine = (this._engine = scene.getEngine());
|
|
566
|
-
if (engine.isWebGPU) {
|
|
567
|
-
throw new Error("Atmosphere is not supported on WebGPU.");
|
|
568
|
-
}
|
|
569
|
-
if (engine.version < 2) {
|
|
566
|
+
if (!engine.isWebGPU && engine.version < 2) {
|
|
570
567
|
throw new Error(`Atmosphere is not supported on WebGL ${engine.version}.`);
|
|
571
568
|
}
|
|
572
569
|
this._physicalProperties = options?.physicalProperties ?? new AtmospherePhysicalProperties();
|
|
@@ -615,6 +612,7 @@ export class Atmosphere {
|
|
|
615
612
|
});
|
|
616
613
|
this._transmittanceLut = new TransmittanceLut(this);
|
|
617
614
|
this._multiScatteringLutRenderTarget = CreateRenderTargetTexture("atmo-multiScattering", { width: 32, height: 32 }, scene);
|
|
615
|
+
this._multiScatteringEffectWrapper = CreateMultiScatteringEffectWrapper(engine, this.uniformBuffer, this._groundAlbedo);
|
|
618
616
|
if (options?.isDiffuseSkyIrradianceLutEnabled ?? true) {
|
|
619
617
|
this._diffuseSkyIrradianceLut = new DiffuseSkyIrradianceLut(this);
|
|
620
618
|
}
|
|
@@ -753,32 +751,6 @@ export class Atmosphere {
|
|
|
753
751
|
getClassName() {
|
|
754
752
|
return "Atmosphere";
|
|
755
753
|
}
|
|
756
|
-
/**
|
|
757
|
-
* Creates a new {@link EffectWrapper} for the multiple scattering LUT
|
|
758
|
-
* @returns The newly created {@link EffectWrapper}.
|
|
759
|
-
*/
|
|
760
|
-
_createMultiScatteringEffectWrapper() {
|
|
761
|
-
const engine = this._engine;
|
|
762
|
-
const name = "atmo-multiScattering";
|
|
763
|
-
const ubo = this.uniformBuffer;
|
|
764
|
-
const useUbo = ubo.useUbo;
|
|
765
|
-
const defines = ["#define POSITION_VEC2"];
|
|
766
|
-
if (!this._groundAlbedo.equals(Color3.BlackReadOnly)) {
|
|
767
|
-
defines.push("#define USE_GROUND_ALBEDO");
|
|
768
|
-
}
|
|
769
|
-
return new EffectWrapper({
|
|
770
|
-
engine,
|
|
771
|
-
name,
|
|
772
|
-
vertexShader: "fullscreenTriangle",
|
|
773
|
-
fragmentShader: "multiScattering",
|
|
774
|
-
attributeNames: ["position"],
|
|
775
|
-
uniformNames: ["depth", ...(useUbo ? [] : ubo.getUniformNames())],
|
|
776
|
-
uniformBuffers: useUbo ? [ubo.name] : [],
|
|
777
|
-
samplerNames: ["transmittanceLut"],
|
|
778
|
-
defines,
|
|
779
|
-
useShaderStore: true,
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
754
|
/**
|
|
783
755
|
* Draws the multiple scattering LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
784
756
|
*/
|
|
@@ -810,12 +782,12 @@ export class Atmosphere {
|
|
|
810
782
|
return;
|
|
811
783
|
}
|
|
812
784
|
const engine = this._engine;
|
|
813
|
-
this._aerialPerspectiveCompositorEffectWrapper ?? (this._aerialPerspectiveCompositorEffectWrapper = CreateAerialPerspectiveCompositorEffectWrapper(engine, this.uniformBuffer, this._isAerialPerspectiveLutEnabled, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias));
|
|
785
|
+
const effectWrapper = (this._aerialPerspectiveCompositorEffectWrapper ?? (this._aerialPerspectiveCompositorEffectWrapper = CreateAerialPerspectiveCompositorEffectWrapper(engine, this.uniformBuffer, this._isAerialPerspectiveLutEnabled, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias)));
|
|
814
786
|
const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;
|
|
815
787
|
const multiScatteringLut = this._multiScatteringLutRenderTarget;
|
|
816
788
|
const transmittanceLut = this._transmittanceLut.renderTarget;
|
|
817
789
|
const aerialPerspectiveLut = this._isAerialPerspectiveLutEnabled ? this.aerialPerspectiveLutRenderTarget : null;
|
|
818
|
-
if (!
|
|
790
|
+
if (!effectWrapper.isReady() ||
|
|
819
791
|
!(skyViewLut?.isReady() ?? true) ||
|
|
820
792
|
!multiScatteringLut.isReady() ||
|
|
821
793
|
!transmittanceLut.isReady() ||
|
|
@@ -823,7 +795,7 @@ export class Atmosphere {
|
|
|
823
795
|
!this.depthTexture.isReady()) {
|
|
824
796
|
return;
|
|
825
797
|
}
|
|
826
|
-
DrawEffect(engine, this._effectRenderer,
|
|
798
|
+
DrawEffect(engine, this._effectRenderer, effectWrapper, null, // No render target, it will render to the current buffer.
|
|
827
799
|
(effectRenderer, _, effect) => {
|
|
828
800
|
if (this.depthTexture === null) {
|
|
829
801
|
throw new Error("Depth texture is required for aerial perspective compositor.");
|
|
@@ -864,14 +836,14 @@ export class Atmosphere {
|
|
|
864
836
|
return;
|
|
865
837
|
}
|
|
866
838
|
const engine = this._engine;
|
|
867
|
-
this._skyCompositorEffectWrapper ?? (this._skyCompositorEffectWrapper = CreateSkyCompositorEffectWrapper(engine, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance));
|
|
839
|
+
const effectWrapper = (this._skyCompositorEffectWrapper ?? (this._skyCompositorEffectWrapper = CreateSkyCompositorEffectWrapper(engine, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance)));
|
|
868
840
|
const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;
|
|
869
841
|
const multiScatteringLut = this._multiScatteringLutRenderTarget;
|
|
870
842
|
const transmittanceLut = this._transmittanceLut.renderTarget;
|
|
871
|
-
if (!
|
|
843
|
+
if (!effectWrapper.isReady() || !(skyViewLut?.isReady() ?? true) || !multiScatteringLut.isReady() || !transmittanceLut.isReady()) {
|
|
872
844
|
return;
|
|
873
845
|
}
|
|
874
|
-
DrawEffect(engine, this._effectRenderer,
|
|
846
|
+
DrawEffect(engine, this._effectRenderer, effectWrapper, null, // No render target, it will render to the current buffer.
|
|
875
847
|
(effectRenderer, _, effect) => {
|
|
876
848
|
this.bindUniformBufferToEffect(effect);
|
|
877
849
|
effectRenderer.bindBuffers(effect);
|
|
@@ -902,17 +874,17 @@ export class Atmosphere {
|
|
|
902
874
|
return;
|
|
903
875
|
}
|
|
904
876
|
const engine = this._engine;
|
|
905
|
-
this._globeAtmosphereCompositorEffectWrapper ?? (this._globeAtmosphereCompositorEffectWrapper = CreateGlobeAtmosphereCompositorEffectWrapper(engine, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, this.depthTexture !== null));
|
|
877
|
+
const effectWrapper = (this._globeAtmosphereCompositorEffectWrapper ?? (this._globeAtmosphereCompositorEffectWrapper = CreateGlobeAtmosphereCompositorEffectWrapper(engine, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, this.depthTexture !== null)));
|
|
906
878
|
const skyViewLut = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null;
|
|
907
879
|
const multiScatteringLut = this._multiScatteringLutRenderTarget;
|
|
908
880
|
const transmittanceLut = this._transmittanceLut.renderTarget;
|
|
909
|
-
if (!
|
|
881
|
+
if (!effectWrapper.isReady() || !(skyViewLut?.isReady() ?? true) || !multiScatteringLut.isReady() || !transmittanceLut.isReady()) {
|
|
910
882
|
return;
|
|
911
883
|
}
|
|
912
884
|
if (this.depthTexture !== null && !this.depthTexture.isReady()) {
|
|
913
885
|
return;
|
|
914
886
|
}
|
|
915
|
-
DrawEffect(engine, this._effectRenderer,
|
|
887
|
+
DrawEffect(engine, this._effectRenderer, effectWrapper, null, // No render target, it will render to the current buffer.
|
|
916
888
|
(effectRenderer, _, effect) => {
|
|
917
889
|
this.bindUniformBufferToEffect(effect);
|
|
918
890
|
effectRenderer.bindBuffers(effect);
|
|
@@ -1022,7 +994,7 @@ export class Atmosphere {
|
|
|
1022
994
|
this._diffuseSkyIrradianceLut?.markDirty();
|
|
1023
995
|
}
|
|
1024
996
|
if (!this._transmittanceLut.isDirty && !this._hasRenderedMultiScatteringLut) {
|
|
1025
|
-
this._multiScatteringEffectWrapper ?? (this._multiScatteringEffectWrapper = this.
|
|
997
|
+
this._multiScatteringEffectWrapper ?? (this._multiScatteringEffectWrapper = CreateMultiScatteringEffectWrapper(this._engine, this.uniformBuffer, this._groundAlbedo));
|
|
1026
998
|
if (this._multiScatteringEffectWrapper?.isReady() && this._multiScatteringLutRenderTarget?.isReady()) {
|
|
1027
999
|
this._drawMultiScatteringLut();
|
|
1028
1000
|
this._hasRenderedMultiScatteringLut = true;
|
|
@@ -1038,17 +1010,18 @@ export class Atmosphere {
|
|
|
1038
1010
|
*/
|
|
1039
1011
|
bindUniformBufferToEffect(effect) {
|
|
1040
1012
|
const uniformBuffer = this.uniformBuffer;
|
|
1041
|
-
const
|
|
1042
|
-
uniformBuffer.
|
|
1013
|
+
const isWGSL = effect.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
|
|
1014
|
+
const blockName = isWGSL ? "atmosphere" : uniformBuffer.name;
|
|
1015
|
+
uniformBuffer.bindToEffect(effect, blockName);
|
|
1043
1016
|
if (uniformBuffer.useUbo) {
|
|
1044
|
-
uniformBuffer.
|
|
1017
|
+
uniformBuffer.update();
|
|
1045
1018
|
}
|
|
1046
1019
|
else {
|
|
1047
1020
|
this.updateUniformBuffer();
|
|
1048
1021
|
}
|
|
1049
1022
|
}
|
|
1050
1023
|
/**
|
|
1051
|
-
* Updates the atmosphere's uniform buffer.
|
|
1024
|
+
* Updates the values in the atmosphere's uniform buffer.
|
|
1052
1025
|
*/
|
|
1053
1026
|
updateUniformBuffer() {
|
|
1054
1027
|
const physicalProperties = this._physicalProperties;
|
|
@@ -1099,7 +1072,6 @@ export class Atmosphere {
|
|
|
1099
1072
|
ubo.updateFloat("originHeight", this._originHeight);
|
|
1100
1073
|
ubo.updateFloat("sinCameraAtmosphereHorizonAngleFromNadir", cameraAtmosphereVariables.sinCameraAtmosphereHorizonAngleFromNadir);
|
|
1101
1074
|
ubo.updateFloat("atmosphereExposure", this._exposure);
|
|
1102
|
-
ubo.update();
|
|
1103
1075
|
}
|
|
1104
1076
|
/**
|
|
1105
1077
|
* Draws the aerial perspective LUT using {@link EffectWrapper} and {@link EffectRenderer}.
|
|
@@ -1172,6 +1144,26 @@ const CreateEffectWrapper = (engine, name, fragmentShader, uniformNames, sampler
|
|
|
1172
1144
|
useShaderStore: true,
|
|
1173
1145
|
});
|
|
1174
1146
|
};
|
|
1147
|
+
const CreateMultiScatteringEffectWrapper = (engine, uniformBuffer, groundAlbedo) => {
|
|
1148
|
+
const name = "atmo-multiScattering";
|
|
1149
|
+
const useUbo = uniformBuffer.useUbo;
|
|
1150
|
+
const defines = ["#define POSITION_VEC2"];
|
|
1151
|
+
if (!groundAlbedo.equals(Color3.BlackReadOnly)) {
|
|
1152
|
+
defines.push("#define USE_GROUND_ALBEDO");
|
|
1153
|
+
}
|
|
1154
|
+
return new EffectWrapper({
|
|
1155
|
+
engine,
|
|
1156
|
+
name,
|
|
1157
|
+
vertexShader: "fullscreenTriangle",
|
|
1158
|
+
fragmentShader: "multiScattering",
|
|
1159
|
+
attributeNames: ["position"],
|
|
1160
|
+
uniformNames: ["depth", ...(useUbo ? [] : uniformBuffer.getUniformNames())],
|
|
1161
|
+
uniformBuffers: useUbo ? [uniformBuffer.name] : [],
|
|
1162
|
+
samplerNames: ["transmittanceLut"],
|
|
1163
|
+
defines,
|
|
1164
|
+
useShaderStore: true,
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1175
1167
|
const CreateRenderTargetTexture = (name, size, scene, options) => {
|
|
1176
1168
|
const caps = scene.getEngine().getCaps();
|
|
1177
1169
|
const textureType = caps.textureHalfFloatRender
|
|
@@ -1229,11 +1221,14 @@ const DrawEffect = (engine, effectRenderer, effectWrapper, renderTarget, drawCal
|
|
|
1229
1221
|
effectRenderer.saveStates();
|
|
1230
1222
|
effectRenderer.setViewport();
|
|
1231
1223
|
effectRenderer.applyEffectWrapper(effectWrapper, depthTest); // Note, stencil is false by default.
|
|
1224
|
+
const currentCull = engine.depthCullingState.cull;
|
|
1225
|
+
engine.depthCullingState.cull = false;
|
|
1232
1226
|
const effect = effectWrapper.effect;
|
|
1233
1227
|
effect.setFloat("depth", depth);
|
|
1234
1228
|
// Call the specific drawing logic.
|
|
1235
1229
|
drawCallback(effectRenderer, renderTarget?.renderTarget, effect, engine);
|
|
1236
1230
|
// Restore state (order matters!)
|
|
1231
|
+
engine.depthCullingState.cull = currentCull;
|
|
1237
1232
|
engine.setAlphaMode(currentAlphaMode);
|
|
1238
1233
|
if (currentDepthWrite !== undefined) {
|
|
1239
1234
|
engine.setDepthWrite(currentDepthWrite);
|
|
@@ -1258,7 +1253,7 @@ const DrawEffect = (engine, effectRenderer, effectWrapper, renderTarget, drawCal
|
|
|
1258
1253
|
*/
|
|
1259
1254
|
const CreateSkyCompositorEffectWrapper = (engine, uniformBuffer, isSkyViewLutEnabled, isLinearSpaceComposition, applyApproximateTransmittance) => {
|
|
1260
1255
|
const useUbo = uniformBuffer.useUbo;
|
|
1261
|
-
const defines = ["COMPUTE_WORLD_RAY"];
|
|
1256
|
+
const defines = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"];
|
|
1262
1257
|
if (isSkyViewLutEnabled) {
|
|
1263
1258
|
defines.push("USE_SKY_VIEW_LUT");
|
|
1264
1259
|
}
|
|
@@ -1277,7 +1272,7 @@ const CreateSkyCompositorEffectWrapper = (engine, uniformBuffer, isSkyViewLutEna
|
|
|
1277
1272
|
* @param uniformBuffer - The uniform buffer to use.
|
|
1278
1273
|
* @returns The created EffectWrapper.
|
|
1279
1274
|
*/
|
|
1280
|
-
const CreateAerialPerspectiveEffectWrapper = (engine, uniformBuffer) => CreateEffectWrapper(engine, "atmo-aerialPerspective", "aerialPerspective", ["layerIdx", "depth", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())], ["transmittanceLut", "multiScatteringLut"], uniformBuffer.useUbo ? [uniformBuffer.name] : [], ["COMPUTE_WORLD_RAY"]);
|
|
1275
|
+
const CreateAerialPerspectiveEffectWrapper = (engine, uniformBuffer) => CreateEffectWrapper(engine, "atmo-aerialPerspective", "aerialPerspective", ["layerIdx", "depth", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())], ["transmittanceLut", "multiScatteringLut"], uniformBuffer.useUbo ? [uniformBuffer.name] : [], ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]);
|
|
1281
1276
|
/**
|
|
1282
1277
|
* Creates an EffectWrapper for the aerial perspective compositor.
|
|
1283
1278
|
* @param engine - The engine to use.
|
|
@@ -1292,7 +1287,7 @@ const CreateAerialPerspectiveEffectWrapper = (engine, uniformBuffer) => CreateEf
|
|
|
1292
1287
|
*/
|
|
1293
1288
|
const CreateAerialPerspectiveCompositorEffectWrapper = (engine, uniformBuffer, isAerialPerspectiveLutEnabled, isSkyViewLutEnabled, isLinearSpaceComposition, applyApproximateTransmittance, aerialPerspectiveIntensity, aerialPerspectiveRadianceBias) => {
|
|
1294
1289
|
const useUbo = uniformBuffer.useUbo;
|
|
1295
|
-
const defines = ["COMPUTE_WORLD_RAY"];
|
|
1290
|
+
const defines = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"];
|
|
1296
1291
|
if (isAerialPerspectiveLutEnabled) {
|
|
1297
1292
|
defines.push("USE_AERIAL_PERSPECTIVE_LUT");
|
|
1298
1293
|
}
|
|
@@ -1334,7 +1329,7 @@ const CreateAerialPerspectiveCompositorEffectWrapper = (engine, uniformBuffer, i
|
|
|
1334
1329
|
*/
|
|
1335
1330
|
const CreateGlobeAtmosphereCompositorEffectWrapper = (engine, uniformBuffer, isSkyViewLutEnabled, isLinearSpaceComposition, applyApproximateTransmittance, aerialPerspectiveIntensity, aerialPerspectiveRadianceBias, hasDepthTexture) => {
|
|
1336
1331
|
const useUbo = uniformBuffer.useUbo;
|
|
1337
|
-
const defines = ["COMPUTE_WORLD_RAY"];
|
|
1332
|
+
const defines = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"];
|
|
1338
1333
|
if (isSkyViewLutEnabled) {
|
|
1339
1334
|
defines.push("USE_SKY_VIEW_LUT");
|
|
1340
1335
|
}
|
|
@@ -1368,5 +1363,5 @@ const CreateGlobeAtmosphereCompositorEffectWrapper = (engine, uniformBuffer, isS
|
|
|
1368
1363
|
* @param uniformBuffer - The uniform buffer to use.
|
|
1369
1364
|
* @returns The created EffectWrapper.
|
|
1370
1365
|
*/
|
|
1371
|
-
const CreateSkyViewEffectWrapper = (engine, uniformBuffer) => CreateEffectWrapper(engine, "atmo-skyView", "skyView", ["depth", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())], ["transmittanceLut", "multiScatteringLut"], uniformBuffer.useUbo ? [uniformBuffer.name] : []);
|
|
1366
|
+
const CreateSkyViewEffectWrapper = (engine, uniformBuffer) => CreateEffectWrapper(engine, "atmo-skyView", "skyView", ["depth", ...(uniformBuffer.useUbo ? [] : uniformBuffer.getUniformNames())], ["transmittanceLut", "multiScatteringLut"], uniformBuffer.useUbo ? [uniformBuffer.name] : [], ["POSITION_VEC2"]);
|
|
1372
1367
|
//# sourceMappingURL=atmosphere.js.map
|