| 25 | } |
| 26 | |
| 27 | void SkyCache::Init(Float3 sunDirection, Float3 groundAlbedo, float turbidity) |
| 28 | { |
| 29 | sunDirection.y = Saturate(sunDirection.y); |
| 30 | sunDirection = Float3::Normalize(sunDirection); |
| 31 | turbidity = Clamp(turbidity, 1.0f, 32.0f); |
| 32 | groundAlbedo = Saturate(groundAlbedo); |
| 33 | |
| 34 | if(StateR != nullptr && sunDirection == SunDirection |
| 35 | && groundAlbedo == Albedo && turbidity == Turbidity) |
| 36 | return; |
| 37 | |
| 38 | Shutdown(); |
| 39 | |
| 40 | float thetaS = AngleBetween(sunDirection, Float3(0, 1, 0)); |
| 41 | float elevation = Pi_2 - thetaS; |
| 42 | StateR = arhosek_rgb_skymodelstate_alloc_init(turbidity, groundAlbedo.x, elevation); |
| 43 | StateG = arhosek_rgb_skymodelstate_alloc_init(turbidity, groundAlbedo.y, elevation); |
| 44 | StateB = arhosek_rgb_skymodelstate_alloc_init(turbidity, groundAlbedo.z, elevation); |
| 45 | |
| 46 | Albedo = groundAlbedo; |
| 47 | Elevation = elevation; |
| 48 | SunDirection = sunDirection; |
| 49 | Turbidity = turbidity; |
| 50 | } |
| 51 | |
| 52 | void SkyCache::Shutdown() |
| 53 | { |
no test coverage detected