< Summary

Class:DCL.Skybox.SkyboxConfiguration
Assembly:ProceduralSkybox
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/SkyboxConfiguration.cs
Covered lines:0
Uncovered lines:379
Coverable lines:379
Total lines:825
Line coverage:0% (0 of 379)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SkyboxConfiguration()0%2100%
ApplyOnMaterial(...)0%30500%
ApplyInWorldAvatarColor(...)0%72800%
ApplyEditorAvatarColor()0%2100%
ApplyAllSlots(...)0%20400%
GetActiveLayer(...)0%90900%
CheckAndFireTimelineEvents(...)0%2401500%
CycleResets()0%20400%
ApplyDLIntensity(...)0%20400%
ApplyDLDirection(...)0%56700%
ApplyTextureLayer(...)0%90900%
CheckFadingIn(...)0%12300%
CheckFadingOut(...)0%20400%
ApplyCubemapTextureLayer(...)0%12300%
ApplyPlanarTextureLayer(...)0%20400%
ApplySatelliteTextureLayer(...)0%6200%
ApplyParticleTextureLayer(...)0%2100%
GetTransitionValue(...)0%56700%
GetTransitionValue(...)0%56700%
GetTransitionValue(...)0%56700%
ResetMaterial(...)0%6200%
ResetSlot(...)0%2100%
Vector4ToQuaternion(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/SkyboxConfiguration.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using DCL.Helpers;
 6
 7namespace DCL.Skybox
 8{
 9    //[CreateAssetMenu(fileName = "Skybox Configuration", menuName = "ScriptableObjects/SkyboxConfiguration", order = 1)
 10    public class SkyboxConfiguration : ScriptableObject
 11    {
 12        public delegate void TimelineEvents(string tag, bool enable, bool trigger);
 13        public event TimelineEvents OnTimelineEvent;
 14
 15        // ID
 16        public string skyboxID;
 17
 18        // Background Color
 019        public Gradient skyColor = new Gradient();
 020        public Gradient horizonColor = new Gradient();
 021        public Gradient groundColor = new Gradient();
 22
 23        // Horizon Layer
 024        public List<TransitioningFloat> horizonWidth = new List<TransitioningFloat>();
 025        public List<TransitioningFloat> horizonHeight = new List<TransitioningFloat>();
 26        public Texture2D horizonMask;
 027        public Vector3 horizonMaskValues = new Vector3(0, 0, 0);
 028        public Gradient horizonPlaneColor = new Gradient();
 029        public List<TransitioningFloat> horizonPlaneHeight = new List<TransitioningFloat>();
 30
 31        // Ambient Color
 032        public bool ambientTrilight = true;
 033        public Gradient ambientSkyColor = new Gradient();
 034        public Gradient ambientEquatorColor = new Gradient();
 035        public Gradient ambientGroundColor = new Gradient();
 36
 37        // Avatar Color
 038        public bool useAvatarGradient = true;
 039        public Gradient avatarTintGradient = new Gradient();
 040        public Color avatarTintColor = Color.white;
 041        public bool useAvatarRealtimeDLDirection = true;
 042        public Vector3 avatarLightConstantDir = new Vector3(-18f, 144f, -72f);
 043        public bool useAvatarRealtimeLightColor = true;
 044        public Gradient avatarLightColorGradient = new Gradient();
 45
 46        // Avatar Editor Color
 047        public Color avatarEditorTintColor = Color.white;
 048        public Vector3 avatarEditorLightDir = new Vector3(-18f, 144f, -72f);
 049        public Color avatarEditorLightColor = Color.white;
 50
 51        // Fog Properties
 52        public bool useFog = false;
 053        public FogMode fogMode = FogMode.ExponentialSquared;
 054        public Gradient fogColor = new Gradient();
 055        public float fogDensity = 0.05f;
 56        public float fogStartDistance = 0;
 057        public float fogEndDistance = 300;
 58
 59        // DirectionalLight Properties
 060        public bool useDirectionalLight = true;
 061        public DirectionalLightAttributes directionalLightLayer = new DirectionalLightAttributes();
 62
 63        // Layers
 064        public List<TextureLayer> layers = new List<TextureLayer>();
 65
 66        // Timeline Tags
 067        public List<TimelineTagsDuration> timelineTags = new List<TimelineTagsDuration>();
 68
 069        private float cycleTime = 24;
 70
 71        public void ApplyOnMaterial(Material selectedMat, float dayTime, float normalizedDayTime, int slotCount = 5, Lig
 72        {
 073            float percentage = normalizedDayTime * 100;
 74
 75            // General Values
 076            selectedMat.SetColor(SkyboxShaderUtils.LightTint, directionalLightLayer.tintColor.Evaluate(normalizedDayTime
 077            selectedMat.SetVector(SkyboxShaderUtils.LightDirection, directionalLightGO.transform.rotation.eulerAngles);
 78
 79            // Apply Base Values
 080            selectedMat.SetColor(SkyboxShaderUtils.SkyColor, skyColor.Evaluate(normalizedDayTime));
 081            selectedMat.SetColor(SkyboxShaderUtils.GroundColor, groundColor.Evaluate(normalizedDayTime));
 82
 83            // Apply Horizon Values
 084            selectedMat.SetColor(SkyboxShaderUtils.HorizonColor, horizonColor.Evaluate(normalizedDayTime));
 085            selectedMat.SetFloat(SkyboxShaderUtils.HorizonHeight, GetTransitionValue(horizonHeight, percentage, 0f));
 086            selectedMat.SetFloat(SkyboxShaderUtils.HorizonWidth, GetTransitionValue(horizonWidth, percentage, 0f));
 087            selectedMat.SetTexture(SkyboxShaderUtils.HorizonMask, horizonMask);
 088            selectedMat.SetVector(SkyboxShaderUtils.HorizonMaskValues, horizonMaskValues);
 089            selectedMat.SetColor(SkyboxShaderUtils.HorizonPlaneColor, horizonPlaneColor.Evaluate(normalizedDayTime));
 090            selectedMat.SetFloat(SkyboxShaderUtils.HorizonPlaneHeight, GetTransitionValue(horizonPlaneHeight, percentage
 91
 92
 93            // Apply Ambient colors to the rendering settings
 094            if (ambientTrilight)
 95            {
 096                RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Trilight;
 097                RenderSettings.ambientSkyColor = ambientSkyColor.Evaluate(normalizedDayTime);
 098                RenderSettings.ambientEquatorColor = ambientEquatorColor.Evaluate(normalizedDayTime);
 099                RenderSettings.ambientGroundColor = ambientGroundColor.Evaluate(normalizedDayTime);
 0100            }
 101            else
 102            {
 0103                RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox;
 104            }
 105
 106            //Fog Values
 0107            RenderSettings.fog = useFog;
 0108            if (useFog)
 109            {
 0110                RenderSettings.fogColor = fogColor.Evaluate(normalizedDayTime);
 0111                RenderSettings.fogMode = fogMode;
 0112                switch (fogMode)
 113                {
 114                    case FogMode.Linear:
 0115                        RenderSettings.fogStartDistance = fogStartDistance;
 0116                        RenderSettings.fogEndDistance = fogEndDistance;
 0117                        break;
 118                    default:
 0119                        RenderSettings.fogDensity = fogDensity;
 120                        break;
 121                }
 122            }
 123
 124            //Directional List
 0125            if (useDirectionalLight)
 126            {
 127                // Apply Direction light color
 0128                directionalLightGO.color = directionalLightLayer.lightColor.Evaluate(normalizedDayTime);
 129
 130                // Apply direction
 0131                ApplyDLDirection(normalizedDayTime, directionalLightGO);
 132
 133                // Apply Intensity
 0134                ApplyDLIntensity(normalizedDayTime, directionalLightGO);
 0135            }
 136            else
 137            {
 0138                directionalLightGO.gameObject.SetActive(false);
 139            }
 140
 141            // Check and Fire timeline events
 0142            CheckAndFireTimelineEvents(dayTime);
 143
 0144            ApplyAllSlots(selectedMat, dayTime, normalizedDayTime, slotCount, cycleTime);
 0145        }
 146
 147        public void ApplyInWorldAvatarColor(float normalizedDayTime, GameObject directionalLightGO)
 148        {
 0149            if (useAvatarGradient)
 150            {
 0151                Shader.SetGlobalColor(ShaderUtils.TintColor, avatarTintGradient.Evaluate(normalizedDayTime));
 0152            }
 153            else
 154            {
 0155                Shader.SetGlobalColor(ShaderUtils.TintColor, avatarTintColor);
 156            }
 157
 158            // Apply Avatar Light Direction
 0159            if (!useAvatarRealtimeDLDirection || directionalLightGO == null || !useDirectionalLight)
 160            {
 0161                Shader.SetGlobalVector(ShaderUtils.LightDir, avatarLightConstantDir / 180);
 0162            }
 163            else
 164            {
 0165                Vector3 tempDir = directionalLightGO.transform.rotation.eulerAngles;
 0166                Shader.SetGlobalVector(ShaderUtils.LightDir, tempDir / 180);
 167            }
 168
 169            // Apply Avatar Light Color
 0170            if (!useAvatarRealtimeLightColor || directionalLightGO == null || !useDirectionalLight)
 171            {
 0172                Shader.SetGlobalColor(ShaderUtils.LightColor, avatarLightColorGradient.Evaluate(normalizedDayTime));
 0173            }
 174            else
 175            {
 0176                Shader.SetGlobalColor(ShaderUtils.LightColor, directionalLightLayer.lightColor.Evaluate(normalizedDayTim
 177            }
 0178        }
 179
 180        public void ApplyEditorAvatarColor()
 181        {
 0182            Shader.SetGlobalColor(ShaderUtils.TintColor, avatarEditorTintColor);
 0183            Shader.SetGlobalVector(ShaderUtils.LightDir, avatarEditorLightDir / 180);
 0184            Shader.SetGlobalColor(ShaderUtils.LightColor, avatarEditorLightColor);
 0185        }
 186
 187        void ApplyAllSlots(Material selectedMat, float dayTime, float normalizedDayTime, int slotCount = 5, float cycleT
 188        {
 0189            for (int i = 0; i < slotCount; i++)
 190            {
 0191                TextureLayer layer = GetActiveLayer(dayTime, i);
 192
 0193                if (layer == null || !layer.enabled)
 194                {
 0195                    ResetSlot(selectedMat, i);
 0196                    continue;
 197                }
 198
 0199                ApplyTextureLayer(selectedMat, dayTime, normalizedDayTime, i, layer, cycleTime);
 200            }
 0201        }
 202
 203        public TextureLayer GetActiveLayer(float currentTime, int slotID)
 204        {
 0205            TextureLayer temp = null;
 206
 0207            for (int i = 0; i < layers.Count; i++)
 208            {
 0209                if (layers[i].slotID != slotID)
 210                {
 211                    continue;
 212                }
 213
 0214                float endTimeEdited = layers[i].timeSpan_End;
 0215                float dayTimeEdited = currentTime;
 216
 0217                if (layers[i].timeSpan_End < layers[i].timeSpan_start)
 218                {
 0219                    endTimeEdited = cycleTime + layers[i].timeSpan_End;
 0220                    if (currentTime < layers[i].timeSpan_start)
 221                    {
 0222                        dayTimeEdited = cycleTime + currentTime;
 223                    }
 224                }
 225
 0226                if (dayTimeEdited >= layers[i].timeSpan_start && dayTimeEdited <= endTimeEdited)
 227                {
 0228                    if (layers[i].enabled)
 229                    {
 0230                        if (temp == null)
 231                        {
 0232                            layers[i].renderType = LayerRenderType.Rendering;
 0233                            temp = layers[i];
 0234                        }
 235                        else
 236                        {
 0237                            temp.renderType = LayerRenderType.Conflict_Playing;
 0238                            layers[i].renderType = LayerRenderType.Conflict_NotPlaying;
 239                        }
 0240                    }
 241                    else
 242                    {
 0243                        layers[i].renderType = LayerRenderType.NotRendering;
 244                    }
 0245                }
 246                else
 247                {
 0248                    layers[i].renderType = LayerRenderType.NotRendering;
 249                }
 250
 251
 252            }
 0253            return temp;
 254        }
 255
 256        #region Timeline Events
 257
 258        /// <summary>
 259        /// Check if any event has to be fired
 260        /// TODO:: Can be optimised.
 261        /// </summary>
 262        /// <param name="dayTime">Current day time</param>
 263        private void CheckAndFireTimelineEvents(float dayTime)
 264        {
 0265            float endTimeEdited = 0;
 0266            float dayTimeEdited = dayTime;
 0267            for (int i = 0; i < timelineTags.Count; i++)
 268            {
 269                // If current event is a trigger event, fire trigger event. It's boolean will be disable when cycle rese
 0270                if (timelineTags[i].isTrigger)
 271                {
 0272                    if (dayTime > timelineTags[i].startTime && !timelineTags[i].startEventExecuted)
 273                    {
 0274                        OnTimelineEvent?.Invoke(timelineTags[i].tag, true, true);
 0275                        timelineTags[i].startEventExecuted = true;
 276                    }
 0277                    continue;
 278                }
 279
 280
 0281                endTimeEdited = timelineTags[i].endTime;
 0282                dayTimeEdited = dayTime;
 283
 284                // Change time if this is over a day scenario
 0285                if (timelineTags[i].endTime < timelineTags[i].startTime)
 286                {
 0287                    endTimeEdited = cycleTime + timelineTags[i].endTime;
 288
 0289                    if (dayTime < timelineTags[i].startTime)
 290                    {
 0291                        dayTimeEdited = cycleTime + dayTime;
 292                    }
 293                }
 294
 295                // If current time is between start and end time and start event is not executed, Fire start event
 0296                if (dayTimeEdited >= timelineTags[i].startTime && dayTimeEdited < endTimeEdited && !timelineTags[i].star
 297                {
 0298                    OnTimelineEvent?.Invoke(timelineTags[i].tag, true, false);
 0299                    timelineTags[i].startEventExecuted = true;
 300                }
 301
 302                // If current time is greater than end time and start event is executed, fire end event
 0303                if (dayTimeEdited >= endTimeEdited && timelineTags[i].startEventExecuted)
 304                {
 0305                    OnTimelineEvent?.Invoke(timelineTags[i].tag, false, false);
 0306                    timelineTags[i].startEventExecuted = false;
 307                }
 308
 309            }
 0310        }
 311
 312        public void CycleResets()
 313        {
 314            // Resets all timeline triggers and normal flow events
 0315            for (int i = 0; i < timelineTags.Count; i++)
 316            {
 0317                if (timelineTags[i].isTrigger)
 318                {
 0319                    timelineTags[i].startEventExecuted = false;
 0320                    continue;
 321                }
 322
 0323                if (timelineTags[i].endTime > timelineTags[i].startTime)
 324                {
 0325                    timelineTags[i].startEventExecuted = false;
 326                }
 327            }
 0328        }
 329
 330        #endregion
 331
 332        #region Directional Light
 333
 334        void ApplyDLIntensity(float normalizedDayTime, Light lightGO)
 335        {
 0336            if (lightGO == null)
 337            {
 0338                Debug.LogError("Directional Light option is on, with light reference");
 0339                return;
 340            }
 341
 0342            if (directionalLightLayer.intensity.Count == 0)
 343            {
 0344                Debug.Log("Directional Light option is on with no intensity data");
 0345                return;
 346            }
 347
 0348            if (directionalLightLayer.intensity.Count == 1)
 349            {
 0350                lightGO.intensity = directionalLightLayer.intensity[0].value;
 0351                return;
 352            }
 353
 354
 0355            lightGO.intensity = GetTransitionValue(directionalLightLayer.intensity, normalizedDayTime * 100);
 0356        }
 357
 358        void ApplyDLDirection(float normalizedDayTime, Light lightGO)
 359        {
 0360            if (lightGO == null)
 361            {
 0362                return;
 363            }
 364
 0365            if (directionalLightLayer.lightDirection.Count == 0)
 366            {
 0367                return;
 368            }
 369
 0370            if (directionalLightLayer.lightDirection.Count == 1)
 371            {
 0372                lightGO.transform.rotation = directionalLightLayer.lightDirection[0].value;
 0373                return;
 374            }
 375
 0376            float percentage = normalizedDayTime * 100;
 0377            TransitioningQuaternion min = directionalLightLayer.lightDirection[0], max = directionalLightLayer.lightDire
 378
 379            // Apply Direction
 0380            for (int i = 0; i < directionalLightLayer.lightDirection.Count; i++)
 381            {
 0382                if (percentage <= directionalLightLayer.lightDirection[i].percentage)
 383                {
 0384                    max = directionalLightLayer.lightDirection[i];
 385
 0386                    if ((i - 1) > 0)
 387                    {
 0388                        min = directionalLightLayer.lightDirection[i - 1];
 389                    }
 390
 0391                    break;
 392                }
 393            }
 394
 0395            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 0396            lightGO.transform.rotation = Quaternion.Lerp(min.value, max.value, t);
 0397        }
 398
 399        #endregion
 400
 401        #region Apply texture layers
 402
 403        void ApplyTextureLayer(Material selectedMat, float dayTime, float normalizedDayTime, int slotNum, TextureLayer l
 404        {
 0405            float endTimeEdited = layer.timeSpan_End;
 0406            float dayTimeEdited = dayTime;
 0407            if (layer.timeSpan_End < layer.timeSpan_start)
 408            {
 0409                endTimeEdited = cycleTime + layer.timeSpan_End;
 0410                if (dayTime < layer.timeSpan_start)
 411                {
 0412                    dayTimeEdited = cycleTime + dayTime;
 413                }
 414            }
 0415            float normalizedLayerTime = Mathf.InverseLerp(layer.timeSpan_start, endTimeEdited, dayTimeEdited);
 416
 0417            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_layerType_" + slotNum), (int)layer.layerType);
 418
 0419            bool fadeInChange = CheckFadingIn(selectedMat, dayTime, normalizedDayTime, slotNum, layer, cycleTime);
 420
 0421            bool fadeOutChange = CheckFadingOut(selectedMat, dayTime, normalizedDayTime, slotNum, layer, cycleTime);
 422
 0423            if (!fadeInChange && !fadeOutChange)
 424            {
 0425                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_fadeTime_" + slotNum), 1);
 426            }
 427
 0428            switch (layer.layerType)
 429            {
 430                case LayerType.Planar:
 431                case LayerType.Radial:
 0432                    ApplyPlanarTextureLayer(selectedMat, dayTime, normalizedLayerTime, slotNum, layer, true);
 0433                    break;
 434                case LayerType.Satellite:
 0435                    ApplySatelliteTextureLayer(selectedMat, dayTime, normalizedLayerTime, slotNum, layer, true);
 0436                    break;
 437                case LayerType.Cubemap:
 0438                    ApplyCubemapTextureLayer(selectedMat, dayTime, normalizedLayerTime, slotNum, layer, true);
 0439                    break;
 440                case LayerType.Particles:
 0441                    ApplyParticleTextureLayer(selectedMat, dayTime, normalizedLayerTime, slotNum, layer, true);
 442                    break;
 443                default:
 444                    break;
 445            }
 0446        }
 447
 448        private bool CheckFadingIn(Material selectedMat, float dayTime, float normalizedDayTime, int slotNum, TextureLay
 449        {
 0450            bool fadeChanged = false;
 0451            float fadeInCompletionTime = layer.timeSpan_start + layer.fadingInTime;
 0452            float dayTimeEdited = dayTime;
 0453            if (dayTime < layer.timeSpan_start)
 454            {
 0455                dayTimeEdited = 24 + dayTime;
 456            }
 457
 0458            if (dayTimeEdited < fadeInCompletionTime)
 459            {
 0460                float percentage = Mathf.InverseLerp(layer.timeSpan_start, fadeInCompletionTime, dayTimeEdited);
 0461                fadeChanged = true;
 0462                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_fadeTime_" + slotNum), percentage);
 463            }
 464
 0465            return fadeChanged;
 466        }
 467
 468        private bool CheckFadingOut(Material selectedMat, float dayTime, float normalizedDayTime, int slotNum, TextureLa
 469        {
 0470            bool fadeChanged = false;
 0471            float endTimeEdited = layer.timeSpan_End;
 0472            float dayTimeEdited = dayTime;
 473
 0474            if (layer.timeSpan_End < layer.timeSpan_start)
 475            {
 0476                endTimeEdited = cycleTime + layer.timeSpan_End;
 477            }
 478
 0479            if (dayTime < layer.timeSpan_start)
 480            {
 0481                dayTimeEdited = cycleTime + dayTime;
 482            }
 483
 484
 0485            float fadeOutStartTime = endTimeEdited - layer.fadingOutTime;
 486
 0487            if (dayTimeEdited > fadeOutStartTime)
 488            {
 0489                float percentage = Mathf.InverseLerp(endTimeEdited, fadeOutStartTime, dayTimeEdited);
 0490                fadeChanged = true;
 0491                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_fadeTime_" + slotNum), percentage);
 492            }
 493
 0494            return fadeChanged;
 495        }
 496
 497        void ApplyCubemapTextureLayer(Material selectedMat, float dayTime, float normalizedLayerTime, int layerNum, Text
 498        {
 0499            if (changeAlllValues)
 500            {
 0501                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_RenderDistance_" + layerNum), 0);
 0502                selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_tex_" + layerNum), null);
 0503                selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_cubemap_" + layerNum), layer.cubemap);
 0504                selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_normals_" + layerNum), null);
 0505                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_timeFrame_" + layerNum), new Vector4(layer.ti
 0506                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_lightIntensity_" + layerNum), layer.tintPercen
 0507                selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_normalIntensity_" + layerNum), 0);
 0508                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortIntAndSize_" + layerNum), Vector2.zero
 0509                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortSpeedAndSharp_" + layerNum), Vector4.z
 510                // Particles
 0511                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_rowAndCollumns_" + layerNum), Vector2.zero);
 0512                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesMainParameters_" + layerNum), Vector
 0513                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesSecondaryParameters_" + layerNum), V
 514            }
 515
 516
 0517            selectedMat.SetColor(SkyboxShaderUtils.GetLayerProperty("_color_" + layerNum), layer.color.Evaluate(normaliz
 518
 519            // Set cubemap rotation. (Shader variable reused)
 0520            if (layer.movementTypeCubemap == MovementType.PointBased)
 521            {
 0522                Vector3 currentRotation = GetTransitionValue(layer.rotations_Vector3, normalizedLayerTime * 100);
 0523                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), new Vector4(cu
 0524                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(0
 0525            }
 526            else
 527            {
 0528                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), new Vector4(0,
 0529                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(l
 530            }
 531
 0532        }
 533
 534        void ApplyPlanarTextureLayer(Material selectedMat, float dayTime, float normalizedLayerTime, int layerNum, Textu
 535        {
 0536            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_RenderDistance_" + layerNum), GetTransitionValue(l
 0537            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_tex_" + layerNum), layer.texture);
 0538            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_normals_" + layerNum), layer.textureNormal);
 0539            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_cubemap_" + layerNum), null);
 540
 0541            selectedMat.SetColor(SkyboxShaderUtils.GetLayerProperty("_color_" + layerNum), layer.color.Evaluate(normaliz
 542
 543
 0544            if (layer.movementTypePlanar_Radial == MovementType.Speed)
 545            {
 546                // speed and Rotation
 0547                float rot = 0;
 0548                if (layer.layerType == LayerType.Planar)
 549                {
 0550                    rot = GetTransitionValue(layer.rotations_float, normalizedLayerTime * 100);
 551                }
 552
 0553                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(l
 554
 555                // Tiling and Offset
 0556                Vector4 t = new Vector4(layer.tiling.x, layer.tiling.y, 0, 0);
 0557                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), t);
 0558            }
 559            else
 560            {
 561                // speed and Rotation
 0562                float rot = 0;
 0563                if (layer.layerType == LayerType.Planar)
 564                {
 0565                    rot = GetTransitionValue(layer.rotations_float, normalizedLayerTime * 100);
 566                }
 567
 0568                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(0
 569
 570                // Tiling and Offset
 0571                Vector2 currentOffset = GetTransitionValue(layer.offset, normalizedLayerTime * 100);
 0572                Vector4 t = new Vector4(layer.tiling.x, layer.tiling.y, currentOffset.x, currentOffset.y);
 0573                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), t);
 574            }
 575
 576
 577            // Time frame
 0578            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_timeFrame_" + layerNum), new Vector4(layer.timeSp
 579            // normal intensity
 0580            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_normalIntensity_" + layerNum), layer.normalIntensi
 581            // Tint
 0582            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_lightIntensity_" + layerNum), layer.tintPercentage
 583
 584            // Reset Particle related Params
 0585            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_rowAndCollumns_" + layerNum), layer.flipbookRowsA
 0586            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesMainParameters_" + layerNum), new Vector
 0587            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesSecondaryParameters_" + layerNum), Vecto
 588
 589            // Apply Distortion Values
 0590            Vector2 distortIntAndSize = new Vector2(GetTransitionValue(layer.distortIntensity, normalizedLayerTime * 100
 0591            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortIntAndSize_" + layerNum), distortIntAndSiz
 592
 0593            Vector2 distortSpeed = GetTransitionValue(layer.distortSpeed, normalizedLayerTime * 100);
 0594            Vector2 distortSharpness = GetTransitionValue(layer.distortSharpness, normalizedLayerTime * 100);
 0595            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortSpeedAndSharp_" + layerNum), new Vector4(d
 0596        }
 597
 598        void ApplySatelliteTextureLayer(Material selectedMat, float dayTime, float normalizedLayerTime, int layerNum, Te
 599        {
 0600            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_tex_" + layerNum), layer.texture);
 0601            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_normals_" + layerNum), layer.textureNormal);
 0602            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_cubemap_" + layerNum), null);
 603
 0604            selectedMat.SetColor(SkyboxShaderUtils.GetLayerProperty("_color_" + layerNum), layer.color.Evaluate(normaliz
 605
 0606            if (layer.movementTypeSatellite == MovementType.Speed)
 607            {
 608                // Tiling and Offset
 0609                Vector2 currentWidthHeight = GetTransitionValue(layer.satelliteWidthHeight, normalizedLayerTime * 100, n
 0610                Vector4 t = new Vector4(currentWidthHeight.x, currentWidthHeight.y, 0, 0);
 0611                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), t);
 612
 613
 614                // speed and Rotation
 0615                float rot = GetTransitionValue(layer.rotations_float, normalizedLayerTime * 100);
 0616                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(l
 0617            }
 618            else
 619            {
 620                // Tiling and Offset
 0621                Vector2 currentOffset = GetTransitionValue(layer.offset, normalizedLayerTime * 100);
 0622                Vector2 currentWidthHeight = GetTransitionValue(layer.satelliteWidthHeight, normalizedLayerTime * 100, n
 0623                Vector4 t = new Vector4(currentWidthHeight.x, currentWidthHeight.y, currentOffset.x, currentOffset.y);
 0624                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), t);
 625
 626                // speed and Rotation
 0627                float rot = GetTransitionValue(layer.rotations_float, normalizedLayerTime * 100);
 0628                selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), new Vector4(0
 629            }
 630
 631            // Time frame
 0632            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_timeFrame_" + layerNum), new Vector4(layer.timeSp
 633            // normal intensity
 0634            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_normalIntensity_" + layerNum), layer.normalIntensi
 635            // Tint
 0636            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_lightIntensity_" + layerNum), layer.tintPercentage
 637
 638            // Reset Particle related Params
 0639            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_rowAndCollumns_" + layerNum), layer.flipbookRowsA
 0640            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesMainParameters_" + layerNum), new Vector
 0641            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesSecondaryParameters_" + layerNum), Vecto
 642
 643            // Reset Distortion values
 0644            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortIntAndSize_" + layerNum), Vector2.zero);
 0645            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortSpeedAndSharp_" + layerNum), Vector4.zero)
 646
 0647        }
 648
 649        void ApplyParticleTextureLayer(Material selectedMat, float dayTime, float normalizedLayerTime, int layerNum, Tex
 650        {
 651            // Reset Unused params
 0652            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_RenderDistance_" + layerNum), 0);
 0653            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_cubemap_" + layerNum), null);
 0654            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortIntAndSize_" + layerNum), Vector2.zero);
 0655            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortSpeedAndSharp_" + layerNum), Vector4.zero)
 656
 657
 658            // Time frame
 0659            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_timeFrame_" + layerNum), new Vector4(layer.timeSp
 660            // Tint
 0661            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_lightIntensity_" + layerNum), layer.tintPercentage
 662
 663            // Particles
 0664            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_tex_" + layerNum), layer.texture);
 0665            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_normals_" + layerNum), layer.textureNormal);
 0666            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_normalIntensity_" + layerNum), layer.normalIntensi
 0667            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_rowAndCollumns_" + layerNum), layer.flipbookRowsA
 0668            selectedMat.SetColor(SkyboxShaderUtils.GetLayerProperty("_color_" + layerNum), layer.color.Evaluate(normaliz
 0669            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + layerNum), new Vector4(layer.
 0670            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + layerNum), GetTransitionValu
 0671            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesMainParameters_" + layerNum), new Vector
 0672            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesSecondaryParameters_" + layerNum), new V
 673
 674
 0675        }
 676
 677        #endregion
 678
 679        #region Transition Values Utility Methods
 680
 681        float GetTransitionValue(List<TransitioningFloat> list, float percentage, float defaultVal = 0)
 682        {
 0683            if (list == null || list.Count < 1)
 684            {
 0685                return defaultVal;
 686            }
 687
 0688            if (list.Count == 1)
 689            {
 0690                return list[0].value;
 691            }
 692
 0693            TransitioningFloat min = list[0], max = list[0];
 694
 695
 0696            for (int i = 0; i < list.Count; i++)
 697            {
 0698                if (percentage <= list[i].percentage)
 699                {
 0700                    max = list[i];
 701
 0702                    if ((i - 1) > 0)
 703                    {
 0704                        min = list[i - 1];
 705                    }
 706
 0707                    break;
 708                }
 709            }
 710
 0711            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 0712            return Mathf.Lerp(min.value, max.value, t);
 713        }
 714
 715        Vector2 GetTransitionValue(List<TransitioningVector2> list, float percentage, Vector2 defaultVal = default(Vecto
 716        {
 0717            Vector2 offset = defaultVal;
 718
 0719            if (list == null || list.Count == 0)
 720            {
 0721                return offset;
 722            }
 723
 0724            if (list.Count == 1)
 725            {
 0726                offset = list[0].value;
 0727                return offset;
 728            }
 729
 730
 0731            TransitioningVector2 min = list[0], max = list[0];
 732
 0733            for (int i = 0; i < list.Count; i++)
 734            {
 0735                if (percentage <= list[i].percentage)
 736                {
 0737                    max = list[i];
 738
 0739                    if ((i - 1) > 0)
 740                    {
 0741                        min = list[i - 1];
 742                    }
 743
 0744                    break;
 745                }
 746            }
 0747            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 0748            offset = Vector2.Lerp(min.value, max.value, t);
 749
 0750            return offset;
 751        }
 752
 753        Vector3 GetTransitionValue(List<TransitioningVector3> list, float percentage)
 754        {
 0755            Vector3 offset = new Vector3(0, 0, 0);
 756
 0757            if (list == null || list.Count == 0)
 758            {
 0759                return offset;
 760            }
 761
 0762            if (list.Count == 1)
 763            {
 0764                offset = list[0].value;
 0765                return offset;
 766            }
 767
 768
 0769            TransitioningVector3 min = list[0], max = list[0];
 770
 0771            for (int i = 0; i < list.Count; i++)
 772            {
 0773                if (percentage <= list[i].percentage)
 774                {
 0775                    max = list[i];
 776
 0777                    if ((i - 1) > 0)
 778                    {
 0779                        min = list[i - 1];
 780                    }
 781
 0782                    break;
 783                }
 784            }
 785
 0786            float t = Mathf.InverseLerp(min.percentage, max.percentage, percentage);
 0787            offset = Vector3.Lerp(min.value, max.value, t);
 788
 0789            return offset;
 790        }
 791
 792        #endregion
 793
 794        public void ResetMaterial(Material selectedMat, int slotCount)
 795        {
 0796            for (int i = 0; i < slotCount; i++)
 797            {
 0798                ResetSlot(selectedMat, i);
 799            }
 0800        }
 801
 802        public void ResetSlot(Material selectedMat, int slotCount)
 803        {
 0804            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_layerType_" + slotCount), 0);
 0805            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_tex_" + slotCount), null);
 0806            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_cubemap_" + slotCount), null);
 0807            selectedMat.SetTexture(SkyboxShaderUtils.GetLayerProperty("_normals_" + slotCount), null);
 0808            selectedMat.SetColor(SkyboxShaderUtils.GetLayerProperty("_color_" + slotCount), new Color(1, 1, 1, 0));
 0809            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_tilingAndOffset_" + slotCount), new Vector4(1, 1,
 0810            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_speedAndRotation_" + slotCount), new Vector4(0, 0
 0811            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_timeFrame_" + slotCount), new Vector4(0, 0));
 0812            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_fadeTime_" + slotCount), 1);
 0813            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_normalIntensity_" + slotCount), 0);
 0814            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_lightIntensity_" + slotCount), 0);
 0815            selectedMat.SetFloat(SkyboxShaderUtils.GetLayerProperty("_RenderDistance_" + slotCount), 3.4f);
 0816            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortIntAndSize_" + slotCount), new Vector2(0, 
 0817            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_distortSpeedAndSharp_" + slotCount), new Vector4(
 0818            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_rowAndCollumns_" + slotCount), new Vector4(1, 1))
 0819            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesMainParameters_" + slotCount), new Vecto
 0820            selectedMat.SetVector(SkyboxShaderUtils.GetLayerProperty("_particlesSecondaryParameters_" + slotCount), new 
 0821        }
 822
 0823        Quaternion Vector4ToQuaternion(Vector4 val) { return new Quaternion(val.x, val.y, val.z, val.w); }
 824    }
 825}

Methods/Properties

SkyboxConfiguration()
ApplyOnMaterial(UnityEngine.Material, System.Single, System.Single, System.Int32, UnityEngine.Light, System.Single)
ApplyInWorldAvatarColor(System.Single, UnityEngine.GameObject)
ApplyEditorAvatarColor()
ApplyAllSlots(UnityEngine.Material, System.Single, System.Single, System.Int32, System.Single)
GetActiveLayer(System.Single, System.Int32)
CheckAndFireTimelineEvents(System.Single)
CycleResets()
ApplyDLIntensity(System.Single, UnityEngine.Light)
ApplyDLDirection(System.Single, UnityEngine.Light)
ApplyTextureLayer(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Single, System.Boolean)
CheckFadingIn(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Single, System.Boolean)
CheckFadingOut(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Single, System.Boolean)
ApplyCubemapTextureLayer(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Boolean)
ApplyPlanarTextureLayer(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Boolean)
ApplySatelliteTextureLayer(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Boolean)
ApplyParticleTextureLayer(UnityEngine.Material, System.Single, System.Single, System.Int32, DCL.Skybox.TextureLayer, System.Boolean)
GetTransitionValue(System.Collections.Generic.List[TransitioningFloat], System.Single, System.Single)
GetTransitionValue(System.Collections.Generic.List[TransitioningVector2], System.Single, UnityEngine.Vector2)
GetTransitionValue(System.Collections.Generic.List[TransitioningVector3], System.Single)
ResetMaterial(UnityEngine.Material, System.Int32)
ResetSlot(UnityEngine.Material, System.Int32)
Vector4ToQuaternion(UnityEngine.Vector4)