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

Commit 092f0af

Browse files
committed
Added an anamorphic bloom option
1 parent c6b5d2a commit 092f0af

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

PostProcessing/Editor/Effects/BloomEditor.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ public sealed class BloomEditor : PostProcessEffectEditor<Bloom>
99
SerializedParameterOverride m_Threshold;
1010
SerializedParameterOverride m_SoftKnee;
1111
SerializedParameterOverride m_Diffusion;
12+
SerializedParameterOverride m_AnamorphicRatio;
1213
SerializedParameterOverride m_Color;
1314
SerializedParameterOverride m_MobileOptimized;
14-
15+
1516
SerializedParameterOverride m_LensTexture;
1617
SerializedParameterOverride m_LensIntensity;
1718

@@ -21,6 +22,7 @@ public override void OnEnable()
2122
m_Threshold = FindParameterOverride(x => x.threshold);
2223
m_SoftKnee = FindParameterOverride(x => x.softKnee);
2324
m_Diffusion = FindParameterOverride(x => x.diffusion);
25+
m_AnamorphicRatio = FindParameterOverride(x => x.anamorphicRatio);
2426
m_Color = FindParameterOverride(x => x.color);
2527
m_MobileOptimized = FindParameterOverride(x => x.mobileOptimized);
2628

@@ -31,17 +33,18 @@ public override void OnEnable()
3133
public override void OnInspectorGUI()
3234
{
3335
EditorUtilities.DrawHeaderLabel("Bloom");
34-
36+
3537
PropertyField(m_Intensity);
3638
PropertyField(m_Threshold);
3739
PropertyField(m_SoftKnee);
3840
PropertyField(m_Diffusion);
41+
PropertyField(m_AnamorphicRatio);
3942
PropertyField(m_Color);
4043
PropertyField(m_MobileOptimized);
41-
44+
4245
EditorGUILayout.Space();
4346
EditorUtilities.DrawHeaderLabel("Lens Dirtiness");
44-
47+
4548
PropertyField(m_LensTexture);
4649
PropertyField(m_LensIntensity);
4750

PostProcessing/Runtime/Effects/Bloom.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public sealed class Bloom : PostProcessEffectSettings
2222
[Range(1f, 10f), Tooltip("Changes the extent of veiling effects. For maximum quality stick to integer values. Because this value changes the internal iteration count, animating it isn't recommended as it may introduce small hiccups in the perceived radius.")]
2323
public FloatParameter diffusion = new FloatParameter { value = 7f };
2424

25+
[Range(-1f, 1f), Tooltip("Distorts the bloom to give an anamorphic look. Negative values distort vertically, positive values distort horizontally.")]
26+
public FloatParameter anamorphicRatio = new FloatParameter { value = 0f };
27+
2528
[ColorUsage(false, true, 0f, 8f, 0.125f, 3f), Tooltip("Global tint of the bloom filter.")]
2629
public ColorParameter color = new ColorParameter { value = Color.white };
2730

@@ -87,10 +90,15 @@ public override void Render(PostProcessRenderContext context)
8790
// Apply auto exposure adjustment in the prefiltering pass
8891
sheet.properties.SetTexture(ShaderIDs.AutoExposureTex, context.autoExposureTexture);
8992

93+
// Negative anamorphic ratio values distort vertically - positive is horizontal
94+
float ratio = Mathf.Clamp(settings.anamorphicRatio, -1, 1);
95+
float rw = ratio < 0 ? -ratio : 0f;
96+
float rh = ratio > 0 ? ratio : 0f;
97+
9098
// Do bloom on a half-res buffer, full-res doesn't bring much and kills performances on
9199
// fillrate limited platforms
92-
int tw = context.width / 2;
93-
int th = context.height / 2;
100+
int tw = Mathf.FloorToInt(context.width / (2f - rw));
101+
int th = Mathf.FloorToInt(context.height / (2f - rh));
94102

95103
// Determine the iteration count
96104
int s = Mathf.Max(tw, th);

0 commit comments

Comments
 (0)