summaryrefslogtreecommitdiff
path: root/indra/llinventory/llsettingssky.h
blob: 82c2d6a8049f686360c3b3dbb6744a41c7064c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
/**
* @file llsettingssky.h
* @author optional
* @brief A base class for asset based settings groups.
*
* $LicenseInfo:2011&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2017, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
* $/LicenseInfo$
*/

#ifndef LL_SETTINGS_SKY_H
#define LL_SETTINGS_SKY_H

#include "llsettingsbase.h"
#include "v4coloru.h"

class LLSettingsSky: public LLSettingsBase
{
public:
    static const std::string SETTING_AMBIENT;
    static const std::string SETTING_BLOOM_TEXTUREID;
    static const std::string SETTING_BLUE_DENSITY;
    static const std::string SETTING_BLUE_HORIZON;
    static const std::string SETTING_DENSITY_MULTIPLIER;
    static const std::string SETTING_DISTANCE_MULTIPLIER;
    static const std::string SETTING_HAZE_DENSITY;
    static const std::string SETTING_HAZE_HORIZON;
    static const std::string SETTING_CLOUD_COLOR;
    static const std::string SETTING_CLOUD_POS_DENSITY1;
    static const std::string SETTING_CLOUD_POS_DENSITY2;
    static const std::string SETTING_CLOUD_SCALE;
    static const std::string SETTING_CLOUD_SCROLL_RATE;
    static const std::string SETTING_CLOUD_SHADOW;
    static const std::string SETTING_CLOUD_TEXTUREID;
    static const std::string SETTING_DOME_OFFSET;
    static const std::string SETTING_DOME_RADIUS;
    static const std::string SETTING_GAMMA;
    static const std::string SETTING_GLOW;    
    static const std::string SETTING_LIGHT_NORMAL;
    static const std::string SETTING_MAX_Y;
    static const std::string SETTING_MOON_ROTATION;
    static const std::string SETTING_MOON_TEXTUREID;
    static const std::string SETTING_STAR_BRIGHTNESS;
    static const std::string SETTING_SUNLIGHT_COLOR;
    static const std::string SETTING_SUN_ROTATION;
    static const std::string SETTING_SUN_TEXTUREID;

    static const std::string SETTING_PLANET_RADIUS;
    static const std::string SETTING_SKY_BOTTOM_RADIUS;
    static const std::string SETTING_SKY_TOP_RADIUS;
    static const std::string SETTING_SUN_ARC_RADIANS;

    static const std::string SETTING_RAYLEIGH_CONFIG;
    static const std::string SETTING_MIE_CONFIG;
    static const std::string SETTING_ABSORPTION_CONFIG;

    static const std::string KEY_DENSITY_PROFILE;
        static const std::string SETTING_DENSITY_PROFILE_WIDTH;
        static const std::string SETTING_DENSITY_PROFILE_EXP_TERM;
        static const std::string SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR;
        static const std::string SETTING_DENSITY_PROFILE_LINEAR_TERM;
        static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM;
        static const std::string SETTING_MIE_ANISOTROPY_FACTOR;

    static const LLUUID DEFAULT_SUN_ID;
    static const LLUUID DEFAULT_MOON_ID;
    static const LLUUID DEFAULT_CLOUD_ID;

    static const LLUUID DEFAULT_ASSET_ID;

    typedef std::shared_ptr<LLSettingsSky> ptr_t;
    typedef std::pair<F32, F32> azimalt_t;

    //---------------------------------------------------------------------
    LLSettingsSky(const LLSD &data);
    virtual ~LLSettingsSky() { };

    virtual ptr_t   buildClone() = 0;

    //---------------------------------------------------------------------
    virtual std::string getSettingType() const override { return std::string("sky"); }
    virtual LLSettingsType::type_e getSettingTypeValue() const override { return LLSettingsType::ST_SKY; }


    // Settings status 
    virtual void blend(const LLSettingsBase::ptr_t &end, F64 blendf) override;
    
    static LLSD defaults();

    LLUUID getBloomTextureId() const
    {
        return mSettings[SETTING_BLOOM_TEXTUREID].asUUID();
    }

    //---------------------------------------------------------------------
    LLColor3 getAmbientColor() const
    {
        return LLColor3(mSettings[SETTING_AMBIENT]);
    }

    void setAmbientColor(const LLColor3 &val)
    {
        setValue(SETTING_AMBIENT, val);
    }

    LLColor3 getBlueDensity() const
    {
        return LLColor3(mSettings[SETTING_BLUE_DENSITY]);
    }

    void setBlueDensity(const LLColor3 &val)
    {
        setValue(SETTING_BLUE_DENSITY, val);
    }

