@onerjs/addons 8.25.4 → 8.25.6

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.
Files changed (81) hide show
  1. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.d.ts +5 -0
  2. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js +12 -0
  3. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js.map +1 -0
  4. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.d.ts +6 -0
  5. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js +234 -0
  6. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js.map +1 -0
  7. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.d.ts +5 -0
  8. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js +12 -0
  9. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js.map +1 -0
  10. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.d.ts +5 -0
  11. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.js +12 -0
  12. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.js.map +1 -0
  13. package/atmosphere/Shaders/ShadersInclude/depthFunctions.d.ts +5 -0
  14. package/atmosphere/Shaders/ShadersInclude/depthFunctions.js +19 -0
  15. package/atmosphere/Shaders/ShadersInclude/depthFunctions.js.map +1 -0
  16. package/atmosphere/Shaders/aerialPerspective.fragment.d.ts +9 -0
  17. package/atmosphere/Shaders/aerialPerspective.fragment.js +25 -0
  18. package/atmosphere/Shaders/aerialPerspective.fragment.js.map +1 -0
  19. package/atmosphere/Shaders/compositeAerialPerspective.fragment.d.ts +10 -0
  20. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js +72 -0
  21. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js.map +1 -0
  22. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.d.ts +10 -0
  23. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js +96 -0
  24. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js.map +1 -0
  25. package/atmosphere/Shaders/compositeSky.fragment.d.ts +10 -0
  26. package/atmosphere/Shaders/compositeSky.fragment.js +75 -0
  27. package/atmosphere/Shaders/compositeSky.fragment.js.map +1 -0
  28. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.d.ts +13 -0
  29. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js +49 -0
  30. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js.map +1 -0
  31. package/atmosphere/Shaders/fullscreenTriangle.vertex.d.ts +7 -0
  32. package/atmosphere/Shaders/fullscreenTriangle.vertex.js +31 -0
  33. package/atmosphere/Shaders/fullscreenTriangle.vertex.js.map +1 -0
  34. package/atmosphere/Shaders/multiScattering.fragment.d.ts +9 -0
  35. package/atmosphere/Shaders/multiScattering.fragment.js +21 -0
  36. package/atmosphere/Shaders/multiScattering.fragment.js.map +1 -0
  37. package/atmosphere/Shaders/skyView.fragment.d.ts +9 -0
  38. package/atmosphere/Shaders/skyView.fragment.js +20 -0
  39. package/atmosphere/Shaders/skyView.fragment.js.map +1 -0
  40. package/atmosphere/Shaders/transmittance.fragment.d.ts +9 -0
  41. package/atmosphere/Shaders/transmittance.fragment.js +20 -0
  42. package/atmosphere/Shaders/transmittance.fragment.js.map +1 -0
  43. package/atmosphere/atmosphere.d.ts +418 -0
  44. package/atmosphere/atmosphere.js +1446 -0
  45. package/atmosphere/atmosphere.js.map +1 -0
  46. package/atmosphere/atmosphereOptions.d.ts +135 -0
  47. package/atmosphere/atmosphereOptions.js +4 -0
  48. package/atmosphere/atmosphereOptions.js.map +1 -0
  49. package/atmosphere/atmospherePBRMaterialPlugin.d.ts +72 -0
  50. package/atmosphere/atmospherePBRMaterialPlugin.js +230 -0
  51. package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -0
  52. package/atmosphere/atmospherePerCameraVariables.d.ts +102 -0
  53. package/atmosphere/atmospherePerCameraVariables.js +189 -0
  54. package/atmosphere/atmospherePerCameraVariables.js.map +1 -0
  55. package/atmosphere/atmospherePhysicalProperties.d.ts +154 -0
  56. package/atmosphere/atmospherePhysicalProperties.js +305 -0
  57. package/atmosphere/atmospherePhysicalProperties.js.map +1 -0
  58. package/atmosphere/atmospherePhysicalPropertiesOptions.d.ts +52 -0
  59. package/atmosphere/atmospherePhysicalPropertiesOptions.js +4 -0
  60. package/atmosphere/atmospherePhysicalPropertiesOptions.js.map +1 -0
  61. package/atmosphere/diffuseSkyIrradianceLut.d.ts +63 -0
  62. package/atmosphere/diffuseSkyIrradianceLut.js +199 -0
  63. package/atmosphere/diffuseSkyIrradianceLut.js.map +1 -0
  64. package/atmosphere/index.d.ts +6 -0
  65. package/atmosphere/index.js +9 -0
  66. package/atmosphere/index.js.map +1 -0
  67. package/atmosphere/sampling.d.ts +15 -0
  68. package/atmosphere/sampling.js +89 -0
  69. package/atmosphere/sampling.js.map +1 -0
  70. package/atmosphere/test/unit/sampling.test.d.ts +1 -0
  71. package/atmosphere/test/unit/sampling.test.js +77 -0
  72. package/atmosphere/test/unit/sampling.test.js.map +1 -0
  73. package/atmosphere/transmittanceLut.d.ts +68 -0
  74. package/atmosphere/transmittanceLut.js +207 -0
  75. package/atmosphere/transmittanceLut.js.map +1 -0
  76. package/index.d.ts +1 -0
  77. package/index.js +1 -0
  78. package/index.js.map +1 -1
  79. package/msdfText/paragraphOptions.d.ts +1 -1
  80. package/msdfText/paragraphOptions.js.map +1 -1
  81. package/package.json +2 -2
