atmosphere

package
v0.0.0-...-ddc071b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

README

package dieselfluid/atmosphere

package Atmosphere

This package allows you to create atmospheric renders with approximations for latitudes and longitudes and times of the year. Using a global decimal UTC time system. Setting the Standard Meridian offsets the decimal time rotation and allows you to work in local time.

Note: Atmosphere package assumes to be working in meters to include all physical phenomena including wavelengths astronomical measurements

Coefficients are based off of the surface layer coefficients for Rayleigh and Mie scattering phenomena future work can be done to move non normalized images into an HDR format for Global Environmental lights.

We can also extend the framework for atmosphere into a more generalized Rayleigh/Mie Scatter framework to allow for different Mie Scattering solutions during weather environmental changes and descriptions

This framework in the future should be updated to incorporate a handler for Electron Node dispatch requests

Include options for detailed Rayleight / Mie Scatter and height configurations for complete control over the model for users to include all configurable options

Usage

Create a new atmosphere object and create textures

mSky := NewAtmosphere(45.0, 0.0)
mSky.SetDay(200.2)
base := "sky_"
for i := 0; i < 10; i++ {
  filename := base + strconv.FormatInt(int64(i), 10) + ".png"
  mSky.StepDay(1 + float32(i)/10)
  mSky.CreateTexture(256, 256, filename)
}

Notes

  • Next update will fix the celestial observer model.
  • Fixed Mie Scattering Error where sun disk failed to render
  • Adjust Sky.Light.Lx.Flux settings for sun intensity. Default (20.5)
  • Adjust Mie Scattering Phase Function by tuning g variable, forward scatter coefficient
  • BetaR , BetaM correspond to the extinction coefficients in RGB tristimulus color space. Tune these vectors according to atmopsheric composition to affect atmospheric colors

Todo

  • Eliminate Negative View Vector Evaluations
  • Faciliate Parameter Tuning for the Atmosphere Package as a whole with JSON Configurations
  • Approximate depth integrals for Rayleigh Mie scattering with Pre-Packaged LUTs for algorithmic speedup
  • Implement Volumetric Cloud Features
  • Implement Ozone Extinction

Table of Measurements

phenomena description units underlying units
Flux Radiant Flux Watts kg m^2 s^-3
Wavelength Electromagnetic Wavelength Meters m
Astronomical Units Radii Meters m

Documentation

Index

Constants

View Source
const (
	PI                 = 3.141529
	AXIAL_TILT         = 23.5      //Degrees
	RAYLEIGH_SAMPLES   = 25        //RAYLEIGH sampling
	LIGHT_PATH_SAMPLES = 25        //PATH SAMPLES
	AU                 = 150000000 //SUN
	HM                 = 1500      //AEROSOL MIE SCATTER HEIGHT
	HR                 = 8000      //RAYLEIGH SCATTER HEIGHT

)

Atmosphere environment lighting model.

This model generates a sun position based on lat/long and solar times and then we simulate atmospheric scattering processes via Rayleigh/Mie Scattering.

View Source
const (
	EARTH_RAD = 6370
)

Variables

This section is empty.

Functions

func ImageFromPixels

func ImageFromPixels(pixels []vector.Vec, width int, height int, clamp bool, alpha uint8, filename string)

Utility function creates an image from a set of pixels

Types

type Atmosphere

type Atmosphere struct {
	Light light.Light
	Spd   light.Spectrum
	Sun   polar.Polar //Orbtial Solar System Earth 2 Sun Polar Coordinate
	Earth *EarthCoords
	Day   float32
	Dir   vector.Vec //Euclidian Sun Direction
}

Atmosphere Environment

func NewAtmosphere

func NewAtmosphere(lat float32, long float32) *Atmosphere

Allocates Default Data Structure and Solar Coords Structs

func (*Atmosphere) ComputeAtmosphere

func (sky *Atmosphere) ComputeAtmosphere(uSampleDomain int, vSampleDomain int) []vector.Vec

Maps texel coordinates to spherical coordinate sampler values (-1,1) and stores resultant map in single texture.

func (*Atmosphere) ComputeRegion

func (sky *Atmosphere) ComputeRegion(uSampleDomain int, vSampleDomain int, x_corner int, y_corner int, width int, height int) []vector.Vec

Maps texel coordinates to spherical coordinate sampler values (-1,1) and stores

func (*Atmosphere) CreateEnvBox

func (sky *Atmosphere) CreateEnvBox(width int, height int, clamp bool)

Creates 6-textures from from computed atmosphere, non-clamping allows for HDR storage width and height are the per texture width height values of the image size

func (*Atmosphere) CreateTexture

func (sky *Atmosphere) CreateTexture(width int, height int, clamp bool, filename string)

Creates texture from from computed atmosphere, non-clamping allows for HDR storage

func (*Atmosphere) InitPosition

func (sky *Atmosphere) InitPosition(absDay float32, inclinationOffset float32) error

Initialize sun positional reference coordinates in terms of polar coordinates

func (*Atmosphere) UpdatePosition

func (sky *Atmosphere) UpdatePosition(delta float32) error

Updates sun positional coordinates by rotating Azimuth & Polar coords by delta degrees

func (*Atmosphere) VolumetricScatterRay

func (sky *Atmosphere) VolumetricScatterRay(sample vector.Vec, view vector.Vec) vector.Vec

Given a sampling vector and a viewing direction calculate RGB stimulus return Based on the Attenuation/Mie Phase Scatter/RayleighScatter Terms

type Domain

type Domain struct {
	// contains filtered or unexported fields
}

func (*Domain) Map

func (m *Domain) Map(value float32, domain Domain) float32

Maps a value with an associated domain to this Domain

type EarthCoords

type EarthCoords struct {
	Latitude         float32     //Decimal Lat
	Longitude        float32     //Decimal Long
	PolarCoord       polar.Polar //Polar Axis offset
	StandardMeridian float32     //Longitude Standard Meridian For Local Time Offsets
	DomainOffset     [2]float32  //Domain offsets for polar sampling of sky depths
	GreaterSphere    polar.Polar //Atmospheric Polar Parameters Polar Parameters
}

Earth Coordinates and Greater Earth will not be rotated for simplicity all Polar transformations are added to sun Polar coordinates as negative transforms

func NewEarth

func NewEarth(lat float32, long float32) *EarthCoords

Declare New Sun Environment with Standard Merdian time set for NYC - Sky Functions handle sun rotation

func (*EarthCoords) GetPosition

func (earth *EarthCoords) GetPosition() vector.Vec

func (*EarthCoords) GetRadius

func (earth *EarthCoords) GetRadius() float32

func (*EarthCoords) GetSample

func (earth *EarthCoords) GetSample(uv [2]float32) vector.Vec

Takes clamped [U,V] polar coordinates from [-1,1.0] and returns the ray depth Returns vector with magnitude to fixed point in sky in valid coordinates

func (*EarthCoords) GetSampleDepth

func (earth *EarthCoords) GetSampleDepth(sample vector.Vec) float32

Approximation of sample depth based on Z coordinate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL