< Summary

Class:DCL.Skybox.SkyboxUtils
Assembly:ProceduralSkybox
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/SkyboxUtils.cs
Covered lines:0
Uncovered lines:4
Coverable lines:4
Total lines:112
Line coverage:0% (0 of 4)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetNormalizedDayTime(...)0%2100%
Vector4ToQuaternion(...)0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL.Skybox
 6{
 7    public static class SkyboxUtils
 8    {
 9        /// <summary>
 10        /// Time for one complete circle. In Hours. default 24
 11        /// </summary>
 12        public const float CYCLE_TIME = 24;
 13        public const float DOME_DEFAULT_SIZE = 50;
 14
 15        public static float GetNormalizedDayTime(float timeOfTheDay)
 16        {
 017            float tTime = timeOfTheDay / SkyboxUtils.CYCLE_TIME;
 018            tTime = Mathf.Clamp(tTime, 0, 1);
 019            return tTime;
 20        }
 21
 022        public static Quaternion Vector4ToQuaternion(Vector4 val) { return new Quaternion(val.x, val.y, val.z, val.w); }
 23    }
 24
 25    public static class SkyboxShaderUtils
 26    {
 27        public const int TOTAL_SKYBOX_LAYERS = 5;
 28
 29        private static Dictionary<string, int>[] shaderLayersProperties = null;
 30        public static readonly int LightTint = Shader.PropertyToID("_lightTint");
 31        public static readonly int LightDirection = Shader.PropertyToID("_lightDirection");
 32        public static readonly int SkyColor = Shader.PropertyToID("_skyColor");
 33        public static readonly int GroundColor = Shader.PropertyToID("_groundColor");
 34        public static readonly int HorizonColor = Shader.PropertyToID("_horizonColor");
 35        public static readonly int HorizonHeight = Shader.PropertyToID("_horizonHeight");
 36        public static readonly int HorizonWidth = Shader.PropertyToID("_horizonWidth");
 37        public static readonly int HorizonMask = Shader.PropertyToID("_horizonMask");
 38        public static readonly int HorizonMaskValues = Shader.PropertyToID("_horizonMaskValues");
 39        public static readonly int HorizonPlane = Shader.PropertyToID("_horizonPlane");
 40        public static readonly int HorizonPlaneValues = Shader.PropertyToID("_horizonPlaneValues");
 41        public static readonly int HorizonPlaneColor = Shader.PropertyToID("_horizonPlaneColor");
 42        public static readonly int HorizonPlaneHeight = Shader.PropertyToID("_horizonPlaneHeight");
 43        public static readonly int PlaneSmoothRange = Shader.PropertyToID("_smoothRange");
 44        public static readonly int HorizonLightIntensity = Shader.PropertyToID("_horizonLigthIntesity");
 45        public static readonly int FogIntensity = Shader.PropertyToID("_fogIntesity");
 46        public static readonly int Opacity = Shader.PropertyToID("_Opacity");
 47
 48        static SkyboxShaderUtils() { CacheShaderProperties(); }
 49
 50        static void CacheShaderProperties()
 51        {
 52            if (shaderLayersProperties != null) return;
 53            shaderLayersProperties = new Dictionary<string, int>[TOTAL_SKYBOX_LAYERS];
 54            for (int i = 0; i < TOTAL_SKYBOX_LAYERS; i++)
 55            {
 56                shaderLayersProperties[i] = new Dictionary<string, int>();
 57
 58                shaderLayersProperties[i].Add("_layerType_", Shader.PropertyToID("_layerType_" + i));
 59                shaderLayersProperties[i].Add("_fadeTime_" , Shader.PropertyToID("_fadeTime_" + i));
 60
 61                shaderLayersProperties[i].Add("_RenderDistance_" , Shader.PropertyToID("_RenderDistance_" + i));
 62                shaderLayersProperties[i].Add("_tex_" , Shader.PropertyToID("_tex_" + i));
 63                shaderLayersProperties[i].Add("_cubemap_" , Shader.PropertyToID("_cubemap_" + i));
 64                shaderLayersProperties[i].Add("_normals_" , Shader.PropertyToID("_normals_" + i));
 65                shaderLayersProperties[i].Add("_color_" , Shader.PropertyToID("_color_" + i));
 66                shaderLayersProperties[i].Add("_timeFrame_" , Shader.PropertyToID("_timeFrame_" + i));
 67                shaderLayersProperties[i].Add("_rowAndCollumns_" , Shader.PropertyToID("_rowAndCollumns_" + i));
 68
 69                shaderLayersProperties[i].Add("_lightIntensity_" , Shader.PropertyToID("_lightIntensity_" + i));
 70                shaderLayersProperties[i].Add("_normalIntensity_" , Shader.PropertyToID("_normalIntensity_" + i));
 71
 72                shaderLayersProperties[i].Add("_distortIntAndSize_" , Shader.PropertyToID("_distortIntAndSize_" + i));
 73                shaderLayersProperties[i].Add("_distortSpeedAndSharp_" , Shader.PropertyToID("_distortSpeedAndSharp_" + 
 74
 75
 76                shaderLayersProperties[i].Add("_particlesMainParameters_" , Shader.PropertyToID("_particlesMainParameter
 77                shaderLayersProperties[i].Add("_particlesSecondaryParameters_" , Shader.PropertyToID("_particlesSecondar
 78
 79                shaderLayersProperties[i].Add("_tilingAndOffset_" , Shader.PropertyToID("_tilingAndOffset_" + i ));
 80                shaderLayersProperties[i].Add("_speedAndRotation_" , Shader.PropertyToID("_speedAndRotation_" + i));
 81            }
 82
 83        }
 84
 85        public static int GetLayerProperty(string name, int layer)
 86        {
 87            if (layer >= TOTAL_SKYBOX_LAYERS)
 88            {
 89                throw new ArgumentException($"Maximum Skybox Layers is {TOTAL_SKYBOX_LAYERS}");
 90            }
 91
 92            int propertyInt;
 93            if (shaderLayersProperties is not { Length: > 0 })
 94            {
 95                CacheShaderProperties();
 96            }
 97
 98            if (shaderLayersProperties[layer].TryGetValue(name, out int val))
 99            {
 100                propertyInt = val;
 101            }
 102            else
 103            {
 104                propertyInt = Shader.PropertyToID(name);
 105                shaderLayersProperties[layer].Add(name, propertyInt);
 106            }
 107
 108            return propertyInt;
 109        }
 110
 111    }
 112}