-
Notifications
You must be signed in to change notification settings - Fork 878
Expand file tree
/
Copy pathFog.cs
More file actions
53 lines (46 loc) · 2.12 KB
/
Copy pathFog.cs
File metadata and controls
53 lines (46 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
namespace UnityEngine.Rendering.PostProcessing
{
/// <summary>
/// This class holds settings for the Fog effect with the deferred rendering path.
/// </summary>
[UnityEngine.Scripting.Preserve]
[Serializable]
public sealed class Fog
{
/// <summary>
/// If <c>true</c>, enables the internal deferred fog pass. Actual fog settings should be
/// set in the Lighting panel.
/// </summary>
[Tooltip("Enables the internal deferred fog pass. Actual fog settings should be set in the Lighting panel.")]
public bool enabled = true;
/// <summary>
/// Should the fog affect the skybox?
/// </summary>
[Tooltip("Mark true for the fog to ignore the skybox")]
public bool excludeSkybox = true;
internal DepthTextureMode GetCameraFlags()
{
return DepthTextureMode.Depth;
}
internal bool IsEnabledAndSupported(PostProcessRenderContext context)
{
return enabled
&& RenderSettings.fog
&& !RuntimeUtilities.scriptableRenderPipelineActive
&& context.resources.shaders.deferredFog
&& context.resources.shaders.deferredFog.isSupported
&& context.camera.actualRenderingPath == RenderingPath.DeferredShading; // In forward fog is already done at shader level
}
internal void Render(PostProcessRenderContext context)
{
var sheet = context.propertySheets.Get(context.resources.shaders.deferredFog);
sheet.ClearKeywords();
var fogColor = RuntimeUtilities.isLinearColorSpace ? RenderSettings.fogColor.linear : RenderSettings.fogColor;
sheet.properties.SetVector(ShaderIDs.FogColor, fogColor);
sheet.properties.SetVector(ShaderIDs.FogParams, new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance));
var cmd = context.command;
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, excludeSkybox ? 1 : 0, false, null, true);
}
}
}