@@ -0,0 +1,207 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // MIT License
3
+ import { Clamp, SmoothStep } from "@onerjs/core/Maths/math.scalar.functions.js";
4
+ import { Constants } from "@onerjs/core/Engines/constants.js";
5
+ import { EffectRenderer, EffectWrapper } from "@onerjs/core/Materials/effectRenderer.js";
6
+ import { FromHalfFloat } from "@onerjs/core/Misc/textureTools.js";
7
+ import { Observable } from "@onerjs/core/Misc/observable.js";
8
+ import { RenderTargetTexture } from "@onerjs/core/Materials/Textures/renderTargetTexture.js";
9
+ import { Sample2DRgbaToRef } from "./sampling.js";
10
+ import "./Shaders/fullscreenTriangle.vertex.js";
11
+ import "./Shaders/transmittance.fragment.js";
12
+ const LutWidthPx = 256;
13
+ const LutHeightPx = 64;
14
+ const EffectiveDomainInUVSpace = { x: (LutWidthPx - 1.0) / LutWidthPx, y: (LutHeightPx - 1.0) / LutHeightPx };
15
+ const HalfTexelSize = { x: 0.5 / LutWidthPx, y: 0.5 / LutHeightPx };
16
+ const TransmittanceHorizonRange = 2.0 * HalfTexelSize.x;
17
+ const TransmittanceMaxUnoccludedU = 1.0 - 0.5 * TransmittanceHorizonRange;
18
+ const UseHalfFloat = false;
19
+ // Temporary storage.
20
+ const Uv = { x: Number.NaN, y: Number.NaN };
21
+ const LightColorTemp = { r: Number.NaN, g: Number.NaN, b: Number.NaN };
22
+ const DirectionToLightTemp = { x: Number.NaN, y: Number.NaN, z: Number.NaN };
23
+ const Color4Temp = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN };
24
+ const ComputeLutUVToRef = (properties, radius, cosAngleLightToZenith, uv) => {
25
+ const radiusSquared = radius * radius;
26
+ const distanceToHorizon = Math.sqrt(Math.max(0.0, radiusSquared - properties.planetRadiusSquared));
27
+ const cosAngleLightToZenithSq = cosAngleLightToZenith * cosAngleLightToZenith;
28
+ const discriminant = radiusSquared * (cosAngleLightToZenithSq - 1.0) + properties.atmosphereRadiusSquared;
29
+ const distanceToAtmosphereEdge = Math.max(0.0, -radius * cosAngleLightToZenith + Math.sqrt(Math.max(0.0, discriminant)));
30
+ const minDistanceToAtmosphereEdge = Math.max(0.0, properties.atmosphereRadius - radius);
31
+ const maxDistanceToAtmosphereEdge = distanceToHorizon + properties.horizonDistanceToAtmosphereEdge;
32
+ const cosAngleLightToZenithCoordinate = (distanceToAtmosphereEdge - minDistanceToAtmosphereEdge) / Math.max(0.000001, maxDistanceToAtmosphereEdge - minDistanceToAtmosphereEdge);
33
+ const distanceToHorizonCoordinate = distanceToHorizon / Math.max(0.000001, properties.horizonDistanceToAtmosphereEdge);
34
+ // Unit to UV.
35
+ uv.x = EffectiveDomainInUVSpace.x * cosAngleLightToZenithCoordinate + HalfTexelSize.x;
36
+ uv.y = EffectiveDomainInUVSpace.y * distanceToHorizonCoordinate + HalfTexelSize.y;
37
+ };
38
+ const SampleLutToRef = (properties, lutData, positionDistanceToOrigin, cosAngleLightToZenith, result) => {
39
+ if (positionDistanceToOrigin > properties.atmosphereRadius) {
40
+ result.r = result.g = result.b = result.a = 1.0;
41
+ return;
42
+ }
43
+ ComputeLutUVToRef(properties, positionDistanceToOrigin, cosAngleLightToZenith, Uv);
44
+ Sample2DRgbaToRef(Uv.x, Uv.y, LutWidthPx, LutHeightPx, lutData, result, UseHalfFloat ? FromHalfFloat : (value) => value / 255.0);
45
+ const weight = Clamp(SmoothStep(1.0, 0.0, Clamp((Uv.x - TransmittanceMaxUnoccludedU) / TransmittanceHorizonRange)));
46
+ result.r *= weight;
47
+ result.g *= weight;
48
+ result.b *= weight;
49
+ result.a *= weight;
50
+ };
51
+ /**
52
+ * The transmittance LUT can be used to get the radiance from an external light source arriving a given point, accounting for atmospheric scattering.
53
+ */
54
+ export class TransmittanceLut {
55
+ /**
56
+ * True if the LUT has been rendered.
57
+ */
58
+ get isDirty() {
59
+ return this._isDirty;
60
+ }
61
+ /**
62
+ * The render target that contains the transmittance LUT.
63
+ * @throws if the LUT has been disposed.
64
+ */
65
+ get renderTarget() {
66
+ if (this._isDisposed || this._renderTarget === null) {
67
+ throw new Error();
68
+ }
69
+ return this._renderTarget;
70
+ }
71
+ /**
72
+ * Constructs the {@link TransmittanceLut}.
73
+ * @param atmosphere - The atmosphere that owns this LUT.
74
+ */
75
+ constructor(atmosphere) {
76
+ /**
77
+ * Listen to this observer to know when the LUT data has been updated.
78
+ * This is typically infrequent (once at startup), but also happens whenever the atmosphere's properties change.
79
+ */
80
+ this.onUpdatedObservable = new Observable();
81
+ this._lutData = new Uint8Array(0);
82
+ this._isDirty = true;
83
+ this._isDisposed = false;
84
+ this._atmosphere = atmosphere;
85
+ const scene = this._atmosphere.scene;
86
+ const engine = scene.getEngine();
87
+ const name = "atmo-transmittance";
88
+ const renderTarget = (this._renderTarget = new RenderTargetTexture(name, { width: LutWidthPx, height: LutHeightPx }, scene, {
89
+ type: UseHalfFloat ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE,
90
+ samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,
91
+ generateDepthBuffer: false,
92
+ gammaSpace: false,
93
+ }));
94
+ renderTarget.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;
95
+ renderTarget.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;
96
+ renderTarget.anisotropicFilteringLevel = 1;
97
+ renderTarget.skipInitialClear = true;
98
+ const useUbo = this._atmosphere.uniformBuffer.useUbo;
99
+ this._effectWrapper = new EffectWrapper({
100
+ engine,
101
+ name,
102
+ vertexShader: "fullscreenTriangle",
103
+ fragmentShader: "transmittance",
104
+ attributeNames: ["position"],
105
+ uniformNames: ["depth", ...(useUbo ? [] : this._atmosphere.uniformBuffer.getUniformNames())],
106
+ uniformBuffers: useUbo ? [this._atmosphere.uniformBuffer.name] : [],
107
+ defines: ["#define POSITION_VEC2"],
108
+ useShaderStore: true,
109
+ });
110
+ this._effectRenderer = new EffectRenderer(engine, {
111
+ // Full screen triangle.
112
+ indices: [0, 2, 1],
113
+ positions: [-1, -1, -1, 3, 3, -1],
114
+ });
115
+ }
116
+ /**
117
+ * Gets the transmittance of an external light through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.
118
+ * The result is always a linear space color.
119
+ * @param directionToLight - The direction to the light source.
120
+ * @param pointRadius - The distance from the origin to the point.
121
+ * @param pointGeocentricNormal - The normal of the point.
122
+ * @param result - The color to write the result to.
123
+ * @returns The result color.
124
+ */
125
+ getTransmittedColorToRef(directionToLight, pointRadius, pointGeocentricNormal, result) {
126
+ if (this._lutData[0] !== undefined) {
127
+ const cosAngleLightToZenith = directionToLight.x * pointGeocentricNormal.x + directionToLight.y * pointGeocentricNormal.y + directionToLight.z * pointGeocentricNormal.z;
128
+ SampleLutToRef(this._atmosphere.physicalProperties, this._lutData, pointRadius, cosAngleLightToZenith, Color4Temp);
129
+ result.r = Color4Temp.r;
130
+ result.g = Color4Temp.g;
131
+ result.b = Color4Temp.b;
132
+ }
133
+ else {
134
+ // Fallback.
135
+ result.r = result.g = result.b = 1.0;
136
+ }
137
+ return result;
138
+ }
139
+ /**
140
+ * Derives light color from the transmittance at a point specified by its distance to the planet center and its geocentric normal.
141
+ * @param light - The light to update.
142
+ * @param pointRadius - The distance from the origin to the point.
143
+ * @param pointGeocentricNormal - The normal of the point.
144
+ */
145
+ updateLightParameters(light, pointRadius, pointGeocentricNormal) {
146
+ const lightDirection = light.direction;
147
+ DirectionToLightTemp.x = -lightDirection.x;
148
+ DirectionToLightTemp.y = -lightDirection.y;
149
+ DirectionToLightTemp.z = -lightDirection.z;
150
+ this.getTransmittedColorToRef(DirectionToLightTemp, pointRadius, pointGeocentricNormal, LightColorTemp);
151
+ light.diffuse.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);
152
+ light.specular.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);
153
+ }
154
+ /**
155
+ * Renders the LUT if needed.
156
+ * @returns true if the LUT was rendered.
157
+ */
158
+ render() {
159
+ // Only need to render the LUT once.
160
+ const effectWrapper = this._effectWrapper;
161
+ if (!this._isDirty || !effectWrapper?.isReady() || !this._renderTarget?.isReady()) {
162
+ return false;
163
+ }
164
+ const engine = this._atmosphere.scene.getEngine();
165
+ engine.bindFramebuffer(this.renderTarget.renderTarget, undefined, undefined, undefined, true);
166
+ const effectRenderer = this._effectRenderer;
167
+ effectRenderer.applyEffectWrapper(effectWrapper);
168
+ effectRenderer.saveStates();
169
+ effectRenderer.setViewport();
170
+ const effect = effectWrapper.effect;
171
+ effectRenderer.bindBuffers(effect);
172
+ this._atmosphere.bindUniformBufferToEffect(effect);
173
+ effect.setFloat("depth", 0);
174
+ effectRenderer.draw();
175
+ effectRenderer.restoreStates();
176
+ engine.restoreDefaultFramebuffer();
177
+ this._isDirty = false;
178
+ // eslint-disable-next-line github/no-then
179
+ void this.renderTarget.readPixels(0, 0, undefined, undefined, UseHalfFloat /* noDataConversion */)?.then((value) => {
180
+ if (this._isDisposed) {
181
+ return;
182
+ }
183
+ this._lutData = value;
184
+ this.onUpdatedObservable.notifyObservers();
185
+ });
186
+ return true;
187
+ }
188
+ /**
189
+ * Marks the LUT as needing to be rendered.
190
+ */
191
+ markDirty() {
192
+ this._isDirty = true;
193
+ }
194
+ /**
195
+ * Disposes the LUT and its resources.
196
+ */
197
+ dispose() {
198
+ this._renderTarget?.dispose();
199
+ this._renderTarget = null;
200
+ this._effectWrapper?.dispose();
201
+ this._effectWrapper = null;
202
+ this._effectRenderer?.dispose();
203
+ this._effectRenderer = null;
204
+ this._isDisposed = true;
205
+ }
206
+ }
207
+ //# sourceMappingURL=transmittanceLut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transmittanceLut.js","sourceRoot":"","sources":["../../../../dev/addons/src/atmosphere/transmittanceLut.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,cAAc;AAId,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,oDAAyC;AACrE,OAAO,EAAE,SAAS,EAAE,0CAA+B;AAEnD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,iDAAsC;AAC9E,OAAO,EAAE,aAAa,EAAE,0CAA+B;AAGvD,OAAO,EAAE,UAAU,EAAE,wCAA6B;AAClD,OAAO,EAAE,mBAAmB,EAAE,+DAAoD;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC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,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;CACJ","sourcesContent":["// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Atmosphere } from \"./atmosphere\";\r\nimport type { AtmospherePhysicalProperties } from \"./atmospherePhysicalProperties\";\r\nimport { Clamp, SmoothStep } from \"core/Maths/math.scalar.functions\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { EffectRenderer, EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport { FromHalfFloat } from \"core/Misc/textureTools\";\r\nimport type { IColor3Like, IColor4Like, IVector2Like, IVector3Like } from \"core/Maths/math.like\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { Sample2DRgbaToRef } from \"./sampling\";\r\nimport \"./Shaders/fullscreenTriangle.vertex\";\r\nimport \"./Shaders/transmittance.fragment\";\r\n\r\nconst LutWidthPx = 256;\r\nconst LutHeightPx = 64;\r\nconst EffectiveDomainInUVSpace = { x: (LutWidthPx - 1.0) / LutWidthPx, y: (LutHeightPx - 1.0) / LutHeightPx };\r\nconst HalfTexelSize = { x: 0.5 / LutWidthPx, y: 0.5 / LutHeightPx };\r\nconst TransmittanceHorizonRange = 2.0 * HalfTexelSize.x;\r\nconst TransmittanceMaxUnoccludedU = 1.0 - 0.5 * TransmittanceHorizonRange;\r\n\r\nconst UseHalfFloat = false;\r\n\r\n// Temporary storage.\r\nconst Uv = { x: Number.NaN, y: Number.NaN } as IVector2Like;\r\nconst LightColorTemp = { r: Number.NaN, g: Number.NaN, b: Number.NaN } as IColor3Like;\r\nconst DirectionToLightTemp = { x: Number.NaN, y: Number.NaN, z: Number.NaN } as IVector3Like;\r\nconst Color4Temp = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN } as IColor4Like;\r\n\r\nconst ComputeLutUVToRef = (properties: AtmospherePhysicalProperties, radius: number, cosAngleLightToZenith: number, uv: IVector2Like): void => {\r\n const radiusSquared = radius * radius;\r\n const distanceToHorizon = Math.sqrt(Math.max(0.0, radiusSquared - properties.planetRadiusSquared));\r\n\r\n const cosAngleLightToZenithSq = cosAngleLightToZenith * cosAngleLightToZenith;\r\n const discriminant = radiusSquared * (cosAngleLightToZenithSq - 1.0) + properties.atmosphereRadiusSquared;\r\n const distanceToAtmosphereEdge = Math.max(0.0, -radius * cosAngleLightToZenith + Math.sqrt(Math.max(0.0, discriminant)));\r\n\r\n const minDistanceToAtmosphereEdge = Math.max(0.0, properties.atmosphereRadius - radius);\r\n const maxDistanceToAtmosphereEdge = distanceToHorizon + properties.horizonDistanceToAtmosphereEdge;\r\n const cosAngleLightToZenithCoordinate =\r\n (distanceToAtmosphereEdge - minDistanceToAtmosphereEdge) / Math.max(0.000001, maxDistanceToAtmosphereEdge - minDistanceToAtmosphereEdge);\r\n const distanceToHorizonCoordinate = distanceToHorizon / Math.max(0.000001, properties.horizonDistanceToAtmosphereEdge);\r\n\r\n // Unit to UV.\r\n uv.x = EffectiveDomainInUVSpace.x * cosAngleLightToZenithCoordinate + HalfTexelSize.x;\r\n uv.y = EffectiveDomainInUVSpace.y * distanceToHorizonCoordinate + HalfTexelSize.y;\r\n};\r\n\r\nconst SampleLutToRef = (\r\n properties: AtmospherePhysicalProperties,\r\n lutData: Uint8Array | Uint16Array,\r\n positionDistanceToOrigin: number,\r\n cosAngleLightToZenith: number,\r\n result: IColor4Like\r\n): void => {\r\n if (positionDistanceToOrigin > properties.atmosphereRadius) {\r\n result.r = result.g = result.b = result.a = 1.0;\r\n return;\r\n }\r\n\r\n ComputeLutUVToRef(properties, positionDistanceToOrigin, cosAngleLightToZenith, Uv);\r\n Sample2DRgbaToRef(Uv.x, Uv.y, LutWidthPx, LutHeightPx, lutData, result, UseHalfFloat ? FromHalfFloat : (value) => value / 255.0);\r\n\r\n const weight = Clamp(SmoothStep(1.0, 0.0, Clamp((Uv.x - TransmittanceMaxUnoccludedU) / TransmittanceHorizonRange)));\r\n result.r *= weight;\r\n result.g *= weight;\r\n result.b *= weight;\r\n result.a *= weight;\r\n};\r\n\r\n/**\r\n * The transmittance LUT can be used to get the radiance from an external light source arriving a given point, accounting for atmospheric scattering.\r\n */\r\nexport class TransmittanceLut {\r\n /**\r\n * Listen to this observer to know when the LUT data has been updated.\r\n * This is typically infrequent (once at startup), but also happens whenever the atmosphere's properties change.\r\n */\r\n public readonly onUpdatedObservable = new Observable<void>();\r\n\r\n private readonly _atmosphere: Atmosphere;\r\n private _lutData: Uint8Array | Uint16Array = new Uint8Array(0);\r\n private _renderTarget: Nullable<RenderTargetTexture>;\r\n private _effectWrapper: Nullable<EffectWrapper>;\r\n private _effectRenderer: Nullable<EffectRenderer>;\r\n private _isDirty = true;\r\n private _isDisposed = false;\r\n\r\n /**\r\n * True if the LUT has been rendered.\r\n */\r\n public get isDirty(): boolean {\r\n return this._isDirty;\r\n }\r\n\r\n /**\r\n * The render target that contains the transmittance LUT.\r\n * @throws if the LUT has been disposed.\r\n */\r\n public get renderTarget(): RenderTargetTexture {\r\n if (this._isDisposed || this._renderTarget === null) {\r\n throw new Error();\r\n }\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Constructs the {@link TransmittanceLut}.\r\n * @param atmosphere - The atmosphere that owns this LUT.\r\n */\r\n constructor(atmosphere: Atmosphere) {\r\n this._atmosphere = atmosphere;\r\n\r\n const scene = this._atmosphere.scene;\r\n const engine = scene.getEngine();\r\n\r\n const name = \"atmo-transmittance\";\r\n const renderTarget = (this._renderTarget = new RenderTargetTexture(name, { width: LutWidthPx, height: LutHeightPx }, scene, {\r\n type: UseHalfFloat ? Constants.TEXTURETYPE_HALF_FLOAT : Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n generateDepthBuffer: false,\r\n gammaSpace: false,\r\n }));\r\n renderTarget.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n renderTarget.anisotropicFilteringLevel = 1;\r\n renderTarget.skipInitialClear = true;\r\n\r\n const useUbo = this._atmosphere.uniformBuffer.useUbo;\r\n this._effectWrapper = new EffectWrapper({\r\n engine,\r\n name,\r\n vertexShader: \"fullscreenTriangle\",\r\n fragmentShader: \"transmittance\",\r\n attributeNames: [\"position\"],\r\n uniformNames: [\"depth\", ...(useUbo ? [] : this._atmosphere.uniformBuffer.getUniformNames())],\r\n uniformBuffers: useUbo ? [this._atmosphere.uniformBuffer.name] : [],\r\n defines: [\"#define POSITION_VEC2\"],\r\n useShaderStore: true,\r\n });\r\n\r\n this._effectRenderer = new EffectRenderer(engine, {\r\n // Full screen triangle.\r\n indices: [0, 2, 1],\r\n positions: [-1, -1, -1, 3, 3, -1],\r\n });\r\n }\r\n\r\n /**\r\n * Gets the transmittance of an external light through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.\r\n * The result is always a linear space color.\r\n * @param directionToLight - The direction to the light source.\r\n * @param pointRadius - The distance from the origin to the point.\r\n * @param pointGeocentricNormal - The normal of the point.\r\n * @param result - The color to write the result to.\r\n * @returns The result color.\r\n */\r\n public getTransmittedColorToRef<T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, result: T): T {\r\n if (this._lutData[0] !== undefined) {\r\n const cosAngleLightToZenith =\r\n directionToLight.x * pointGeocentricNormal.x + directionToLight.y * pointGeocentricNormal.y + directionToLight.z * pointGeocentricNormal.z;\r\n SampleLutToRef(this._atmosphere.physicalProperties, this._lutData, pointRadius, cosAngleLightToZenith, Color4Temp);\r\n result.r = Color4Temp.r;\r\n result.g = Color4Temp.g;\r\n result.b = Color4Temp.b;\r\n } else {\r\n // Fallback.\r\n result.r = result.g = result.b = 1.0;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Derives light color from the transmittance at a point specified by its distance to the planet center and its geocentric normal.\r\n * @param light - The light to update.\r\n * @param pointRadius - The distance from the origin to the point.\r\n * @param pointGeocentricNormal - The normal of the point.\r\n */\r\n public updateLightParameters(light: DirectionalLight, pointRadius: number, pointGeocentricNormal: IVector3Like): void {\r\n const lightDirection = light.direction;\r\n DirectionToLightTemp.x = -lightDirection.x;\r\n DirectionToLightTemp.y = -lightDirection.y;\r\n DirectionToLightTemp.z = -lightDirection.z;\r\n this.getTransmittedColorToRef(DirectionToLightTemp, pointRadius, pointGeocentricNormal, LightColorTemp);\r\n\r\n light.diffuse.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);\r\n light.specular.copyFromFloats(LightColorTemp.r, LightColorTemp.g, LightColorTemp.b);\r\n }\r\n\r\n /**\r\n * Renders the LUT if needed.\r\n * @returns true if the LUT was rendered.\r\n */\r\n public render(): boolean {\r\n // Only need to render the LUT once.\r\n const effectWrapper = this._effectWrapper;\r\n if (!this._isDirty || !effectWrapper?.isReady() || !this._renderTarget?.isReady()) {\r\n return false;\r\n }\r\n\r\n const engine = this._atmosphere.scene.getEngine();\r\n\r\n engine.bindFramebuffer(this.renderTarget.renderTarget!, undefined, undefined, undefined, true);\r\n\r\n const effectRenderer = this._effectRenderer!;\r\n effectRenderer.applyEffectWrapper(effectWrapper);\r\n\r\n effectRenderer.saveStates();\r\n effectRenderer.setViewport();\r\n\r\n const effect = effectWrapper.effect;\r\n effectRenderer.bindBuffers(effect);\r\n\r\n this._atmosphere.bindUniformBufferToEffect(effect);\r\n\r\n effect.setFloat(\"depth\", 0);\r\n\r\n effectRenderer.draw();\r\n\r\n effectRenderer.restoreStates();\r\n engine.restoreDefaultFramebuffer();\r\n\r\n this._isDirty = false;\r\n\r\n // eslint-disable-next-line github/no-then\r\n void this.renderTarget.readPixels(0, 0, undefined, undefined, UseHalfFloat /* noDataConversion */)?.then((value: ArrayBufferView) => {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n this._lutData = value as Uint8Array | Uint16Array;\r\n this.onUpdatedObservable.notifyObservers();\r\n });\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Marks the LUT as needing to be rendered.\r\n */\r\n public markDirty(): void {\r\n this._isDirty = true;\r\n }\r\n\r\n /**\r\n * Disposes the LUT and its resources.\r\n */\r\n public dispose(): void {\r\n this._renderTarget?.dispose();\r\n this._renderTarget = null;\r\n this._effectWrapper?.dispose();\r\n this._effectWrapper = null;\r\n this._effectRenderer?.dispose();\r\n this._effectRenderer = null;\r\n this._isDisposed = true;\r\n }\r\n}\r\n"]}
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from "./atmosphere/index.js";
1
2
  export * from "./htmlMesh/index.js";
