Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.

Constants

FRAC_PI

#
const FRAC_PI: f32 = 0.3183098862

FRAC_2_PI

#
const FRAC_2_PI: f32 = 0.15915494309

FRAC_3_16_PI

#
const FRAC_3_16_PI: f32 = 0.0596831036594607509

FRAC_4_PI

#
const FRAC_4_PI: f32 = 0.07957747154594767

ROOT_2

#
const ROOT_2: f32 = 1.41421356

EPSILON

#
const EPSILON: f32 = 1.0

MIN_EXTINCTION

#
const MIN_EXTINCTION: vec3<f32> = vec3(1e-12)

MIDPOINT_RATIO

#
const MIDPOINT_RATIO: f32 = 0.3

ABSORPTION_DENSITY

#
const ABSORPTION_DENSITY: f32 = 0.0

SCATTERING_DENSITY

#
const SCATTERING_DENSITY: f32 = 1.0

PHASE_MAPPING_N

#
const PHASE_MAPPING_N: f32 = 0.5

Structures

RaymarchSegment

#
struct RaymarchSegment {
start: f32 ,
end: f32 ,
}

RaymarchResult

#
struct RaymarchResult {
inscattering: vec3<f32> ,
transmittance: vec3<f32> ,
}

Functions

unit_to_sub_uvs

#
fn unit_to_sub_uvs (
val: vec2<f32>
, 
resolution: vec2<f32>
) -> vec2<f32>

sub_uvs_to_unit

#
fn sub_uvs_to_unit (
val: vec2<f32>
, 
resolution: vec2<f32>
) -> vec2<f32>

multiscattering_lut_r_mu_to_uv

#
fn multiscattering_lut_r_mu_to_uv (
r: f32
, 
mu: f32
) -> vec2<f32>

multiscattering_lut_uv_to_r_mu

#
fn multiscattering_lut_uv_to_r_mu (
uv: vec2<f32>
) -> vec2<f32>

sky_view_lut_r_mu_azimuth_to_uv

#
fn sky_view_lut_r_mu_azimuth_to_uv (
r: f32
, 
mu: f32
, 
azimuth: f32
) -> vec2<f32>

sky_view_lut_uv_to_zenith_azimuth

#
fn sky_view_lut_uv_to_zenith_azimuth (
r: f32
, 
uv: vec2<f32>
) -> vec2<f32>

sample_transmittance_lut

#
fn sample_transmittance_lut (
r: f32
, 
mu: f32
) -> vec3<f32>

sample_multiscattering_lut

#
fn sample_multiscattering_lut (
r: f32
, 
mu: f32
) -> vec3<f32>

sample_sky_view_lut

#
fn sample_sky_view_lut (
r: f32
, 
ray_dir_as: vec3<f32>
) -> vec3<f32>

ndc_to_camera_dist

#
fn ndc_to_camera_dist (
ndc: vec3<f32>
) -> f32

sample_aerial_view_lut

#

RGB channels: total inscattered light along the camera ray to the current sample. A channel: average transmittance across all wavelengths to the current sample.

fn sample_aerial_view_lut (
uv: vec2<f32>
, 
t: f32
) -> vec3<f32>

sample_density_lut

#

calling with component = 0.0 will return the atmosphere’s absorption density, while calling with component = 1.0 will return the atmosphere’s scattering density.

fn sample_density_lut (
r: f32
, 
component: f32
) -> vec3<f32>

sample_scattering_lut

#

samples from the atmosphere scattering LUT. neg_LdotV is the dot product of the light direction and the incoming view vector. Nonlinear phase mapping to mitigate banding in low-resolution LUTs.

fn sample_scattering_lut (
r: f32
, 
neg_LdotV: f32
) -> vec3<f32>

sample_local_inscattering

#

evaluates L_scat, equation 3 in the paper, which gives the total single-order scattering towards the view at a single point

fn sample_local_inscattering (
local_scattering: vec3<f32>
, 
ray_dir: vec3<f32>
, 
world_pos: vec3<f32>
) -> vec3<f32>

sample_sun_radiance

#
fn sample_sun_radiance (
ray_dir_ws: vec3<f32>
) -> vec3<f32>

calculate_visible_sun_ratio

#
fn calculate_visible_sun_ratio (
atmosphere: Atmosphere
, 
r: f32
, 
mu: f32
, 
sun_angular_size: f32
) -> f32

clamp_to_surface

#

Clamp a position to the planet surface (with a small epsilon) to avoid underground artifacts.

fn clamp_to_surface (
atmosphere: Atmosphere
, 
position: vec3<f32>
) -> vec3<f32>

max_atmosphere_distance

#
fn max_atmosphere_distance (
r: f32
, 
mu: f32
) -> f32

get_view_position

#

Returns the observer’s position in the atmosphere

fn get_view_position () -> vec3<f32>

get_local_up

#

We assume the up vector at the view position is the y axis, since the world is locally flat/level. t = distance along view ray in atmosphere space NOTE: this means that if your world is actually spherical, this will be wrong.

fn get_local_up (
r: f32
, 
t: f32
, 
ray_dir: vec3<f32>
) -> vec3<f32>

get_local_r

#

Given a ray starting at radius r, with mu = cos(zenith angle), and a t = distance along the ray, gives the new radius at point t

fn get_local_r (
r: f32
, 
mu: f32
, 
t: f32
) -> f32

uv_to_ndc

#

Convert uv [0.0 .. 1.0] coordinate to ndc space xy [-1.0 .. 1.0]

fn uv_to_ndc (
uv: vec2<f32>
) -> vec2<f32>

ndc_to_uv

#

Convert ndc space xy coordinate [-1.0 .. 1.0] to uv [0.0 .. 1.0]

fn ndc_to_uv (
ndc: vec2<f32>
) -> vec2<f32>

direction_world_to_atmosphere

#

Converts a direction in world space to atmosphere space

fn direction_world_to_atmosphere (
dir_ws: vec3<f32>
) -> vec3<f32>

direction_atmosphere_to_world

#

Converts a direction in atmosphere space to world space

fn direction_atmosphere_to_world (
dir_as: vec3<f32>
) -> vec3<f32>

uv_to_ray_direction

#

Modified from skybox.wesl. For this pass we don’t need to apply a separate sky transform or consider camera viewport. Returns a normalized ray direction in world space.

fn uv_to_ray_direction (
uv: vec2<f32>
) -> vec3<f32>

zenith_azimuth_to_ray_dir

#
fn zenith_azimuth_to_ray_dir (
zenith: f32
, 
azimuth: f32
) -> vec3<f32>

get_raymarch_segment

#
fn get_raymarch_segment (
r: f32
, 
mu: f32
) -> RaymarchSegment

raymarch_atmosphere

#
fn raymarch_atmosphere (
pos: vec3<f32>
, 
ray_dir: vec3<f32>
, 
t_max: f32
, 
max_samples: u32
, 
uv: vec2<f32>
, 
ground: bool
) -> RaymarchResult
Contents