https://github.com/andrewwillmott/sun-sky
Various sun/sky models, convolution of theta/gamma-parameterised models
https://github.com/andrewwillmott/sun-sky
Last synced: 18 days ago
JSON representation
Various sun/sky models, convolution of theta/gamma-parameterised models
- Host: GitHub
- URL: https://github.com/andrewwillmott/sun-sky
- Owner: andrewwillmott
- License: unlicense
- Created: 2014-06-29T23:51:31.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-04-02T15:30:38.000Z (about 6 years ago)
- Last Synced: 2024-11-14T22:35:34.678Z (6 months ago)
- Language: C++
- Size: 1.57 MB
- Stars: 244
- Watchers: 17
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- AwesomeCppGameDev - sun-sky - parameterised models (Graphics)
README
Overview
========The code in SunSky.* is an implementation of several sky models:
* The Preetham Clear Sky model. (From ["A Practical Analytic Model for
Daylight"](https://www.cs.utah.edu/~shirley/papers/sunsky/), Preetham, Shirley
& Smits.)* The Hosek Clear Sky model. (From ["An Analytic Model for Full Spectral Sky-Dome
Radiance"](https://cgg.mff.cuni.cz/projects/SkylightModelling/), Hosek &
Wilkie.)* Various luminance-only CIE models:
* The Clear Sky model
* The Overcast Sky model
* The Partly(!) Cloudy Sky model
* The more recent fifteen CIE sky models from, e.g., "CIE general sky standard
defining luminance distributions", Darula & Kittler. (There are many variants
of this paper!)* The sun model from Preetham (also used by Hosek), and helpers for converting
from time and place to local sun direction.In addition, for the Preetham and Hosek models, I have added:
* Table-driven versions for fast evaluation on the GPU (or indeed CPU) via
64 x 2 lookup table.* Extended table-driven versions that use zonal harmonics to produce approximate
mirror-to-diffuse BRDF power convolutions. These use 64 x 8 or 64 x 16
tables.* Proper handling of night transitions. The original models assume the sun
is above the horizon. The supplied code transitions to a dark blue sky as
the sun fully sets, and then to black towards the end of twilight.* An extension to allow mixing the clear sky models with an overcast sky
via a simple linear 'overcast' factor. Generally it's best to use this
to simulate high cloud, while low-lying clouds are represented explicitly
in the shader. However, when used for shading rather than skybox display,
it can also represent low-lying cloud cover.The Preetham code is a trusty standby, and has been shipped in several games.
The Hosek code is new, it is a re-implementation of the Hosek paper using
floats, with some minor optimisations, and an attempt to make the structure a
bit more obvious. The CPU-only and table variants are solid, as is the night
transition. The overcast functionality and BRDF convolution might need a bit
more tweaking.I would like to provide some sample shaders, but for now look at FillTexture*,
and the Table::SkyRGB() routines.Results
=======Preetham
--------Clear Sky:






Overcast 50%/Day













BRDF Day/Sunset:













Hosek
-----Clear Sky:






Overcast 50%/Day:













BRDF Day/Sunset:













SunSky Tool
===========Included in SunSkyTool.cpp is a tool exercising most of the sky model
functionality. Current options are below. It can be used to generate top-down
'hemisphere' views with or without fisheye projection, panoramic views, and
cube maps, with various forms of tonemapping. Both LDR (png) and HDR (pfm)
versions are output.Building
--------To build this tool, use
c++ --std=c++11 -O3 SunSky.cpp SunSkyTool.cpp -o sunsky
Or add those files to your favourite IDE.
Options
-------sunsky
Options:
-h : this help
-tskyType:
Preetham (pt)
PreethamTable (ptt)
PreethamBRDF (ptb)
Hosek (hk)
HosekTable (hkt)
HosekBRDF (hkb)
cieClear (cc)
cieOvercast (co)
ciePartlyCloudy (cp)toneMapType:
linear (l)
exponential (ex)
reinhard (rh)Examples
--------Show noon sky for the current time of year using Preetham:
sunsky -t 12
Glossy version of the same sky:
sunsky -t 12 -s preethamBRDF -r 0.3
Hosek sky at 4pm with greenish albedo, high turbidity, and exponential tone
mapping, saved to a cube map:sunsky -t 16 -s hosek -x 0.2 0.5 0.2 -b 6 -e ex -c