    LLColor3 getBlueHorizon() const
    {
        return LLColor3(mSettings[SETTING_BLUE_HORIZON]);
    }

    void setBlueHorizon(const LLColor3 &val)
    {
        setValue(SETTING_BLUE_HORIZON, val);
    }

    F32 getDensityMultiplier() const
    {
        return mSettings[SETTING_DENSITY_MULTIPLIER].asReal();
    }

    void setDensityMultiplier(F32 val)
    {
        setValue(SETTING_DENSITY_MULTIPLIER, val);
    }

    F32 getDistanceMultiplier() const
    {
        return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal();
    }

    void setDistanceMultiplier(F32 val)
    {
        setValue(SETTING_DISTANCE_MULTIPLIER, val);
    }

    F32 getHazeDensity() const
    {
        return mSettings[SETTING_HAZE_DENSITY].asReal();
    }

    void setHazeDensity(F32 val)
    {
        setValue(SETTING_HAZE_DENSITY, val);
    }

    F32 getHazeHorizon() const
    {
        return mSettings[SETTING_HAZE_HORIZON].asReal();
    }

    void setHazeHorizon(F32 val)
    {
        setValue(SETTING_HAZE_HORIZON, val);
    }

    LLColor3 getCloudColor() const
    {
        return LLColor3(mSettings[SETTING_CLOUD_COLOR]);
    }

    void setCloudColor(const LLColor3 &val)
    {
        setValue(SETTING_CLOUD_COLOR, val);
    }

    LLUUID getCloudNoiseTextureId() const
    {
        return mSettings[SETTING_CLOUD_TEXTUREID].asUUID();
    }

    void setCloudNoiseTextureId(const LLUUID &id)
    {
        setValue(SETTING_CLOUD_TEXTUREID, id);
    }

