This repository was archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 739
FogEffect #513
Closed
Closed
FogEffect #513
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
PostProcessing/Editor/Effects/FogEditor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| using UnityEngine; | ||
| using UnityEngine.Rendering.PostProcessing; | ||
|
|
||
| namespace UnityEditor.Rendering.PostProcessing | ||
| { | ||
| [PostProcessEditor(typeof(Fog))] | ||
| public sealed class FogEditor : PostProcessEffectEditor<Fog> | ||
| { | ||
| SerializedParameterOverride m_excludeSkybox; | ||
| SerializedParameterOverride m_color; | ||
| SerializedParameterOverride m_density; | ||
| SerializedParameterOverride m_startDistance; | ||
| SerializedParameterOverride m_endDistance; | ||
| SerializedParameterOverride m_mode; | ||
|
|
||
| public override void OnEnable() | ||
| { | ||
| m_excludeSkybox = FindParameterOverride(x => x.excludeSkybox); | ||
| m_color = FindParameterOverride(x => x.color); | ||
| m_density = FindParameterOverride(x => x.density); | ||
| m_startDistance = FindParameterOverride(x => x.startDistance); | ||
| m_endDistance = FindParameterOverride(x => x.endDistance); | ||
| m_mode = FindParameterOverride(x => x.mode); | ||
| } | ||
|
|
||
| public override void OnInspectorGUI() | ||
| { | ||
| base.OnInspectorGUI(); | ||
|
|
||
| PropertyField(m_excludeSkybox); | ||
| PropertyField(m_color); | ||
| PropertyField(m_mode); | ||
| if (m_mode.value.intValue == (int)FogMode.Linear) | ||
| { | ||
| PropertyField(m_startDistance); | ||
| PropertyField(m_endDistance); | ||
| } | ||
| else if (m_mode.value.intValue == (int)FogMode.Exponential || m_mode.value.intValue == (int)FogMode.ExponentialSquared) | ||
| { | ||
| PropertyField(m_density); | ||
| } | ||
| } | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
PostProcessing/Editor/Effects/FogEditor.cs.meta
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
PostProcessing/Runtime/Effects/DeferredFog.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using System; | ||
|
|
||
| namespace UnityEngine.Rendering.PostProcessing | ||
| { | ||
| [Serializable] | ||
| public sealed class DeferredFog | ||
| { | ||
| [Tooltip("Enables the internal deferred fog pass. Actual fog settings should be set in the Lighting panel.")] | ||
| public bool enabled = true; | ||
|
|
||
| [Tooltip("Should the fog affect 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); | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
PostProcessing/Runtime/Effects/DeferredFog.cs.meta
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
PostProcessing/Runtime/Effects/Fog.cs.meta
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.