/// <summary> /// Sets the fog color in the area specified. /// nFogType = FOG_TYPE_* specifies wether the Sun, Moon, or both fog types are set. /// nFogColor = FOG_COLOR_* specifies the color the fog is being set to. /// The fog color can also be represented as a hex RGB number if specific color shades /// are desired. /// The format of a hex specified color would be 0xFFEEDD where /// FF would represent the amount of red in the color /// EE would represent the amount of green in the color /// DD would represent the amount of blue in the color. /// If no valid area (or object) is specified, it uses the area of caller. /// If an object other than an area is specified, will use the area that the object is currently in. /// </summary> public static void SetFogColor(FogType nFogType, FogColorType nFogColor, uint oArea = OBJECT_INVALID) { Internal.NativeFunctions.StackPushObject(oArea); Internal.NativeFunctions.StackPushInteger(nFogColor.InternalValue); Internal.NativeFunctions.StackPushInteger(nFogType.InternalValue); Internal.NativeFunctions.CallBuiltIn(780); }
public void Update_GlobalFog(bool fogEnabled, CustomFog fogMode, FogColorType fogColorMode, Color fogColor, float fogDistance, float fogHeight, float fogStart, float fogEnd, float fogDensity, Color scatteringAlbedo, float freePath, float fogAnisotropy , float LightProbeDimmer) { VisualEnvironment enviro; GameObject.Find("Fog/Sky/HD Volume").GetComponent <Volume>().sharedProfile.TryGet(out enviro); if (fogEnabled) { if (fogMode == CustomFog.Exponential) { enviro.fogType.overrideState = true; enviro.fogType.value = FogType.Exponential; ExponentialFog exFog; GameObject.Find("Fog/Sky/HD Volume").GetComponent <Volume>().sharedProfile.TryGet(out exFog); exFog.colorMode.overrideState = true; if (fogColorMode == FogColorType.SkyColor) { exFog.colorMode.value = FogColorMode.SkyColor; } if (fogColorMode == FogColorType.CustomColor) { exFog.colorMode.value = FogColorMode.ConstantColor; } exFog.fogDistance.overrideState = true; exFog.fogDistance.value = fogDistance; exFog.fogBaseHeight.overrideState = true; exFog.fogBaseHeight.value = fogHeight; exFog.color.overrideState = true; exFog.color.value = fogColor; exFog.density.overrideState = true; exFog.density.value = fogDensity; } if (fogMode == CustomFog.Linear) { enviro.fogType.overrideState = true; enviro.fogType.value = FogType.Linear; LinearFog exFog; GameObject.Find("Fog/Sky/HD Volume").GetComponent <Volume>().sharedProfile.TryGet(out exFog); if (fogColorMode == FogColorType.SkyColor) { exFog.colorMode.value = FogColorMode.SkyColor; } if (fogColorMode == FogColorType.CustomColor) { exFog.colorMode.value = FogColorMode.ConstantColor; } exFog.fogStart.overrideState = true; exFog.fogStart.value = fogStart; exFog.fogEnd.overrideState = true; exFog.fogEnd.value = fogEnd; exFog.fogHeightEnd.overrideState = true; exFog.fogHeightEnd.value = fogHeight; exFog.color.overrideState = true; exFog.color.value = fogColor; exFog.density.overrideState = true; exFog.density.value = fogDensity; } if (fogMode == CustomFog.Volumetric) { enviro.fogType.overrideState = true; enviro.fogType.value = FogType.Volumetric; VolumetricFog volFog; GameObject.Find("Fog/Sky/HD Volume").GetComponent <Volume>().sharedProfile.TryGet(out volFog); volFog.albedo.overrideState = true; volFog.albedo.value = new UnityEngine.Experimental.Rendering .ColorParameter(scatteringAlbedo); volFog.meanFreePath.overrideState = true; volFog.meanFreePath.value = new MinFloatParameter(freePath, 1.0f); volFog.anisotropy.overrideState = true; volFog.anisotropy.value = new ClampedFloatParameter(fogAnisotropy, -1.0f, 1.0f); volFog.globalLightProbeDimmer.overrideState = true; volFog.globalLightProbeDimmer.value = new ClampedFloatParameter(LightProbeDimmer, 0.0f, 1.0f); } } if (!fogEnabled) { enviro.fogType.overrideState = true; enviro.fogType.value = FogType.None; } }