    LLColor3 getCloudPosDensity1() const
    {
        return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]);
    }

    void setCloudPosDensity1(const LLColor3 &val)
    {
        setValue(SETTING_CLOUD_POS_DENSITY1, val);
    }

    LLColor3 getCloudPosDensity2() const
    {
        return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]);
    }

    void setCloudPosDensity2(const LLColor3 &val)
    {
        setValue(SETTING_CLOUD_POS_DENSITY2, val);
    }

    F32 getCloudScale() const
    {
        return mSettings[SETTING_CLOUD_SCALE].asReal();
    }

    void setCloudScale(F32 val)
    {
        setValue(SETTING_CLOUD_SCALE, val);
    }

    LLVector2 getCloudScrollRate() const
    {
        return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]);
    }

    void setCloudScrollRate(const LLVector2 &val)
    {
        setValue(SETTING_CLOUD_SCROLL_RATE, val);
    }

    void setCloudScrollRateX(F32 val)
    {
        mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val;
        setDirtyFlag(true);
    }

    void setCloudScrollRateY(F32 val)
    {
        mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val;
        setDirtyFlag(true);
    }

    F32 getCloudShadow() const
    {
        return mSettings[SETTING_CLOUD_SHADOW].asReal();
    }

    void setCloudShadow(F32 val)
    {
        setValue(SETTING_CLOUD_SHADOW, val);
    }

    
    F32 getDomeOffset() const
    {
        return DOME_OFFSET;
        //return mSettings[SETTING_DOME_OFFSET].asReal();
    }

    F32 getDomeRadius() const
    {
        return DOME_RADIUS;
        //return mSettings[SETTING_DOME_RADIUS].asReal();
    }

    F32 getGamma() const
    {
        return mSettings[SETTING_GAMMA].asReal();
    }

    void setGamma(F32 val)
    {
        mSettings[SETTING_GAMMA] = LLSD::Real(val);
        setDirtyFlag(true);
    }

    LLColor3 getGlow() const
    {
        return LLColor3(mSettings[SETTING_GLOW]);
    }

    void setGlow(const LLColor3 &val)
    {
        setValue(SETTING_GLOW, val);
    }

    LLVector3 getLightNormal() const
    {
        return LLVector3(mSettings[SETTING_LIGHT_NORMAL]);
    }

    void setLightNormal(const LLVector3 &val) 
    {
        setValue(SETTING_LIGHT_NORMAL, val);
    }

    F32 getMaxY() const
    {
        return mSettings[SETTING_MAX_Y].asReal();
    }

    void setMaxY(F32 val) 
    {
        setValue(SETTING_MAX_Y, val);
    }

    LLQuaternion getMoonRotation() const
    {
        return LLQuaternion(mSettings[SETTING_MOON_ROTATION]);
    }

    void setMoonRotation(const LLQuaternion &val)
    {
        setValue(SETTING_MOON_ROTATION, val);
    }

    azimalt_t getMoonRotationAzAl() const;

    void setMoonRotation(F32 azimuth, F32 altitude);

    void setMoonRotation(const azimalt_t &azialt)
    {
        setMoonRotation(azialt.first, azialt.second);
    }

    LLUUID getMoonTextureId() const
    {
        return mSettings[SETTING_MOON_TEXTUREID].asUUID();
    }

    void setMoonTextureId(LLUUID id)
    {
        setValue(SETTING_MOON_TEXTUREID, id);
    }

    F32 getStarBrightness() const
    {
        return mSettings[SETTING_STAR_BRIGHTNESS].asReal();
    }

    void setStarBrightness(F32 val)
    {
        setValue(SETTING_STAR_BRIGHTNESS, val);
    }

    LLColor3 getSunlightColor() const
    {
        return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]);
    }

    void setSunlightColor(const LLColor3 &val)
    {
        setValue(SETTING_SUNLIGHT_COLOR, val);
    }

    LLQuaternion getSunRotation() const
    {
        return LLQuaternion(mSettings[SETTING_SUN_ROTATION]);
    }

    azimalt_t getSunRotationAzAl() const;

    void setSunRotation(const LLQuaternion &val) 
    {
        setValue(SETTING_SUN_ROTATION, val);
    }

    void setSunRotation(F32 azimuth, F32 altitude);

    void setSunRotation(const azimalt_t & azimalt)
    {
        setSunRotation(azimalt.first, azimalt.second);
    }

    LLUUID getSunTextureId() const
    {
        return mSettings[SETTING_SUN_TEXTUREID].asUUID();
    }

    void setSunTextureId(LLUUID id) 
    {
        setValue(SETTING_SUN_TEXTUREID, id);
    }

    // Internal/calculated settings
    LLVector3 getLightDirection() const
    {
        update();
        return mLightDirection;
    };

    LLVector3 getClampedLightDirection() const
    {
        update();
        return mClampedLightDirection;
    };

    LLVector3   getSunDirection() const
    {
        update();
        return mSunDirection;
    }

    LLVector3   getMoonDirection() const
    {
        update();
        return mMoonDirection;
    }

    LLColor4U   getFadeColor() const
    {
        update();
        return mFadeColor;
    }

    LLColor4    getMoonAmbient() const
    {
        update();
        return mMoonAmbient;
    }

    LLColor3    getMoonDiffuse() const
    {
        update();
        return mMoonDiffuse;
    }

    LLColor4    getSunAmbient() const
    {
        update();
        return mSunAmbient;
    }

    LLColor3    getSunDiffuse() const
    {
        update();
        return mSunDiffuse;
    }

    LLColor4    getTotalAmbient() const
    {
        update();
        return mTotalAmbient;
    }

    //=====================================================================
    virtual void                loadTextures() { };

    //=====================================================================
    virtual validation_list_t   getValidationList() const override;
    static validation_list_t    validationList();

    static LLSD                 translateLegacySettings(LLSD legacy);

    //=====================================================================
    // transient properties used in animations.
    LLUUID getNextSunTextureId() const
    {
        return mNextSunTextureId;
    }

    LLUUID getNextMoonTextureId() const
    {
        return mNextMoonTextureId;
    }

    LLUUID getNextCloudNoiseTextureId() const
    {
        return mNextCloudTextureId;
    }

    virtual LLSettingsBase::ptr_t buildDerivedClone() override { return buildClone(); }

protected:
    static const std::string SETTING_LEGACY_EAST_ANGLE;
    static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL;
    static const std::string SETTING_LEGACY_SUN_ANGLE;

    LLSettingsSky();

    virtual stringset_t getSlerpKeys() const override;

    virtual void    updateSettings() override;

private:
    static LLSD rayleighConfigDefault();
    static LLSD absorptionConfigDefault();
    static LLSD mieConfigDefault();

    static const F32         NIGHTTIME_ELEVATION;
    static const F32         NIGHTTIME_ELEVATION_COS;

    void        calculateHeavnlyBodyPositions();
    void        calculateLightSettings();

    LLVector3   mSunDirection;
    LLVector3   mMoonDirection;
    LLVector3   mLightDirection;
    LLVector3   mClampedLightDirection;

    static const F32 DOME_RADIUS;
    static const F32 DOME_OFFSET;

    LLColor4U   mFadeColor;
    LLColor4    mMoonAmbient;
    LLColor3    mMoonDiffuse;
    LLColor4    mSunAmbient;
    LLColor3    mSunDiffuse;

    LLColor4    mTotalAmbient;

    LLUUID      mNextSunTextureId;
    LLUUID      mNextMoonTextureId;
    LLUUID      mNextCloudTextureId;

    typedef std::map<std::string, S32> mapNameToUniformId_t;

    static mapNameToUniformId_t sNameToUniformMapping;
};

#endif