public void SetSkyFogColor(SkyColors colors) { // Set camera clear colour cameraClearColor = colors.clearColor; myCamera.backgroundColor = ((cameraClearColor * SkyTintColor) * 2f) * SkyColorScale; // Set gray fog color for anything denser than heavy rain, otherwise use sky color for atmospheric fogging // Only operates when weatherManager can be found (i.e. in game scene) while DaggerfallSky is running if (weatherManager) { WeatherManager.FogSettings currentFogSettings = GameManager.Instance.WeatherManager.currentOutdoorFogSettings; WeatherManager.FogSettings rainyFogSettings = GameManager.Instance.WeatherManager.RainyFogSettings; if (currentFogSettings.fogMode == FogMode.Exponential && currentFogSettings.density > rainyFogSettings.density) { RenderSettings.fogColor = Color.gray; } else { RenderSettings.fogColor = cameraClearColor; } } else { RenderSettings.fogColor = cameraClearColor; } }
private static void RenderSkyColors(SkyColors colors) { CONS.WriteLine($" sky: {colors.Sky.ToStringOrDefault()}"); CONS.WriteLine($" shadow: {colors.Shadow.ToStringOrDefault()}"); CONS.WriteLine($" overlay: {colors.Overlay.ToStringOrDefault()}"); CONS.WriteLine($" saturation: {colors.Saturation.GetValueOrDefault()}"); }
void UpdateSkyColor() { // 一日の時間を [0, 1] へ変換。 // 0 が 0 時、1 が 24 時。 var elapsed = ElapsedSecondsPerDay / SecondsPerDay; CurrentSkyColor = SkyColors.GetColor(elapsed); }
public void SetSkyFogColor(SkyColors colors) { // Set camera clear colour cameraClearColor = colors.clearColor; myCamera.backgroundColor = ((cameraClearColor * SkyTintColor) * 2f) * SkyColorScale; // Assign colour to fog UnityEngine.RenderSettings.fogColor = cameraClearColor; }
private void PromoteToTexture(SkyColors colors, bool flip = false) { const int dayWidth = 512; const int dayHeight = 220; const int nightWidth = 512; const int nightHeight = 219; // Destroy old textures Destroy(westTexture); Destroy(eastTexture); // Create new textures if (!IsNight || !showNightSky) { westTexture = new Texture2D(dayWidth, dayHeight, TextureFormat.ARGB32, false); eastTexture = new Texture2D(dayWidth, dayHeight, TextureFormat.ARGB32, false); } else { westTexture = new Texture2D(nightWidth, nightHeight, TextureFormat.ARGB32, false); eastTexture = new Texture2D(nightWidth, nightHeight, TextureFormat.ARGB32, false); } // Set pixels, flipping hemisphere if required if (!flip) { westTexture.SetPixels32(colors.west); eastTexture.SetPixels32(colors.east); } else { westTexture.SetPixels32(colors.east); eastTexture.SetPixels32(colors.west); } // Set wrap mode eastTexture.wrapMode = TextureWrapMode.Clamp; westTexture.wrapMode = TextureWrapMode.Clamp; // Set filter mode westTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; eastTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; // Compress sky textures if (dfUnity.MaterialReader.CompressSkyTextures) { westTexture.Compress(true); eastTexture.Compress(true); } // Apply changes westTexture.Apply(false, true); eastTexture.Apply(false, true); SetSkyFogColor(colors); }
void Awake() { lastButtonUsedIndex = 1; ev = FindObjectOfType <Enviroment>(); cloudScript = FindObjectOfType <CloudScript>(); skyColors = FindObjectOfType <SkyColors>(); parameters = new Parameters(); ev.isPaused = true; status = Status.Pause; bm_instance = this; }
/// <summary> /// Loads day sky from arena files /// </summary> /// <param name="skyIndex"></param> /// <returns>SkyColors loaded</returns> private SkyColors LoadVanillaDaySky(int skyIndex, int frame) { SkyFile skyFile = new SkyFile(Path.Combine(dfUnity.Arena2Path, SkyFile.IndexToFileName(skyIndex)), FileUsage.UseMemory, true); skyFile.Palette = skyFile.GetDFPalette(frame); SkyColors colors = new SkyColors(); colors.east = skyFile.GetColor32(0, frame); colors.west = skyFile.GetColor32(1, frame); colors.clearColor = colors.west[0]; colors.imageSize = new Vector2Int(512, 220); return(colors); }
private void PromoteToTexture(SkyColors colors, bool flip = false) { // Destroy old textures Destroy(westTexture); Destroy(eastTexture); // Create new textures westTexture = new Texture2D(colors.imageSize.x, colors.imageSize.y, TextureFormat.ARGB32, false); eastTexture = new Texture2D(colors.imageSize.x, colors.imageSize.y, TextureFormat.ARGB32, false); // Set pixels, flipping hemisphere if required if (!flip) { westTexture.SetPixels32(colors.west); eastTexture.SetPixels32(colors.east); } else { westTexture.SetPixels32(colors.east); eastTexture.SetPixels32(colors.west); } // Set wrap mode eastTexture.wrapMode = TextureWrapMode.Clamp; westTexture.wrapMode = TextureWrapMode.Clamp; // Set filter mode westTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; eastTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; // Compress sky textures if (dfUnity.MaterialReader.CompressSkyTextures) { westTexture.Compress(true); eastTexture.Compress(true); } // Apply changes westTexture.Apply(false, true); eastTexture.Apply(false, true); SetSkyFogColor(colors); }
private void LoadDaySky(int frame) { if (DaggerfallUnity.Settings.AssetInjection) { TryLoadDayTextures(SkyIndex, frame, out Texture2D westTexture, out Texture2D eastTexture); if (westTexture && eastTexture) { skyColors = new SkyColors(); skyColors.east = eastTexture.GetPixels32(); skyColors.west = westTexture.GetPixels32(); skyColors.clearColor = skyColors.west[0]; skyColors.imageSize = new Vector2Int(westTexture.width, westTexture.height); return; } } skyColors = LoadVanillaDaySky(SkyIndex, frame); }
private void PromoteToTexture(SkyColors colors, bool flip = false) { const int dayWidth = 512; const int dayHeight = 220; const int nightWidth = 512; const int nightHeight = 219; // Destroy old textures Destroy(westTexture); Destroy(eastTexture); // Create new textures if (!IsNight || !showNightSky) { westTexture = new Texture2D(dayWidth, dayHeight, TextureFormat.RGB24, false); eastTexture = new Texture2D(dayWidth, dayHeight, TextureFormat.RGB24, false); } else { westTexture = new Texture2D(nightWidth, nightHeight, TextureFormat.RGB24, false); eastTexture = new Texture2D(nightWidth, nightHeight, TextureFormat.RGB24, false); } // Set pixels, flipping hemisphere if required if (!flip) { westTexture.SetPixels32(colors.west); eastTexture.SetPixels32(colors.east); } else { westTexture.SetPixels32(colors.east); eastTexture.SetPixels32(colors.west); } // Set wrap mode eastTexture.wrapMode = TextureWrapMode.Clamp; westTexture.wrapMode = TextureWrapMode.Clamp; // Set filter mode westTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; eastTexture.filterMode = dfUnity.MaterialReader.SkyFilterMode; // Compress sky textures if (dfUnity.MaterialReader.CompressSkyTextures) { westTexture.Compress(true); eastTexture.Compress(true); } // Apply changes westTexture.Apply(false, true); eastTexture.Apply(false, true); // Set camera clear colour cameraClearColor = colors.clearColor; myCamera.backgroundColor = ((cameraClearColor * SkyTintColor) * 2f) * SkyColorScale; // Assign colour to fog UnityEngine.RenderSettings.fogColor = cameraClearColor; }
/// <summary> /// Loads night sky from arena files and adds stars if enabled in settings /// </summary> /// <param name="skyIndex"></param> /// <returns>SkyColors loaded</returns> private SkyColors LoadVanillaNightSky(int skyIndex) { const int width = 512; const int height = 219; // Get night sky matching sky index int nightSky; if (skyIndex >= 0 && skyIndex <= 7) { nightSky = 3; } else if (skyIndex >= 8 && skyIndex <= 15) { nightSky = 1; } else if (skyIndex >= 16 && skyIndex <= 23) { nightSky = 2; } else { nightSky = 0; } string filename = string.Format("NITE{0:00}I0.IMG", nightSky); imgFile = new ImgFile(Path.Combine(dfUnity.Arena2Path, filename), FileUsage.UseMemory, true); imgFile.Palette.Load(Path.Combine(dfUnity.Arena2Path, imgFile.PaletteName)); // Get sky bitmap DFBitmap dfBitmap = imgFile.GetDFBitmap(0, 0); // Draw stars if (ShowStars) { for (int i = 0; i < dfBitmap.Data.Length; i++) { // Stars should only be drawn over clear sky indices int index = dfBitmap.Data[i]; if (index > 16 && index < 32) { if (random.NextDouble() < starChance) { dfBitmap.Data[i] = starColorIndices[random.Next(0, starColorIndices.Length)]; } } } } // Get sky colour array Color32[] colors = imgFile.GetColor32(dfBitmap); // Fix seam on right side of night skies for (int y = 0; y < height; y++) { int pos = y * width + width - 2; colors[pos + 1] = colors[pos]; } SkyColors skyColors = new SkyColors(); skyColors.west = colors; skyColors.east = colors; skyColors.clearColor = skyColors.west[0]; skyColors.imageSize = new Vector2Int(512, 219); return(skyColors); }