{"id":13731632,"url":"https://github.com/andrewwillmott/sun-sky","last_synced_at":"2025-05-08T05:30:27.668Z","repository":{"id":51490251,"uuid":"21334796","full_name":"andrewwillmott/sun-sky","owner":"andrewwillmott","description":"Various sun/sky models, convolution of theta/gamma-parameterised models","archived":false,"fork":false,"pushed_at":"2019-04-02T15:30:38.000Z","size":1645,"stargazers_count":244,"open_issues_count":1,"forks_count":13,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-11-14T22:35:34.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewwillmott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-29T23:51:31.000Z","updated_at":"2024-11-02T12:57:44.000Z","dependencies_parsed_at":"2022-08-22T02:20:31.632Z","dependency_job_id":null,"html_url":"https://github.com/andrewwillmott/sun-sky","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewwillmott%2Fsun-sky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewwillmott%2Fsun-sky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewwillmott%2Fsun-sky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewwillmott%2Fsun-sky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewwillmott","download_url":"https://codeload.github.com/andrewwillmott/sun-sky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253008318,"owners_count":21839627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T02:01:34.412Z","updated_at":"2025-05-08T05:30:27.649Z","avatar_url":"https://github.com/andrewwillmott.png","language":"C++","funding_links":[],"categories":["Graphics"],"sub_categories":[],"readme":"Overview\n========\n\nThe code in SunSky.* is an implementation of several sky models:\n\n* The Preetham Clear Sky model. (From [\"A Practical Analytic Model for\n  Daylight\"](https://www.cs.utah.edu/~shirley/papers/sunsky/), Preetham, Shirley\n  \u0026 Smits.)\n\n* The Hosek Clear Sky model. (From [\"An Analytic Model for Full Spectral Sky-Dome\n  Radiance\"](https://cgg.mff.cuni.cz/projects/SkylightModelling/), Hosek \u0026\n  Wilkie.)\n\n* Various luminance-only CIE models:\n  * The Clear Sky model\n  * The Overcast Sky model\n  * The Partly(!) Cloudy Sky model\n  * The more recent fifteen CIE sky models from, e.g., \"CIE general sky standard\n    defining luminance distributions\", Darula \u0026 Kittler. (There are many variants\n    of this paper!)\n\n* The sun model from Preetham (also used by Hosek), and helpers for converting\n  from time and place to local sun direction.\n\nIn addition, for the Preetham and Hosek models, I have added:\n\n* Table-driven versions for fast evaluation on the GPU (or indeed CPU) via\n  64 x 2 lookup table.\n\n* Extended table-driven versions that use zonal harmonics to produce approximate\n  mirror-to-diffuse BRDF power convolutions. These use 64 x 8 or 64 x 16\n  tables.\n\n* Proper handling of night transitions. The original models assume the sun\n  is above the horizon. The supplied code transitions to a dark blue sky as\n  the sun fully sets, and then to black towards the end of twilight.\n\n* An extension to allow mixing the clear sky models with an overcast sky\n  via a simple linear 'overcast' factor. Generally it's best to use this\n  to simulate high cloud, while low-lying clouds are represented explicitly\n  in the shader. However, when used for shading rather than skybox display,\n  it can also represent low-lying cloud cover.\n\nThe Preetham code is a trusty standby, and has been shipped in several games.\n\nThe Hosek code is new, it is a re-implementation of the Hosek paper using\nfloats, with some minor optimisations, and an attempt to make the structure a\nbit more obvious. The CPU-only and table variants are solid, as is the night\ntransition. The overcast functionality and BRDF convolution might need a bit\nmore tweaking.\n\nI would like to provide some sample shaders, but for now look at FillTexture*,\nand the Table::SkyRGB() routines.\n\n\nResults\n=======\n\nPreetham\n--------\n\nClear Sky:\n\n![](images/preetham-1.png)\n![](images/preetham-2.png)\n![](images/preetham-3.png)\n![](images/preetham-4.png)\n![](images/preetham-5.png)\n![](images/preetham-6.png)\n![](images/preetham-7.png)\n\nOvercast 50%/Day\n\n![](images/preetham-oc-1.png)\n![](images/preetham-oc-2.png)\n![](images/preetham-oc-3.png)\n![](images/preetham-oc-4.png)\n![](images/preetham-oc-5.png)\n![](images/preetham-oc-6.png)\n![](images/preetham-oc-7.png)\n\u003cbr\u003e\n![](images/preetham-ocd-1.png)\n![](images/preetham-ocd-2.png)\n![](images/preetham-ocd-3.png)\n![](images/preetham-ocd-4.png)\n![](images/preetham-ocd-5.png)\n![](images/preetham-ocd-6.png)\n![](images/preetham-ocd-7.png)\n\nBRDF Day/Sunset:\n\n![](images/preethamBRDF-rd-1.png)\n![](images/preethamBRDF-rd-2.png)\n![](images/preethamBRDF-rd-3.png)\n![](images/preethamBRDF-rd-4.png)\n![](images/preethamBRDF-rd-5.png)\n![](images/preethamBRDF-rd-6.png)\n![](images/preethamBRDF-rd-7.png)\n\u003cbr\u003e\n![](images/preethamBRDF-rs-1.png)\n![](images/preethamBRDF-rs-2.png)\n![](images/preethamBRDF-rs-3.png)\n![](images/preethamBRDF-rs-4.png)\n![](images/preethamBRDF-rs-5.png)\n![](images/preethamBRDF-rs-6.png)\n![](images/preethamBRDF-rs-7.png)\n\nHosek\n-----\n\nClear Sky:\n\n![](images/hosek-1.png)\n![](images/hosek-2.png)\n![](images/hosek-3.png)\n![](images/hosek-4.png)\n![](images/hosek-5.png)\n![](images/hosek-6.png)\n![](images/hosek-7.png)\n\nOvercast 50%/Day:\n\n![](images/hosek-oc-1.png)\n![](images/hosek-oc-2.png)\n![](images/hosek-oc-3.png)\n![](images/hosek-oc-4.png)\n![](images/hosek-oc-5.png)\n![](images/hosek-oc-6.png)\n![](images/hosek-oc-7.png)\n\u003cbr\u003e\n![](images/hosek-ocd-1.png)\n![](images/hosek-ocd-2.png)\n![](images/hosek-ocd-3.png)\n![](images/hosek-ocd-4.png)\n![](images/hosek-ocd-5.png)\n![](images/hosek-ocd-6.png)\n![](images/hosek-ocd-7.png)\n\nBRDF Day/Sunset:\n\n![](images/hosekBRDF-rd-1.png)\n![](images/hosekBRDF-rd-2.png)\n![](images/hosekBRDF-rd-3.png)\n![](images/hosekBRDF-rd-4.png)\n![](images/hosekBRDF-rd-5.png)\n![](images/hosekBRDF-rd-6.png)\n![](images/hosekBRDF-rd-7.png)\n\u003cbr\u003e\n![](images/hosekBRDF-rs-1.png)\n![](images/hosekBRDF-rs-2.png)\n![](images/hosekBRDF-rs-3.png)\n![](images/hosekBRDF-rs-4.png)\n![](images/hosekBRDF-rs-5.png)\n![](images/hosekBRDF-rs-6.png)\n![](images/hosekBRDF-rs-7.png)\n\n\nSunSky Tool\n===========\n\nIncluded in SunSkyTool.cpp is a tool exercising most of the sky model\nfunctionality. Current options are below. It can be used to generate top-down\n'hemisphere' views with or without fisheye projection, panoramic views, and\ncube maps, with various forms of tonemapping. Both LDR (png) and HDR (pfm)\nversions are output.\n\nBuilding\n--------\n\nTo build this tool, use\n\n    c++ --std=c++11 -O3 SunSky.cpp SunSkyTool.cpp -o sunsky\n\nOr add those files to your favourite IDE.\n\nOptions\n-------\n\n        sunsky \u003coptions\u003e\n\n        Options:\n          -h : this help\n          -t \u003ctime\u003e          : 0 - 24\n          -d \u003cday of year\u003e   : 0 - 365\n          -b \u003ctubidity\u003e      : 2 - 30\n          -x \u003cground_bounce\u003e : 0 - 1\n          -l \u003clatitude\u003e \u003clongitude\u003e\n          -w \u003cnormalisation weight\u003e\n          -g \u003cgamma\u003e\n          -e \u003ctonemapType\u003e : use given tonemap operator (default: linear)\n          -a : autoscale intensity\n          -i : invert hemisphere\n          -f : fisheye rather than cos projection\n          -c : output cubemap instead\n          -p : output panorama instead\n          -m : output movie, record day as sky.mp4, requires ffmpeg\n          -v : verbose\n          -s \u003cskyType\u003e : use given sky type\n          -r \u003croughness:float\u003e : specify roughness for PreethamBRDF\n\n        skyType:\n          Preetham         (pt)\n          PreethamTable    (ptt)\n          PreethamBRDF     (ptb)\n          Hosek            (hk)\n          HosekTable       (hkt)\n          HosekBRDF        (hkb)\n          cieClear         (cc)\n          cieOvercast      (co)\n          ciePartlyCloudy  (cp)\n\n        toneMapType:\n          linear           (l)\n          exponential      (ex)\n          reinhard         (rh)\n\nExamples\n--------\n\nShow noon sky for the current time of year using Preetham:\n\n        sunsky -t 12\n\nGlossy version of the same sky:\n\n        sunsky -t 12 -s preethamBRDF -r 0.3\n\nHosek sky at 4pm with greenish albedo, high turbidity, and exponential tone\nmapping, saved to a cube map:\n\n        sunsky -t 16 -s hosek -x 0.2 0.5 0.2 -b 6 -e ex -c\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewwillmott%2Fsun-sky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewwillmott%2Fsun-sky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewwillmott%2Fsun-sky/lists"}