1
0
Fork 0

HDR: Add separate fog layer to atmosphere

Also use Nasal to feed the shaders' uniforms. Much better than running
the computations on the GPU.
This commit is contained in:
Fernando García Liñán 2023-04-21 02:15:42 +02:00
parent 6d03eb190f
commit 691337a00e
6 changed files with 305 additions and 206 deletions

View file

@ -3,18 +3,42 @@
<name>Effects/HDR/atmos-aerial-perspective</name>
<parameters>
<!-- atmos.glsl -->
<aerosol-type>
<use>/sim/rendering/hdr/atmos/aerosol-type</use>
</aerosol-type>
<aerosol-turbidity>
<use>/sim/rendering/hdr/atmos/aerosol-turbidity</use>
</aerosol-turbidity>
<ground-albedo>
<use>/sim/rendering/hdr/atmos/ground-albedo</use>
<aerosol-absorption-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[3]</use>
</aerosol-absorption-cross-section>
<aerosol-scattering-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[3]</use>
</aerosol-scattering-cross-section>
<aerosol-base-density>
<use>/sim/rendering/hdr/atmos/aerosol-base-density</use>
</aerosol-base-density>
<aerosol-relative-background-density>
<use>/sim/rendering/hdr/atmos/aerosol-relative-background-density</use>
</aerosol-relative-background-density>
<aerosol-scale-height>
<use>/sim/rendering/hdr/atmos/aerosol-scale-height</use>
</aerosol-scale-height>
<fog-density>
<use>/sim/rendering/hdr/atmos/fog-density</use>
</fog-density>
<fog-scale-height>
<use>/sim/rendering/hdr/atmos/fog-scale-height</use>
</fog-scale-height>
<ozone-mean-dobson>
<use>/sim/rendering/hdr/atmos/ozone-mean-dobson</use>
</ozone-mean-dobson>
<ground-albedo type="vec4d">
<use>/sim/rendering/hdr/atmos/ground-albedo[0]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[1]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[2]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[3]</use>
</ground-albedo>
<month-of-the-year>
<use>/sim/time/utc/month</use>
</month-of-the-year>
</parameters>
<technique n="1">
<pass>
@ -33,25 +57,50 @@
</uniform>
<!-- atmos.glsl -->
<uniform>
<name>aerosol_type</name>
<type>int</type>
<value><use>aerosol-type</use></value>
<name>aerosol_absorption_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-absorption-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_turbidity</name>
<name>aerosol_scattering_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-scattering-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_base_density</name>
<type>float</type>
<value><use>aerosol-turbidity</use></value>
<value><use>aerosol-base-density</use></value>
</uniform>
<uniform>
<name>aerosol_relative_background_density</name>
<type>float</type>
<value><use>aerosol-relative-background-density</use></value>
</uniform>
<uniform>
<name>aerosol_scale_height</name>
<type>float</type>
<value><use>aerosol-scale-height</use></value>
</uniform>
<uniform>
<name>fog_density</name>
<type>float</type>
<value><use>fog-density</use></value>
</uniform>
<uniform>
<name>fog_scale_height</name>
<type>float</type>
<value><use>fog-scale-height</use></value>
</uniform>
<uniform>
<name>ozone_mean_dobson</name>
<type>float</type>
<value><use>ozone-mean-dobson</use></value>
</uniform>
<uniform>
<name>ground_albedo</name>
<type>float</type>
<type>float-vec4</type>
<value><use>ground-albedo</use></value>
</uniform>
<uniform>
<name>month_of_the_year</name>
<type>int</type>
<value><use>month-of-the-year</use></value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -3,18 +3,42 @@
<name>Effects/HDR/atmos-sky-view</name>
<parameters>
<!-- atmos.glsl -->
<aerosol-type>
<use>/sim/rendering/hdr/atmos/aerosol-type</use>
</aerosol-type>
<aerosol-turbidity>
<use>/sim/rendering/hdr/atmos/aerosol-turbidity</use>
</aerosol-turbidity>
<ground-albedo>
<use>/sim/rendering/hdr/atmos/ground-albedo</use>
<aerosol-absorption-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[3]</use>
</aerosol-absorption-cross-section>
<aerosol-scattering-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[3]</use>
</aerosol-scattering-cross-section>
<aerosol-base-density>
<use>/sim/rendering/hdr/atmos/aerosol-base-density</use>
</aerosol-base-density>
<aerosol-relative-background-density>
<use>/sim/rendering/hdr/atmos/aerosol-relative-background-density</use>
</aerosol-relative-background-density>
<aerosol-scale-height>
<use>/sim/rendering/hdr/atmos/aerosol-scale-height</use>
</aerosol-scale-height>
<fog-density>
<use>/sim/rendering/hdr/atmos/fog-density</use>
</fog-density>
<fog-scale-height>
<use>/sim/rendering/hdr/atmos/fog-scale-height</use>
</fog-scale-height>
<ozone-mean-dobson>
<use>/sim/rendering/hdr/atmos/ozone-mean-dobson</use>
</ozone-mean-dobson>
<ground-albedo type="vec4d">
<use>/sim/rendering/hdr/atmos/ground-albedo[0]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[1]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[2]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[3]</use>
</ground-albedo>
<month-of-the-year>
<use>/sim/time/utc/month</use>
</month-of-the-year>
</parameters>
<technique n="1">
<pass>
@ -31,25 +55,50 @@
</uniform>
<!-- atmos.glsl -->
<uniform>
<name>aerosol_type</name>
<type>int</type>
<value><use>aerosol-type</use></value>
<name>aerosol_absorption_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-absorption-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_turbidity</name>
<name>aerosol_scattering_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-scattering-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_base_density</name>
<type>float</type>
<value><use>aerosol-turbidity</use></value>
<value><use>aerosol-base-density</use></value>
</uniform>
<uniform>
<name>aerosol_relative_background_density</name>
<type>float</type>
<value><use>aerosol-relative-background-density</use></value>
</uniform>
<uniform>
<name>aerosol_scale_height</name>
<type>float</type>
<value><use>aerosol-scale-height</use></value>
</uniform>
<uniform>
<name>fog_density</name>
<type>float</type>
<value><use>fog-density</use></value>
</uniform>
<uniform>
<name>fog_scale_height</name>
<type>float</type>
<value><use>fog-scale-height</use></value>
</uniform>
<uniform>
<name>ozone_mean_dobson</name>
<type>float</type>
<value><use>ozone-mean-dobson</use></value>
</uniform>
<uniform>
<name>ground_albedo</name>
<type>float</type>
<type>float-vec4</type>
<value><use>ground-albedo</use></value>
</uniform>
<uniform>
<name>month_of_the_year</name>
<type>int</type>
<value><use>month-of-the-year</use></value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -3,18 +3,42 @@
<name>Effects/HDR/atmos-transmittance</name>
<parameters>
<!-- atmos.glsl -->
<aerosol-type>
<use>/sim/rendering/hdr/atmos/aerosol-type</use>
</aerosol-type>
<aerosol-turbidity>
<use>/sim/rendering/hdr/atmos/aerosol-turbidity</use>
</aerosol-turbidity>
<ground-albedo>
<use>/sim/rendering/hdr/atmos/ground-albedo</use>
<aerosol-absorption-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[3]</use>
</aerosol-absorption-cross-section>
<aerosol-scattering-cross-section type="vec4d">
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[0]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[1]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[2]</use>
<use>/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[3]</use>
</aerosol-scattering-cross-section>
<aerosol-base-density>
<use>/sim/rendering/hdr/atmos/aerosol-base-density</use>
</aerosol-base-density>
<aerosol-relative-background-density>
<use>/sim/rendering/hdr/atmos/aerosol-relative-background-density</use>
</aerosol-relative-background-density>
<aerosol-scale-height>
<use>/sim/rendering/hdr/atmos/aerosol-scale-height</use>
</aerosol-scale-height>
<fog-density>
<use>/sim/rendering/hdr/atmos/fog-density</use>
</fog-density>
<fog-scale-height>
<use>/sim/rendering/hdr/atmos/fog-scale-height</use>
</fog-scale-height>
<ozone-mean-dobson>
<use>/sim/rendering/hdr/atmos/ozone-mean-dobson</use>
</ozone-mean-dobson>
<ground-albedo type="vec4d">
<use>/sim/rendering/hdr/atmos/ground-albedo[0]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[1]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[2]</use>
<use>/sim/rendering/hdr/atmos/ground-albedo[3]</use>
</ground-albedo>
<month-of-the-year>
<use>/sim/time/utc/month</use>
</month-of-the-year>
</parameters>
<technique n="1">
<pass>
@ -26,25 +50,50 @@
</program>
<!-- atmos.glsl -->
<uniform>
<name>aerosol_type</name>
<type>int</type>
<value><use>aerosol-type</use></value>
<name>aerosol_absorption_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-absorption-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_turbidity</name>
<name>aerosol_scattering_cross_section</name>
<type>float-vec4</type>
<value><use>aerosol-scattering-cross-section</use></value>
</uniform>
<uniform>
<name>aerosol_base_density</name>
<type>float</type>
<value><use>aerosol-turbidity</use></value>
<value><use>aerosol-base-density</use></value>
</uniform>
<uniform>
<name>aerosol_relative_background_density</name>
<type>float</type>
<value><use>aerosol-relative-background-density</use></value>
</uniform>
<uniform>
<name>aerosol_scale_height</name>
<type>float</type>
<value><use>aerosol-scale-height</use></value>
</uniform>
<uniform>
<name>fog_density</name>
<type>float</type>
<value><use>fog-density</use></value>
</uniform>
<uniform>
<name>fog_scale_height</name>
<type>float</type>
<value><use>fog-scale-height</use></value>
</uniform>
<uniform>
<name>ozone_mean_dobson</name>
<type>float</type>
<value><use>ozone-mean-dobson</use></value>
</uniform>
<uniform>
<name>ground_albedo</name>
<type>float</type>
<type>float-vec4</type>
<value><use>ground-albedo</use></value>
</uniform>
<uniform>
<name>month_of_the_year</name>
<type>int</type>
<value><use>month-of-the-year</use></value>
</uniform>
</pass>
</technique>
</PropertyList>

