Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit dbbc916

Browse files
committed
Added back the ability to make aspect-ratio dependent vignettes
1 parent c2601d2 commit dbbc916

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

PostProcessing/Editor/Models/VignetteModelEditor.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class VignetteModelEditor : PostProcessingModelEditor
1717
SerializedProperty m_Roundness;
1818
SerializedProperty m_Mask;
1919
SerializedProperty m_Opacity;
20+
SerializedProperty m_Rounded;
2021

2122
public override void OnEnable()
2223
{
@@ -28,6 +29,7 @@ public override void OnEnable()
2829
m_Roundness = FindSetting((Settings x) => x.roundness);
2930
m_Mask = FindSetting((Settings x) => x.mask);
3031
m_Opacity = FindSetting((Settings x) => x.opacity);
32+
m_Rounded = FindSetting((Settings x) => x.rounded);
3133
}
3234

3335
public override void OnInspectorGUI()
@@ -40,9 +42,8 @@ public override void OnInspectorGUI()
4042
EditorGUILayout.PropertyField(m_Center);
4143
EditorGUILayout.PropertyField(m_Intensity);
4244
EditorGUILayout.PropertyField(m_Smoothness);
43-
44-
if (m_Mode.intValue == (int)VignetteMode.Classic)
45-
EditorGUILayout.PropertyField(m_Roundness);
45+
EditorGUILayout.PropertyField(m_Roundness);
46+
EditorGUILayout.PropertyField(m_Rounded);
4647
}
4748
else
4849
{

PostProcessing/Resources/Shaders/Uber.shader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Shader "Hidden/Post FX/Uber Shader"
6666
// Vignette
6767
half3 _Vignette_Color;
6868
half2 _Vignette_Center; // UV space
69-
half3 _Vignette_Settings; // x: intensity, y: smoothness, z: roundness
69+
half4 _Vignette_Settings; // x: intensity, y: smoothness, z: roundness, w: rounded
7070
sampler2D _Vignette_Mask;
7171
half _Vignette_Opacity; // [0;1]
7272

@@ -227,7 +227,7 @@ Shader "Hidden/Post FX/Uber Shader"
227227
#if VIGNETTE_CLASSIC
228228
{
229229
half2 d = abs(uv - _Vignette_Center) * _Vignette_Settings.x;
230-
d.x *= _ScreenParams.x / _ScreenParams.y;
230+
d.x *= lerp(1.0, _ScreenParams.x / _ScreenParams.y, _Vignette_Settings.w);
231231
d = pow(d, _Vignette_Settings.z); // Roundness
232232
half vfactor = pow(saturate(1.0 - dot(d, d)), _Vignette_Settings.y);
233233
color *= lerp(_Vignette_Color, (1.0).xxx, vfactor);

PostProcessing/Runtime/Components/VignetteComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void Prepare(Material uberMaterial)
3030
uberMaterial.SetVector(Uniforms._Vignette_Center, settings.center);
3131
uberMaterial.EnableKeyword("VIGNETTE_CLASSIC");
3232
float roundness = (1f - settings.roundness) * 6f + settings.roundness;
33-
uberMaterial.SetVector(Uniforms._Vignette_Settings, new Vector3(settings.intensity * 3f, settings.smoothness * 5f, roundness));
33+
uberMaterial.SetVector(Uniforms._Vignette_Settings, new Vector4(settings.intensity * 3f, settings.smoothness * 5f, roundness, settings.rounded ? 1f : 0f));
3434
}
3535
else if (settings.mode == VignetteModel.Mode.Masked)
3636
{

PostProcessing/Runtime/Models/VignetteModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public struct Settings
3939
[Range(0f, 1f), Tooltip("Mask opacity.")]
4040
public float opacity;
4141

42+
[Tooltip("Should the vignette be perfectly round or be dependent on the current aspect ratio?")]
43+
public bool rounded;
44+
4245
public static Settings defaultSettings
4346
{
4447
get
@@ -52,7 +55,8 @@ public static Settings defaultSettings
5255
smoothness = 0.2f,
5356
roundness = 1f,
5457
mask = null,
55-
opacity = 1f
58+
opacity = 1f,
59+
rounded = false
5660
};
5761
}
5862
}

0 commit comments

Comments
 (0)