Skip to content

Commit 7830a7d

Browse files
committed
🔧 Manually undo wrong merges
1 parent 6916b14 commit 7830a7d

File tree

20 files changed

+181
-309
lines changed

20 files changed

+181
-309
lines changed

config/base/scene/simple_hmd.json

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -751,40 +751,52 @@
751751
"csp-atmospheres": {
752752
"atmospheres": {
753753
"Earth": {
754-
"height": 80000,
755-
"model": "Bruneton",
756754
"cloudTexture": "../share/resources/textures/earth-clouds.jpg",
755+
"topAltitude": 80000,
756+
"bottomAltitude": -100,
757+
"model": "Bruneton",
757758
"modelSettings": {
758759
"sunAngularRadius": 0.004675,
759-
"rayleigh": 1.24062e-6,
760-
"rayleighScaleHeight": 8000.0,
761-
"mieScaleHeight": 1200.0,
762-
"mieAngstromAlpha": 0.0,
763-
"mieAngstromBeta": 5.328e-3,
764-
"mieSingleScatteringAlbedo": 0.9,
765-
"miePhaseFunctionG": 0.8,
766-
"groundAlbedo": 0.1,
767-
"useOzone": true
760+
"multiScatteringOrder": 10,
761+
"molecules": {
762+
"phase": "../share/resources/data/csp-atmospheres/earth_cosmoscout_molecules_phase.csv",
763+
"betaSca": "../share/resources/data/csp-atmospheres/earth_cosmoscout_molecules_scattering.csv",
764+
"betaAbs": "../share/resources/data/csp-atmospheres/earth_cosmoscout_molecules_absorption.csv",
765+
"density": "../share/resources/data/csp-atmospheres/earth_cosmoscout_molecules_density.csv"
766+
},
767+
"aerosols": {
768+
"phase": "../share/resources/data/csp-atmospheres/earth_cosmoscout_aerosols_phase.csv",
769+
"betaSca": "../share/resources/data/csp-atmospheres/earth_cosmoscout_aerosols_scattering.csv",
770+
"betaAbs": "../share/resources/data/csp-atmospheres/earth_cosmoscout_aerosols_absorption.csv",
771+
"density": "../share/resources/data/csp-atmospheres/earth_cosmoscout_aerosols_density.csv"
772+
},
773+
"ozone": {
774+
"betaAbs": "../share/resources/data/csp-atmospheres/earth_cosmoscout_ozone_absorption.csv",
775+
"density": "../share/resources/data/csp-atmospheres/earth_cosmoscout_ozone_density.csv"
776+
}
768777
}
769778
},
770779
"Mars": {
771-
"height": 100000,
772-
"model": "CosmoScoutVR",
780+
"topAltitude": 80000,
781+
"bottomAltitude": -4500,
782+
"model": "Bruneton",
773783
"modelSettings": {
774-
"mieAnisotropy": 0.76,
775-
"mieHeight": 1200,
776-
"mieScattering": [
777-
4.0e-5,
778-
4.0e-5,
779-
4.0e-5
780-
],
781-
"rayleighAnisotropy": 0,
782-
"rayleighHeight": 11000,
783-
"rayleighScattering": [
784-
19.981e-6,
785-
13.57e-6,
786-
5.75e-6
787-
]
784+
"transmittanceTextureWidth": 1024,
785+
"transmittanceTextureHeight": 512,
786+
"sunAngularRadius": 0.003054,
787+
"multiScatteringOrder": 10,
788+
"molecules": {
789+
"phase": "../share/resources/data/csp-atmospheres/mars_cosmoscout_molecules_cinematic_phase.csv",
790+
"betaSca": "../share/resources/data/csp-atmospheres/mars_cosmoscout_molecules_cinematic_scattering.csv",
791+
"betaAbs": "../share/resources/data/csp-atmospheres/mars_cosmoscout_molecules_cinematic_absorption.csv",
792+
"density": "../share/resources/data/csp-atmospheres/mars_cosmoscout_molecules_cinematic_density.csv"
793+
},
794+
"aerosols": {
795+
"phase": "../share/resources/data/csp-atmospheres/mars_cosmoscout_aerosols_cinematic_phase.csv",
796+
"betaSca": "../share/resources/data/csp-atmospheres/mars_cosmoscout_aerosols_cinematic_scattering.csv",
797+
"betaAbs": "../share/resources/data/csp-atmospheres/mars_cosmoscout_aerosols_cinematic_absorption.csv",
798+
"density": "../share/resources/data/csp-atmospheres/mars_cosmoscout_aerosols_cinematic_density.csv"
799+
}
788800
}
789801
}
790802
}
12.4 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2022 German Aerospace Center (DLR) <[email protected]>
2+
3+
SPDX-License-Identifier: CC-BY-4.0

docs/img/csp-user-study.jpg

19.2 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2022 German Aerospace Center (DLR) <[email protected]>
2+
3+
SPDX-License-Identifier: CC-BY-4.0

plugins/csp-atmospheres/bruneton-preprocessor/shaders/csp-atmosphere-preprocessing-definitions.glsl

Lines changed: 50 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -2,236 +2,62 @@
22
// This file is part of CosmoScout VR //
33
////////////////////////////////////////////////////////////////////////////////////////////////////
44

5-
// SPDX-FileCopyrightText: 2017 Eric Bruneton
6-
// SPDX-License-Identifier: BSD-3-Clause
7-
8-
// This file has been directly copied from here:
9-
// https://github.com/ebruneton/precomputed_atmospheric_scattering/blob/master/atmosphere/definitions.glsl
10-
// The only differences should be related to formatting. The documentation below can also be read
11-
// online at:
12-
// https://ebruneton.github.io/precomputed_atmospheric_scattering/atmosphere/definitions.glsl.html
13-
14-
/*<h2>atmosphere/definitions.glsl</h2>
15-
16-
<p>This GLSL file defines the physical types and constants which are used in the
17-
main <a href="functions.glsl.html">functions</a> of our atmosphere model, in
18-
such a way that they can be compiled by a GLSL compiler (a
19-
<a href="reference/definitions.h.html">C++ equivalent</a> of this file
20-
provides the same types and constants in C++, to allow the same functions to be
21-
compiled by a C++ compiler - see the <a href="../index.html">Introduction</a>).
22-
23-
<h3>Physical quantities</h3>
24-
25-
<p>The physical quantities we need for our atmosphere model are
26-
<a href="https://en.wikipedia.org/wiki/Radiometry">radiometric</a> and
27-
<a href="https://en.wikipedia.org/wiki/Photometry_(optics)">photometric</a>
28-
quantities. In GLSL we can't define custom numeric types to enforce the
29-
homogeneity of expressions at compile time, so we define all the physical
30-
quantities as <code>float</code>, with preprocessor macros (there is no
31-
<code>typedef</code> in GLSL).
32-
33-
<p>We start with six base quantities: length, wavelength, angle, solid angle,
34-
power and luminous power (wavelength is also a length, but we distinguish the
35-
two for increased clarity).
36-
*/
37-
38-
#define Length float
39-
#define Wavelength float
40-
#define Angle float
41-
#define SolidAngle float
42-
#define Power float
43-
#define LuminousPower float
44-
45-
/*
46-
<p>From this we "derive" the irradiance, radiance, spectral irradiance,
47-
spectral radiance, luminance, etc, as well pure numbers, area, volume, etc (the
48-
actual derivation is done in the <a href="reference/definitions.h.html">C++
49-
equivalent</a> of this file).
50-
*/
51-
52-
#define Number float
53-
#define InverseLength float
54-
#define Area float
55-
#define Volume float
56-
#define NumberDensity float
57-
#define Irradiance float
58-
#define Radiance float
59-
#define SpectralPower float
60-
#define SpectralIrradiance float
61-
#define SpectralRadiance float
62-
#define SpectralRadianceDensity float
63-
#define ScatteringCoefficient float
64-
#define InverseSolidAngle float
65-
#define LuminousIntensity float
66-
#define Luminance float
67-
#define Illuminance float
68-
69-
/*
70-
<p>We also need vectors of physical quantities, mostly to represent functions
71-
depending on the wavelength. In this case the vector elements correspond to
72-
values of a function at some predefined wavelengths. Again, in GLSL we can't
73-
define custom vector types to enforce the homogeneity of expressions at compile
74-
time, so we define these vector types as <code>vec3</code>, with preprocessor
75-
macros. The full definitions are given in the
76-
<a href="reference/definitions.h.html">C++ equivalent</a> of this file).
77-
*/
78-
79-
// A generic function from Wavelength to some other type.
80-
#define AbstractSpectrum vec3
81-
// A function from Wavelength to Number.
82-
#define DimensionlessSpectrum vec3
83-
// A function from Wavelength to SpectralPower.
84-
#define PowerSpectrum vec3
85-
// A function from Wavelength to SpectralIrradiance.
86-
#define IrradianceSpectrum vec3
87-
// A function from Wavelength to SpectralRadiance.
88-
#define RadianceSpectrum vec3
89-
// A function from Wavelength to SpectralRadianceDensity.
90-
#define RadianceDensitySpectrum vec3
91-
// A function from Wavelength to ScaterringCoefficient.
92-
#define ScatteringSpectrum vec3
93-
94-
// A position in 3D (3 length values).
95-
#define Position vec3
96-
// A unit direction vector in 3D (3 unitless values).
97-
#define Direction vec3
98-
// A vector of 3 luminance values.
99-
#define Luminance3 vec3
100-
// A vector of 3 illuminance values.
101-
#define Illuminance3 vec3
102-
103-
/*
104-
<p>Finally, we also need precomputed textures containing physical quantities in
105-
each texel. Since we can't define custom sampler types to enforce the
106-
homogeneity of expressions at compile time in GLSL, we define these texture
107-
types as <code>sampler2D</code> and <code>sampler3D</code>, with preprocessor
108-
macros. The full definitions are given in the
109-
<a href="reference/definitions.h.html">C++ equivalent</a> of this file).
110-
*/
111-
112-
#define TransmittanceTexture sampler2D
113-
#define AbstractScatteringTexture sampler3D
114-
#define ReducedScatteringTexture sampler3D
115-
#define ScatteringTexture sampler3D
116-
#define ScatteringDensityTexture sampler3D
117-
#define IrradianceTexture sampler2D
118-
119-
/*
120-
<h3>Physical units</h3>
121-
122-
<p>We can then define the units for our six base physical quantities:
123-
meter (m), nanometer (nm), radian (rad), steradian (sr), watt (watt) and lumen
124-
(lm):
125-
*/
126-
127-
const Length m = 1.0;
128-
const Wavelength nm = 1.0;
129-
const Angle rad = 1.0;
130-
const SolidAngle sr = 1.0;
131-
const Power watt = 1.0;
132-
const LuminousPower lm = 1.0;
133-
134-
/*
135-
<p>From which we can derive the units for some derived physical quantities,
136-
as well as some derived units (kilometer km, kilocandela kcd, degree deg):
137-
*/
5+
// SPDX-FileCopyrightText: German Aerospace Center (DLR) <[email protected]>
6+
// SPDX-License-Identifier: MIT
1387

1398
const float PI = 3.14159265358979323846;
1409

141-
const Length km = 1000.0 * m;
142-
const Area m2 = m * m;
143-
const Volume m3 = m * m * m;
144-
const Angle pi = PI * rad;
145-
const Angle deg = pi / 180.0;
146-
const Irradiance watt_per_square_meter = watt / m2;
147-
const Radiance watt_per_square_meter_per_sr = watt / (m2 * sr);
148-
const SpectralIrradiance watt_per_square_meter_per_nm = watt / (m2 * nm);
149-
const SpectralRadiance watt_per_square_meter_per_sr_per_nm = watt / (m2 * sr * nm);
150-
const SpectralRadianceDensity watt_per_cubic_meter_per_sr_per_nm = watt / (m3 * sr * nm);
151-
const LuminousIntensity cd = lm / sr;
152-
const LuminousIntensity kcd = 1000.0 * cd;
153-
const Luminance cd_per_square_meter = cd / m2;
154-
const Luminance kcd_per_square_meter = kcd / m2;
10+
// This texture contains all the phase functions for the scattering components of the atmosphere.
11+
// The u coordinate maps to the scattering angle. Forward scattering is on the left (u == 0, theta
12+
// == 0) and back scattering on the right (u == 1, theta == 180).
13+
// The v coordinate maps to the various components. The phase function of the first scattering
14+
// component is stored in the top row of pixels, the second in the next and so on. So usually the
15+
// phase function for molecules is in the top row and the phase function for aerosols is in the
16+
// bottom row.
17+
uniform sampler2D uPhaseTexture;
18+
19+
// This texture contains all the density functions for the components of the atmosphere. The density
20+
// function maps a relative density value in [0..1] to each altitude. The u coordinate corresponds
21+
// to the altitude; atmosphere's bottom is on the left (u == 0) and the top is the right (u == 1).
22+
// The v coordinate maps to the various components. The density function of the first component is
23+
// stored in the top row of pixels, the second in the next and so on. So usually the molecules are
24+
// in the first row, aerosols in the second row, and ozone is in the last row.
25+
// The density_texture is only sampled during preprocessing. It is not used at runtime in the final
26+
// fragment shader.
27+
uniform sampler2D uDensityTexture;
28+
29+
// Scattering components can absorb and scatter light. Air molecules and aerosols in Earth's
30+
// atmosphere are both modelled using scattering components.
31+
struct ScatteringComponent {
32+
33+
// The vertical texture coordinate of the component's the phse function in phase_texture.
34+
float phaseTextureV;
35+
36+
// The vertical texture coordinate of the component's the density function in density_texture.
37+
float densityTextureV;
38+
39+
// The extinction coefficient beta_ext in m^-1.
40+
vec3 extinction;
41+
42+
// The extinction coefficient beta_sca in m^-1.
43+
vec3 scattering;
44+
};
15545

156-
/*
157-
<h3>Atmosphere parameters</h3>
46+
// Absorbing components can absorb light but do not scatter light. Ozone in Earth's atmosphere is
47+
// modelled using an absorbing component.
48+
struct AbsorbingComponent {
15849

159-
<p>Using the above types, we can now define the parameters of our atmosphere
160-
model. We start with the definition of density profiles, which are needed for
161-
parameters that depend on the altitude:
162-
*/
50+
// The vertical texture coordinate of the component's the density function in density_texture.
51+
float densityTextureV;
16352

164-
// An atmosphere layer of width 'width', and whose density is defined as
165-
// 'exp_term' * exp('exp_scale' * h) + 'linear_term' * h + 'constant_term',
166-
// clamped to [0,1], and where h is the altitude.
167-
struct DensityProfileLayer {
168-
Length width;
169-
Number exp_term;
170-
InverseLength exp_scale;
171-
InverseLength linear_term;
172-
Number constant_term;
53+
// The extinction coefficient beta_ext in m^-1.
54+
vec3 extinction;
17355
};
17456

175-
// An atmosphere density profile made of several layers on top of each other
176-
// (from bottom to top). The width of the last layer is ignored, i.e. it always
177-
// extend to the top atmosphere boundary. The profile values vary between 0
178-
// (null density) to 1 (maximum density).
179-
struct DensityProfile {
180-
DensityProfileLayer layers[2];
181-
};
182-
183-
/*
184-
The atmosphere parameters are then defined by the following struct:
185-
*/
186-
187-
struct AtmosphereParameters {
188-
// The solar irradiance at the top of the atmosphere.
189-
IrradianceSpectrum solar_irradiance;
190-
// The sun's angular radius. Warning: the implementation uses approximations
191-
// that are valid only if this angle is smaller than 0.1 radians.
192-
Angle sun_angular_radius;
193-
// The distance between the planet center and the bottom of the atmosphere.
194-
Length bottom_radius;
195-
// The distance between the planet center and the top of the atmosphere.
196-
Length top_radius;
197-
// The density profile of air molecules, i.e. a function from altitude to
198-
// dimensionless values between 0 (null density) and 1 (maximum density).
199-
DensityProfile rayleigh_density;
200-
// The scattering coefficient of air molecules at the altitude where their
201-
// density is maximum (usually the bottom of the atmosphere), as a function of
202-
// wavelength. The scattering coefficient at altitude h is equal to
203-
// 'rayleigh_scattering' times 'rayleigh_density' at this altitude.
204-
ScatteringSpectrum rayleigh_scattering;
205-
// The density profile of aerosols, i.e. a function from altitude to
206-
// dimensionless values between 0 (null density) and 1 (maximum density).
207-
DensityProfile mie_density;
208-
// The scattering coefficient of aerosols at the altitude where their density
209-
// is maximum (usually the bottom of the atmosphere), as a function of
210-
// wavelength. The scattering coefficient at altitude h is equal to
211-
// 'mie_scattering' times 'mie_density' at this altitude.
212-
ScatteringSpectrum mie_scattering;
213-
// The extinction coefficient of aerosols at the altitude where their density
214-
// is maximum (usually the bottom of the atmosphere), as a function of
215-
// wavelength. The extinction coefficient at altitude h is equal to
216-
// 'mie_extinction' times 'mie_density' at this altitude.
217-
ScatteringSpectrum mie_extinction;
218-
// The asymetry parameter for the Cornette-Shanks phase function for the
219-
// aerosols.
220-
Number mie_phase_function_g;
221-
// The density profile of air molecules that absorb light (e.g. ozone), i.e.
222-
// a function from altitude to dimensionless values between 0 (null density)
223-
// and 1 (maximum density).
224-
DensityProfile absorption_density;
225-
// The extinction coefficient of molecules that absorb light (e.g. ozone) at
226-
// the altitude where their density is maximum, as a function of wavelength.
227-
// The extinction coefficient at altitude h is equal to
228-
// 'absorption_extinction' times 'absorption_density' at this altitude.
229-
ScatteringSpectrum absorption_extinction;
230-
// The average albedo of the ground.
231-
DimensionlessSpectrum ground_albedo;
232-
// The cosine of the maximum Sun zenith angle for which atmospheric scattering
233-
// must be precomputed (for maximum precision, use the smallest Sun zenith
234-
// angle yielding negligible sky light radiance values. For instance, for the
235-
// Earth case, 102 degrees is a good choice - yielding mu_s_min = -0.2).
236-
Number mu_s_min;
57+
// An atmosphere consists of two scattering components and an absorbing component. The scattering
58+
// components can absorb light as well, but the absorbing component can not scatter light.
59+
struct AtmosphereComponents {
60+
ScatteringComponent molecules;
61+
ScatteringComponent aerosols;
62+
AbsorbingComponent ozone;
23763
};

0 commit comments

Comments
 (0)