33
Nasal/hdr.nas Normal file
View file

@ -0,0 +1,33 @@
# Copyright (C) 2023 Fernando García Liñán
# SPDX-License-Identifier: GPL-2.0-or-later
#-------------------------------------------------------------------------------
# Utilities for the HDR Pipeline
#
# Shaders usually need to be fed uniforms that are either too expensive to
# compute on the GPU or can be precomputed once per frame. In this file we
# transform values from already existing properties into data that can be used
# by the shaders directly.
#-------------------------------------------------------------------------------
setprop("/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[0]", 2.8722e-24);
setprop("/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[1]", 4.6168e-24);
setprop("/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[2]", 7.9706e-24);
setprop("/sim/rendering/hdr/atmos/aerosol-absorption-cross-section[3]", 1.3578e-23);
setprop("/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[0]", 1.5908e-22);
setprop("/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[1]", 1.7711e-22);
setprop("/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[2]", 2.0942e-22);
setprop("/sim/rendering/hdr/atmos/aerosol-scattering-cross-section[3]", 2.4033e-22);
setprop("/sim/rendering/hdr/atmos/aerosol-base-density", 1.3681e17);
setprop("/sim/rendering/hdr/atmos/aerosol-relative-background-density", 1.4619e-17);
setprop("/sim/rendering/hdr/atmos/aerosol-scale-height", 0.73);
setprop("/sim/rendering/hdr/atmos/fog-density", 0.0);
setprop("/sim/rendering/hdr/atmos/fog-scale-height", 1.0);
setprop("/sim/rendering/hdr/atmos/ozone-mean-dobson", 347.0);
setprop("/sim/rendering/hdr/atmos/ground-albedo[0]", 0.4);
setprop("/sim/rendering/hdr/atmos/ground-albedo[1]", 0.4);
setprop("/sim/rendering/hdr/atmos/ground-albedo[2]", 0.4);
setprop("/sim/rendering/hdr/atmos/ground-albedo[3]", 0.4);

