< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SkyboxShaderUtils()0%2100%
CacheShaderProperties()0%12300%
GetLayerProperty(...)0%30500%

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        {
 17            float tTime = timeOfTheDay / SkyboxUtils.CYCLE_TIME;
 18            tTime = Mathf.Clamp(tTime, 0, 1);
 19            return tTime;
 20        }
 21
 22        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
 029        private static Dictionary<string, int>[] shaderLayersProperties = null;
 030        public static readonly int LightTint = Shader.PropertyToID("_lightTint");
 031        public static readonly int LightDirection = Shader.PropertyToID("_lightDirection");
 032        public static readonly int SkyColor = Shader.PropertyToID("_skyColor");
 033        public static readonly int GroundColor = Shader.PropertyToID("_groundColor");
 034        public static readonly int HorizonColor = Shader.PropertyToID("_horizonColor");
 035        public static readonly int HorizonHeight = Shader.PropertyToID("_horizonHeight");
 036        public static readonly int HorizonWidth = Shader.PropertyToID("_horizonWidth");
 037        public static readonly int HorizonMask = Shader.PropertyToID("_horizonMask");
 038        public static readonly int HorizonMaskValues = Shader.PropertyToID("_horizonMaskValues");
 039        public static readonly int HorizonPlane = Shader.PropertyToID("_horizonPlane");
 040        public static readonly int HorizonPlaneValues = Shader.PropertyToID("_horizonPlaneValues");
 041        public static readonly int HorizonPlaneColor = Shader.PropertyToID("_horizonPlaneColor");
 042        public static readonly int HorizonPlaneHeight = Shader.PropertyToID("_horizonPlaneHeight");
 043        public static readonly int PlaneSmoothRange = Shader.PropertyToID("_smoothRange");
 044        public static readonly int HorizonLightIntensity = Shader.PropertyToID("_horizonLigthIntesity");
 045        public static readonly int FogIntensity = Shader.PropertyToID("_fogIntesity");
 046        public static readonly int Opacity = Shader.PropertyToID("_Opacity");
 47
 048        static SkyboxShaderUtils() { CacheShaderProperties(); }
 49
 50        static void CacheShaderProperties()
 51        {
 052            if (shaderLayersProperties != null) return;
 053            shaderLayersProperties = new Dictionary<string, int>[TOTAL_SKYBOX_LAYERS];
 054            for (int i = 0; i < TOTAL_SKYBOX_LAYERS; i++)
 55            {
 056                shaderLayersProperties[i] = new Dictionary<string, int>();
 57
 058                shaderLayersProperties[i].Add("_layerType_", Shader.PropertyToID("_layerType_" + i));
 059                shaderLayersProperties[i].Add("_fadeTime_" , Shader.PropertyToID("_fadeTime_" + i));
 60
 061                shaderLayersProperties[i].Add("_RenderDistance_" , Shader.PropertyToID("_RenderDistance_" + i));
 062                shaderLayersProperties[i].Add("_tex_" , Shader.PropertyToID("_tex_" + i));
 063                shaderLayersProperties[i].Add("_cubemap_" , Shader.PropertyToID("_cubemap_" + i));
 064                shaderLayersProperties[i].Add("_normals_" , Shader.PropertyToID("_normals_" + i));
 065                shaderLayersProperties[i].Add("_color_" , Shader.PropertyToID("_color_" + i));
 066                shaderLayersProperties[i].Add("_timeFrame_" , Shader.PropertyToID("_timeFrame_" + i));
 067                shaderLayersProperties[i].Add("_rowAndCollumns_" , Shader.PropertyToID("_rowAndCollumns_" + i));
 68
 069                shaderLayersProperties[i].Add("_lightIntensity_" , Shader.PropertyToID("_lightIntensity_" + i));
 070                shaderLayersProperties[i].Add("_normalIntensity_" , Shader.PropertyToID("_normalIntensity_" + i));
 71
 072                shaderLayersProperties[i].Add("_distortIntAndSize_" , Shader.PropertyToID("_distortIntAndSize_" + i));
 073                shaderLayersProperties[i].Add("_distortSpeedAndSharp_" , Shader.PropertyToID("_distortSpeedAndSharp_" + 
 74
 75
 076                shaderLayersProperties[i].Add("_particlesMainParameters_" , Shader.PropertyToID("_particlesMainParameter
 077                shaderLayersProperties[i].Add("_particlesSecondaryParameters_" , Shader.PropertyToID("_particlesSecondar
 78
 079                shaderLayersProperties[i].Add("_tilingAndOffset_" , Shader.PropertyToID("_tilingAndOffset_" + i ));
 080                shaderLayersProperties[i].Add("_speedAndRotation_" , Shader.PropertyToID("_speedAndRotation_" + i));
 81            }
 82
 083        }
 84
 85        public static int GetLayerProperty(string name, int layer)
 86        {
 087            if (layer >= TOTAL_SKYBOX_LAYERS)
 88            {
 089                throw new ArgumentException($"Maximum Skybox Layers is {TOTAL_SKYBOX_LAYERS}");
 90            }
 91
 92            int propertyInt;
 093            if (shaderLayersProperties is not { Length: > 0 })
 94            {
 095                CacheShaderProperties();
 96            }
 97
 098            if (shaderLayersProperties[layer].TryGetValue(name, out int val))
 99            {
 0100                propertyInt = val;
 101            }
 102            else
 103            {
 0104                propertyInt = Shader.PropertyToID(name);
 0105                shaderLayersProperties[layer].Add(name, propertyInt);
 106            }
 107
 0108            return propertyInt;
 109        }
 110
 111    }
 112}