| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.Skybox |
| | 6 | | { |
| | 7 | | public static class SkyboxShaderUtils |
| | 8 | | { |
| | 9 | | public static Dictionary<string, int> shaderLayersProperties; |
| 0 | 10 | | public static readonly int LightTint = Shader.PropertyToID("_lightTint"); |
| 0 | 11 | | public static readonly int LightDirection = Shader.PropertyToID("_lightDirection"); |
| 0 | 12 | | public static readonly int SkyColor = Shader.PropertyToID("_skyColor"); |
| 0 | 13 | | public static readonly int GroundColor = Shader.PropertyToID("_groundColor"); |
| 0 | 14 | | public static readonly int HorizonColor = Shader.PropertyToID("_horizonColor"); |
| 0 | 15 | | public static readonly int HorizonHeight = Shader.PropertyToID("_horizonHeight"); |
| 0 | 16 | | public static readonly int HorizonWidth = Shader.PropertyToID("_horizonWidth"); |
| 0 | 17 | | public static readonly int HorizonMask = Shader.PropertyToID("_horizonMask"); |
| 0 | 18 | | public static readonly int HorizonMaskValues = Shader.PropertyToID("_horizonMaskValues"); |
| 0 | 19 | | public static readonly int HorizonPlaneColor = Shader.PropertyToID("_HorizonPlaneColor"); |
| 0 | 20 | | public static readonly int HorizonPlaneHeight = Shader.PropertyToID("_horizonPlaneHeight"); |
| | 21 | |
|
| 0 | 22 | | static SkyboxShaderUtils() { CacheShaderProperties(); } |
| | 23 | |
|
| | 24 | | static void CacheShaderProperties() |
| | 25 | | { |
| 0 | 26 | | shaderLayersProperties = new Dictionary<string, int>(); |
| 0 | 27 | | for (int i = 0; i < 5; i++) |
| | 28 | | { |
| 0 | 29 | | shaderLayersProperties.Add("_layerType_" + i, Shader.PropertyToID("_layerType_" + i)); |
| 0 | 30 | | shaderLayersProperties.Add("_fadeTime_" + i, Shader.PropertyToID("_fadeTime_" + i)); |
| | 31 | |
|
| 0 | 32 | | shaderLayersProperties.Add("_RenderDistance_" + i, Shader.PropertyToID("_RenderDistance_" + i)); |
| 0 | 33 | | shaderLayersProperties.Add("_tex_" + i, Shader.PropertyToID("_tex_" + i)); |
| 0 | 34 | | shaderLayersProperties.Add("_cubemap_" + i, Shader.PropertyToID("_cubemap_" + i)); |
| 0 | 35 | | shaderLayersProperties.Add("_normals_" + i, Shader.PropertyToID("_normals_" + i)); |
| 0 | 36 | | shaderLayersProperties.Add("_color_" + i, Shader.PropertyToID("_color_" + i)); |
| 0 | 37 | | shaderLayersProperties.Add("_timeFrame_" + i, Shader.PropertyToID("_timeFrame_" + i)); |
| 0 | 38 | | shaderLayersProperties.Add("_rowAndCollumns_" + i, Shader.PropertyToID("_rowAndCollumns_" + i)); |
| | 39 | |
|
| 0 | 40 | | shaderLayersProperties.Add("_lightIntensity_" + i, Shader.PropertyToID("_lightIntensity_" + i)); |
| 0 | 41 | | shaderLayersProperties.Add("_normalIntensity_" + i, Shader.PropertyToID("_normalIntensity_" + i)); |
| | 42 | |
|
| 0 | 43 | | shaderLayersProperties.Add("_distortIntAndSize_" + i, Shader.PropertyToID("_distortIntAndSize_" + i)); |
| 0 | 44 | | shaderLayersProperties.Add("_distortSpeedAndSharp_" + i, Shader.PropertyToID("_distortSpeedAndSharp_" + |
| | 45 | |
|
| | 46 | |
|
| 0 | 47 | | shaderLayersProperties.Add("_particlesMainParameters_" + i, Shader.PropertyToID("_particlesMainParameter |
| 0 | 48 | | shaderLayersProperties.Add("_particlesSecondaryParameters_" + i, Shader.PropertyToID("_particlesSecondar |
| | 49 | |
|
| 0 | 50 | | shaderLayersProperties.Add("_tilingAndOffset_" + i, Shader.PropertyToID("_tilingAndOffset_" + i)); |
| 0 | 51 | | shaderLayersProperties.Add("_speedAndRotation_" + i, Shader.PropertyToID("_speedAndRotation_" + i)); |
| | 52 | | } |
| | 53 | |
|
| 0 | 54 | | } |
| | 55 | |
|
| | 56 | | public static int GetLayerProperty(string name) |
| | 57 | | { |
| | 58 | | int propertyInt; |
| 0 | 59 | | if (shaderLayersProperties == null || shaderLayersProperties.Count <= 0) |
| | 60 | | { |
| 0 | 61 | | CacheShaderProperties(); |
| | 62 | | } |
| | 63 | |
|
| 0 | 64 | | if (!shaderLayersProperties.ContainsKey(name)) |
| | 65 | | { |
| 0 | 66 | | propertyInt = Shader.PropertyToID(name); |
| 0 | 67 | | shaderLayersProperties.Add(name, propertyInt); |
| 0 | 68 | | } |
| | 69 | | else |
| | 70 | | { |
| 0 | 71 | | propertyInt = shaderLayersProperties[name]; |
| | 72 | | } |
| | 73 | |
|
| 0 | 74 | | return propertyInt; |
| | 75 | | } |
| | 76 | |
|
| | 77 | | } |
| | 78 | | } |