View file

@ -1,9 +1,24 @@
/*
* Common atmosphere rendering functions
*
* See https://www.shadertoy.com/view/msXXDS for a more complete description
* of what the shader does and more references.
*
* All 4-component vectors in this file represent values sampled for the
* following wavelengths: 630, 560, 490, 430 nm
*/
#version 330 core
uniform int aerosol_type;
uniform float aerosol_turbidity;
uniform float ground_albedo;
uniform int month_of_the_year;
uniform vec4 aerosol_absorption_cross_section;
uniform vec4 aerosol_scattering_cross_section;
uniform float aerosol_base_density;
uniform float aerosol_relative_background_density;
uniform float aerosol_scale_height;
uniform float fog_density;
uniform float fog_scale_height;
uniform float ozone_mean_dobson;
uniform vec4 ground_albedo;
uniform float fg_EarthRadius;
@ -19,37 +34,21 @@ const float HENYEY_ASYMMETRY2 = HENYEY_ASYMMETRY*HENYEY_ASYMMETRY;
const vec4 molecular_scattering_coefficient_base =
vec4(6.605e-6, 1.067e-5, 1.842e-5, 3.156e-5);
/*
* Fog scattering/extinction cross section, units m^2 / molecules
* Mie theory results for IOR of 1.333. Particle size is a log normal
* distribution of mean diameter=15 and std deviation=0.4
*/
const vec4 fog_scattering_cross_section =
vec4(5.015e-10, 4.987e-10, 4.966e-10, 4.949e-10);
/*
* Ozone absorption cross section, units m^2 / molecules
* "High spectral resolution ozone absorption cross-sections"
* by V. Gorshelev et al. (2014).
*/
const vec4 ozone_cross_section =
vec4(3.472e-21, 3.914e-21, 1.349e-21, 11.03e-23) * 1e-4f;
const float ozone_mean_monthly_dobson[] = float[](
347.0, // January
370.0, // February
381.0, // March
384.0, // April
372.0, // May
352.0, // June
333.0, // July
317.0, // August
298.0, // September
285.0, // October
290.0, // November
315.0 // December
);
const float ozone_height_distribution[] = float[](
9.0 / 210.0,
14.0 / 210.0,
111.0 / 210.0,
64.0 / 210.0,
6.0 / 210.0,
6.0 / 210.0,
0.0
);
const vec4 ozone_absorption_cross_section =
vec4(3.472e-25, 3.914e-25, 1.349e-25, 11.03e-27);
// math.glsl
float M_PI();
@ -156,131 +155,46 @@ vec4 get_molecular_scattering_coefficient(float h)
}
/*
* Return the molecular volume absorption coefficient (km^-1) for a given altitude
* Return the molecular volume absorption coefficient (m^-1) for a given altitude
* in kilometers.
*/
vec4 get_molecular_absorption_coefficient(float h)
{
int i = int(clamp(h / 9.0, 0.0, 6.0));
float density = ozone_height_distribution[i] *
ozone_mean_monthly_dobson[month_of_the_year-1] * 2.6867e20f; // molecules / m^2
density /= 9e3; // m^-3
return ozone_cross_section * density; // m^-1
h += 1e-4; // Avoid division by 0
float t = log(h) - 3.22261;
float density = 3.78547397e17 * (1.0 / h) * exp(-t * t * 5.55555555);
return ozone_absorption_cross_section * ozone_mean_dobson * density;
}
/*
* Return the aerosol density for a given altitude in kilometers.
*/
float get_aerosol_density(float h, float base_density, float height_scale,
float relative_background_density)
float get_aerosol_density(float h)
{
if (aerosol_type == 0) {
// Only for the Background aerosol type, no dependency on height
return base_density * (1.0 + relative_background_density);
} else {
return base_density * (exp(-h / height_scale) + relative_background_density);
}
return aerosol_base_density * (exp(-h / aerosol_scale_height)
+ aerosol_relative_background_density);
}
/*
* Get the aerosol collision coefficients for a given altitude h in km.
* The two main parameters are the aerosol type (0 to 8), and the turbidity.
* Every aerosol type expects 5 parameters:
* - Scattering cross section
* - Absorption cross section
* - Base density (km^-3)
* - Background density (km^-3)
* - Height scaling parameter
* Return the fog volume scattering coefficient (m^-1) for a given altitude in
* kilometers.
*
* This model for aerosols and their corresponding parameters come from
* "A Physically-Based Spatio-Temporal Sky Model"
* by Guimera et al. (2018).
* Fog (or mist, depending on density) is a special kind of aerosol consisting
* of water droplets or ice crystals. Visibility is mostly dependent on fog.
*/
void get_aerosol_collision_coefficients(in float h,
out vec4 absorption,
out vec4 scattering)
vec4 get_fog_scattering_coefficient(float h)
{
vec4 aerosol_absorption_cross_section, aerosol_scattering_cross_section;
float aerosol_base_density, aerosol_background_density, aerosol_height_scale;
if (aerosol_type == 0) {
// Background
aerosol_absorption_cross_section = vec4(4.5517e-19, 5.9269e-19, 6.9143e-19, 8.5228e-19);
aerosol_scattering_cross_section = vec4(1.8921e-26, 1.6951e-26, 1.7436e-26, 2.1158e-26);
aerosol_base_density = 2.584e17;
aerosol_background_density = 2e6;
} else if (aerosol_type == 1) {
// Desert-Dust
aerosol_absorption_cross_section = vec4(4.6758e-16, 4.4654e-16, 4.1989e-16, 4.1493e-16);
aerosol_scattering_cross_section = vec4(2.9144e-16, 3.1463e-16, 3.3902e-16, 3.4298e-16);
aerosol_base_density = 1.8662e18;
aerosol_background_density = 2e6;
aerosol_height_scale = 2.0;
} else if (aerosol_type == 2) {
// Maritime Clean
aerosol_absorption_cross_section = vec4(6.3312e-19, 7.5567e-19, 9.2627e-19, 1.0391e-18);
aerosol_scattering_cross_section = vec4(4.6539e-26, 2.721e-26, 4.1104e-26, 5.6249e-26);
aerosol_base_density = 2.0266e17;
aerosol_background_density = 2e6;
aerosol_height_scale = 0.9;
} else if (aerosol_type == 3) {
// Maritime Mineral
aerosol_absorption_cross_section = vec4(6.9365e-19, 7.5951e-19, 8.2423e-19, 8.9101e-19);
aerosol_scattering_cross_section = vec4(2.3699e-19, 2.2439e-19, 2.2126e-19, 2.021e-19);
aerosol_base_density = 2.0266e17;
aerosol_background_density = 2e6;
aerosol_height_scale = 2.0;
} else if (aerosol_type == 4) {
// Polar Antarctic
aerosol_absorption_cross_section = vec4(1.3399e-16, 1.3178e-16, 1.2909e-16, 1.3006e-16);
aerosol_scattering_cross_section = vec4(1.5506e-19, 1.809e-19, 2.3069e-19, 2.5804e-19);
aerosol_base_density = 2.3864e16;
aerosol_background_density = 2e6;
aerosol_height_scale = 30.0;
} else if (aerosol_type == 5) {
// Polar Arctic
aerosol_absorption_cross_section = vec4(1.0364e-16, 1.0609e-16, 1.0193e-16, 1.0092e-16);
aerosol_scattering_cross_section = vec4(2.1609e-17, 2.2759e-17, 2.5089e-17, 2.6323e-17);
aerosol_base_density = 2.3864e16;
aerosol_background_density = 2e6;
aerosol_height_scale = 30.0;
} else if (aerosol_type == 6) {
// Remote Continental
aerosol_absorption_cross_section = vec4(4.5307e-18, 5.0662e-18, 4.4877e-18, 3.7917e-18);
aerosol_scattering_cross_section = vec4(1.8764e-18, 1.746e-18, 1.6902e-18, 1.479e-18);
aerosol_base_density = 6.103e18;
aerosol_background_density = 2e6;
aerosol_height_scale = 0.73;
} else if (aerosol_type == 7) {
// Rural
aerosol_absorption_cross_section = vec4(5.0393e-23, 8.0765e-23, 1.3823e-22, 2.3383e-22);
aerosol_scattering_cross_section = vec4(2.6004e-22, 2.4844e-22, 2.8362e-22, 2.7494e-22);
aerosol_base_density = 8.544e18;
aerosol_background_density = 2e6;
aerosol_height_scale = 0.73;
} else if (aerosol_type == 8) {
// Urban
aerosol_absorption_cross_section = vec4(2.8722e-24, 4.6168e-24, 7.9706e-24, 1.3578e-23);
aerosol_scattering_cross_section = vec4(1.5908e-22, 1.7711e-22, 2.0942e-22, 2.4033e-22);
aerosol_base_density = 1.3681e20;
aerosol_background_density = 2e6;
aerosol_height_scale = 0.73;
if (fog_density > 0.0) {
return fog_scattering_cross_section * fog_density
* exp(-h / fog_scale_height);
} else {
return vec4(0.0);
}
float aerosol_relative_background_density =
aerosol_background_density / aerosol_base_density;
float aerosol_density = get_aerosol_density(
h, aerosol_base_density, aerosol_height_scale,
aerosol_relative_background_density);
aerosol_density *= aerosol_turbidity * 1e-3;
absorption = aerosol_absorption_cross_section * aerosol_density;
scattering = aerosol_scattering_cross_section * aerosol_density;
}
/*
* Get the collision coefficients (scattering and absorption) of the
* atmospheric medium for a given point at an altitude h.
* atmospheric medium for a given point at an altitude h in meters.
*/
void get_atmosphere_collision_coefficients(in float h,
out vec4 aerosol_absorption,
@ -291,9 +205,19 @@ void get_atmosphere_collision_coefficients(in float h,
{
h *= 1e-3; // To km
h = max(h, 0.0); // In case height is negative
get_aerosol_collision_coefficients(h, aerosol_absorption, aerosol_scattering);
// Molecules
molecular_absorption = get_molecular_absorption_coefficient(h);
molecular_scattering = get_molecular_scattering_coefficient(h);
// Aerosols
float aerosol_density = get_aerosol_density(h);
aerosol_absorption = aerosol_absorption_cross_section * aerosol_density;
aerosol_scattering = aerosol_scattering_cross_section * aerosol_density;
// Add contribution from fog
aerosol_scattering += get_fog_scattering_coefficient(h);
extinction =
aerosol_absorption + aerosol_scattering +
molecular_absorption + molecular_scattering;

View file

@ -535,11 +535,6 @@ Started September 2000 by David Megginson, david@megginson.com
<hdr>
<antialiasing-technique type="int" userarchive="y">2</antialiasing-technique>
<exposure-compensation type="float">0.0</exposure-compensation>
<atmos>
<aerosol-type type="int">8</aerosol-type>
<aerosol-turbidity type="float">1.0</aerosol-turbidity>
<ground-albedo type="float">0.4</ground-albedo>
</atmos>
<bloom>
<strength type="float">0.01</strength>
<filter-radius type="float">0.005</filter-radius>