Skip to content

Commit 932dce9

Browse files
committed
Invert into smoothness
* Added in an invert function to the smoothness gui.
1 parent f8e20c9 commit 932dce9

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Assets/Scripts/SmoothnessGui.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class SmoothnessGui : MonoBehaviour
4848
private static readonly int FinalBias = Shader.PropertyToID("_FinalBias");
4949
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
5050
private static readonly int MetallicTex = Shader.PropertyToID("_MetallicTex");
51+
private static readonly int Invert = Shader.PropertyToID("_Invert");
5152
private Material _blitMaterial;
5253
private RenderTexture _blurMap;
5354
private Camera _camera;
@@ -72,6 +73,7 @@ public class SmoothnessGui : MonoBehaviour
7273
private Texture2D _sampleColorMap3;
7374

7475
private bool _selectingColor;
76+
private bool _invert;
7577

7678
private SmoothnessSettings _settings;
7779

@@ -228,7 +230,12 @@ private void Update()
228230
ThisMaterial.SetFloat(MaskLow3, _settings.MaskLow3);
229231
ThisMaterial.SetFloat(MaskHigh3, _settings.MaskHigh3);
230232
ThisMaterial.SetFloat(Sample3Smoothness, _settings.Sample3Smoothness);
231-
233+
int invert = 0;
234+
if (_settings.Invert)
235+
{
236+
invert = 1;
237+
}
238+
ThisMaterial.SetInt(Invert, invert);
232239
ThisMaterial.SetFloat(BaseSmoothness, _settings.BaseSmoothness);
233240

234241
ThisMaterial.SetFloat(Slider, _slider);
@@ -457,6 +464,10 @@ private void DoMyWindow(int windowId)
457464
GuiHelper.Slider(new Rect(offsetX, offsetY, 280, 50), "Final Bias", _settings.FinalBias,
458465
_settings.FinalBiasText,
459466
out _settings.FinalBias, out _settings.FinalBiasText, -0.5f, 0.5f);
467+
offsetY += 40;
468+
469+
_settings.Invert = GUI.Toggle(new Rect(offsetX, offsetY, 150, 20), _settings.Invert, "Invert Smoothness");
470+
460471
offsetY += 50;
461472

462473
if (GUI.Button(new Rect(offsetX + 10, offsetY, 130, 30), "Reset to Defaults"))
@@ -477,7 +488,7 @@ private void OnGUI()
477488
if (!_settingsInitialized) return;
478489

479490
_windowRect.width = 300;
480-
_windowRect.height = 490;
491+
_windowRect.height = 550;
481492

482493
if (_settings.UseSample1) _windowRect.height += 110;
483494

@@ -596,7 +607,12 @@ public IEnumerator ProcessSmoothness()
596607
_blitMaterial.SetFloat("_MaskLow3", _settings.MaskLow3);
597608
_blitMaterial.SetFloat("_MaskHigh3", _settings.MaskHigh3);
598609
_blitMaterial.SetFloat("_Sample3Smoothness", _settings.Sample3Smoothness);
599-
610+
int invert = 0;
611+
if (_settings.Invert)
612+
{
613+
invert = 1;
614+
}
615+
_blitMaterial.SetInt("_Invert",invert);
600616
_blitMaterial.SetFloat("_BaseSmoothness", _settings.BaseSmoothness);
601617

602618
_blitMaterial.SetFloat("_BlurOverlay", _settings.BlurOverlay);

Assets/Scripts/SmoothnessSettings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class SmoothnessSettings
7373

7474
[DefaultValue(0.2f)] public float Sample3Smoothness;
7575

76+
[DefaultValue(0)] public bool Invert;
77+
7678
//[DefaultValueAttribute(Color.black)]
7779
public Color SampleColor1;
7880

@@ -165,7 +167,7 @@ public SmoothnessSettings()
165167

166168
FinalBias = 0.0f;
167169
FinalBiasText = "0";
168-
170+
Invert = false;
169171
UseAdjustedDiffuse = false;
170172
UseOriginalDiffuse = true;
171173
}

0 commit comments

Comments
 (0)