2
3
  export * from "./msdfText/index.js";
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-restricted-imports */
2
+ export * from "./atmosphere/index.js";
2
3
  export * from "./htmlMesh/index.js";
3
4
  export * from "./msdfText/index.js";
4
5
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev/addons/src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./htmlMesh/index\";\nexport * from \"./msdfText/index\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../dev/addons/src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./atmosphere/index\";\nexport * from \"./htmlMesh/index\";\nexport * from \"./msdfText/index\";\n"]}
@@ -1,4 +1,4 @@
1
- import type { IVector2Like } from "@onerjs/core/Maths.js";
1
+ import type { IVector2Like } from "@onerjs/core/Maths/math.like.js";
2
2
  /** @internal */
3
3
  export type ParagraphOptions = {
4
4
  maxWidth: number;
@@ -1 +1 @@
1
- {"version":3,"file":"paragraphOptions.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/paragraphOptions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAexC,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACrD,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE;CAClC,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\n\r\nimport type { IVector2Like } from \"core/Maths\";\r\n\r\n/** @internal */\r\nexport type ParagraphOptions = {\r\n maxWidth: number;\r\n lineHeight: number;\r\n letterSpacing: number;\r\n tabSize: number;\r\n whiteSpace: /* 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | */ \"pre-line\" /* | 'break-spaces'*/;\r\n textAlign: \"left\" | \"right\" | \"center\" /* | 'justify'*/;\r\n translate: IVector2Like | undefined;\r\n};\r\n\r\n/** @internal */\r\nexport const DefaultParagraphOptions: ParagraphOptions = {\r\n maxWidth: Infinity,\r\n lineHeight: 1,\r\n letterSpacing: 1,\r\n tabSize: 4,\r\n whiteSpace: \"pre-line\",\r\n textAlign: \"center\",\r\n translate: { x: -0.5, y: -0.5 },\r\n};\r\n"]}
1
+ {"version":3,"file":"paragraphOptions.js","sourceRoot":"","sources":["../../../../dev/addons/src/msdfText/paragraphOptions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAexC,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACrD,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE;CAClC,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\r\n\r\nimport type { IVector2Like } from \"core/Maths/math.like\";\r\n\r\n/** @internal */\r\nexport type ParagraphOptions = {\r\n maxWidth: number;\r\n lineHeight: number;\r\n letterSpacing: number;\r\n tabSize: number;\r\n whiteSpace: /* 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | */ \"pre-line\" /* | 'break-spaces'*/;\r\n textAlign: \"left\" | \"right\" | \"center\" /* | 'justify'*/;\r\n translate: IVector2Like | undefined;\r\n};\r\n\r\n/** @internal */\r\nexport const DefaultParagraphOptions: ParagraphOptions = {\r\n maxWidth: Infinity,\r\n lineHeight: 1,\r\n letterSpacing: 1,\r\n tabSize: 4,\r\n whiteSpace: \"pre-line\",\r\n textAlign: \"center\",\r\n translate: { x: -0.5, y: -0.5 },\r\n};\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onerjs/addons",
3
- "version": "8.25.4",
3
+ "version": "8.25.6",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@onerjs/core": "^8.25.4",
21
+ "@onerjs/core": "^8.25.6",
22
22
  "@dev/addons": "^1.0.0",
23
23
  "@dev/build-tools": "^1.0.0"
24
24
  },