├── HosekDataXYZ.h ├── LICENSE.md ├── README.md ├── SunSky.cpp ├── SunSky.h ├── SunSkyTool.cpp ├── VL234f.h ├── gen-images.sh ├── images ├── hosek-1.png ├── hosek-2.png ├── hosek-3.png ├── hosek-4.png ├── hosek-5.png ├── hosek-6.png ├── hosek-7.png ├── hosek-oc-1.png ├── hosek-oc-2.png ├── hosek-oc-3.png ├── hosek-oc-4.png ├── hosek-oc-5.png ├── hosek-oc-6.png ├── hosek-oc-7.png ├── hosek-ocd-1.png ├── hosek-ocd-2.png ├── hosek-ocd-3.png ├── hosek-ocd-4.png ├── hosek-ocd-5.png ├── hosek-ocd-6.png ├── hosek-ocd-7.png ├── hosekBRDF-rd-1.png ├── hosekBRDF-rd-2.png ├── hosekBRDF-rd-3.png ├── hosekBRDF-rd-4.png ├── hosekBRDF-rd-5.png ├── hosekBRDF-rd-6.png ├── hosekBRDF-rd-7.png ├── hosekBRDF-rs-1.png ├── hosekBRDF-rs-2.png ├── hosekBRDF-rs-3.png ├── hosekBRDF-rs-4.png ├── hosekBRDF-rs-5.png ├── hosekBRDF-rs-6.png ├── hosekBRDF-rs-7.png ├── preetham-1.png ├── preetham-2.png ├── preetham-3.png ├── preetham-4.png ├── preetham-5.png ├── preetham-6.png ├── preetham-7.png ├── preetham-oc-1.png ├── preetham-oc-2.png ├── preetham-oc-3.png ├── preetham-oc-4.png ├── preetham-oc-5.png ├── preetham-oc-6.png ├── preetham-oc-7.png ├── preetham-ocd-1.png ├── preetham-ocd-2.png ├── preetham-ocd-3.png ├── preetham-ocd-4.png ├── preetham-ocd-5.png ├── preetham-ocd-6.png ├── preetham-ocd-7.png ├── preethamBRDF-rd-1.png ├── preethamBRDF-rd-2.png ├── preethamBRDF-rd-3.png ├── preethamBRDF-rd-4.png ├── preethamBRDF-rd-5.png ├── preethamBRDF-rd-6.png ├── preethamBRDF-rd-7.png ├── preethamBRDF-rs-1.png ├── preethamBRDF-rs-2.png ├── preethamBRDF-rs-3.png ├── preethamBRDF-rs-4.png ├── preethamBRDF-rs-5.png ├── preethamBRDF-rs-6.png └── preethamBRDF-rs-7.png └── stb_image_mini.h /LICENSE.md: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Overview 2 | ======== 3 | 4 | The code in SunSky.* is an implementation of several sky models: 5 | 6 | * The Preetham Clear Sky model. (From ["A Practical Analytic Model for 7 | Daylight"](https://www.cs.utah.edu/~shirley/papers/sunsky/), Preetham, Shirley 8 | & Smits.) 9 | 10 | * The Hosek Clear Sky model. (From ["An Analytic Model for Full Spectral Sky-Dome 11 | Radiance"](https://cgg.mff.cuni.cz/projects/SkylightModelling/), Hosek & 12 | Wilkie.) 13 | 14 | * Various luminance-only CIE models: 15 | * The Clear Sky model 16 | * The Overcast Sky model 17 | * The Partly(!) Cloudy Sky model 18 | * The more recent fifteen CIE sky models from, e.g., "CIE general sky standard 19 | defining luminance distributions", Darula & Kittler. (There are many variants 20 | of this paper!) 21 | 22 | * The sun model from Preetham (also used by Hosek), and helpers for converting 23 | from time and place to local sun direction. 24 | 25 | In addition, for the Preetham and Hosek models, I have added: 26 | 27 | * Table-driven versions for fast evaluation on the GPU (or indeed CPU) via 28 | 64 x 2 lookup table. 29 | 30 | * Extended table-driven versions that use zonal harmonics to produce approximate 31 | mirror-to-diffuse BRDF power convolutions. These use 64 x 8 or 64 x 16 32 | tables. 33 | 34 | * Proper handling of night transitions. The original models assume the sun 35 | is above the horizon. The supplied code transitions to a dark blue sky as 36 | the sun fully sets, and then to black towards the end of twilight. 37 | 38 | * An extension to allow mixing the clear sky models with an overcast sky 39 | via a simple linear 'overcast' factor. Generally it's best to use this 40 | to simulate high cloud, while low-lying clouds are represented explicitly 41 | in the shader. However, when used for shading rather than skybox display, 42 | it can also represent low-lying cloud cover. 43 | 44 | The Preetham code is a trusty standby, and has been shipped in several games. 45 | 46 | The Hosek code is new, it is a re-implementation of the Hosek paper using 47 | floats, with some minor optimisations, and an attempt to make the structure a 48 | bit more obvious. The CPU-only and table variants are solid, as is the night 49 | transition. The overcast functionality and BRDF convolution might need a bit 50 | more tweaking. 51 | 52 | I would like to provide some sample shaders, but for now look at FillTexture*, 53 | and the Table::SkyRGB() routines. 54 | 55 | 56 | Results 57 | ======= 58 | 59 | Preetham 60 | -------- 61 | 62 | Clear Sky: 63 | 64 | ![](images/preetham-1.png) 65 | ![](images/preetham-2.png) 66 | ![](images/preetham-3.png) 67 | ![](images/preetham-4.png) 68 | ![](images/preetham-5.png) 69 | ![](images/preetham-6.png) 70 | ![](images/preetham-7.png) 71 | 72 | Overcast 50%/Day 73 | 74 | ![](images/preetham-oc-1.png) 75 | ![](images/preetham-oc-2.png) 76 | ![](images/preetham-oc-3.png) 77 | ![](images/preetham-oc-4.png) 78 | ![](images/preetham-oc-5.png) 79 | ![](images/preetham-oc-6.png) 80 | ![](images/preetham-oc-7.png) 81 |
82 | ![](images/preetham-ocd-1.png) 83 | ![](images/preetham-ocd-2.png) 84 | ![](images/preetham-ocd-3.png) 85 | ![](images/preetham-ocd-4.png) 86 | ![](images/preetham-ocd-5.png) 87 | ![](images/preetham-ocd-6.png) 88 | ![](images/preetham-ocd-7.png) 89 | 90 | BRDF Day/Sunset: 91 | 92 | ![](images/preethamBRDF-rd-1.png) 93 | ![](images/preethamBRDF-rd-2.png) 94 | ![](images/preethamBRDF-rd-3.png) 95 | ![](images/preethamBRDF-rd-4.png) 96 | ![](images/preethamBRDF-rd-5.png) 97 | ![](images/preethamBRDF-rd-6.png) 98 | ![](images/preethamBRDF-rd-7.png) 99 |
100 | ![](images/preethamBRDF-rs-1.png) 101 | ![](images/preethamBRDF-rs-2.png) 102 | ![](images/preethamBRDF-rs-3.png) 103 | ![](images/preethamBRDF-rs-4.png) 104 | ![](images/preethamBRDF-rs-5.png) 105 | ![](images/preethamBRDF-rs-6.png) 106 | ![](images/preethamBRDF-rs-7.png) 107 | 108 | Hosek 109 | ----- 110 | 111 | Clear Sky: 112 | 113 | ![](images/hosek-1.png) 114 | ![](images/hosek-2.png) 115 | ![](images/hosek-3.png) 116 | ![](images/hosek-4.png) 117 | ![](images/hosek-5.png) 118 | ![](images/hosek-6.png) 119 | ![](images/hosek-7.png) 120 | 121 | Overcast 50%/Day: 122 | 123 | ![](images/hosek-oc-1.png) 124 | ![](images/hosek-oc-2.png) 125 | ![](images/hosek-oc-3.png) 126 | ![](images/hosek-oc-4.png) 127 | ![](images/hosek-oc-5.png) 128 | ![](images/hosek-oc-6.png) 129 | ![](images/hosek-oc-7.png) 130 |
131 | ![](images/hosek-ocd-1.png) 132 | ![](images/hosek-ocd-2.png) 133 | ![](images/hosek-ocd-3.png) 134 | ![](images/hosek-ocd-4.png) 135 | ![](images/hosek-ocd-5.png) 136 | ![](images/hosek-ocd-6.png) 137 | ![](images/hosek-ocd-7.png) 138 | 139 | BRDF Day/Sunset: 140 | 141 | ![](images/hosekBRDF-rd-1.png) 142 | ![](images/hosekBRDF-rd-2.png) 143 | ![](images/hosekBRDF-rd-3.png) 144 | ![](images/hosekBRDF-rd-4.png) 145 | ![](images/hosekBRDF-rd-5.png) 146 | ![](images/hosekBRDF-rd-6.png) 147 | ![](images/hosekBRDF-rd-7.png) 148 |
149 | ![](images/hosekBRDF-rs-1.png) 150 | ![](images/hosekBRDF-rs-2.png) 151 | ![](images/hosekBRDF-rs-3.png) 152 | ![](images/hosekBRDF-rs-4.png) 153 | ![](images/hosekBRDF-rs-5.png) 154 | ![](images/hosekBRDF-rs-6.png) 155 | ![](images/hosekBRDF-rs-7.png) 156 | 157 | 158 | SunSky Tool 159 | =========== 160 | 161 | Included in SunSkyTool.cpp is a tool exercising most of the sky model 162 | functionality. Current options are below. It can be used to generate top-down 163 | 'hemisphere' views with or without fisheye projection, panoramic views, and 164 | cube maps, with various forms of tonemapping. Both LDR (png) and HDR (pfm) 165 | versions are output. 166 | 167 | Building 168 | -------- 169 | 170 | To build this tool, use 171 | 172 | c++ --std=c++11 -O3 SunSky.cpp SunSkyTool.cpp -o sunsky 173 | 174 | Or add those files to your favourite IDE. 175 | 176 | Options 177 | ------- 178 | 179 | sunsky 180 | 181 | Options: 182 | -h : this help 183 | -t