diff options
| author | yum <yum.food.vr@gmail.com> | 2024-10-29 16:22:34 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-10-29 16:22:34 -0700 |
| commit | c26d19e86b9365f468f34f73cbe648ab2520bdec (patch) | |
| tree | b0a5b024881ba895c9f30fa52781c57177b329bd /Editor | |
| parent | 9a492f33c29c8564bcec17edef0a6591518ca9d4 (diff) | |
Can now specify interpolation mode on most important textures
You can select {linear,point,bilinear}x{repeat,clamp} for base pbr,
overlays, and rim lighting (??) textures now.
Overlay masks also tile now.
Diffstat (limited to 'Editor')
| -rw-r--r-- | Editor/tooner.cs | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 116fb4f..0163e85 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -227,9 +227,16 @@ public class ToonerGUI : ShaderGUI { return enabled; } + // Why do the cartesian product here rather than in C? Easier to do it here + // than with C macros! enum SamplerMode { - Repeat, - Clamp, + // Why this order? Backwards compatibility when interpolation selection was introduced + LinearRepeat, + LinearClamp, + PointRepeat, + PointClamp, + BilinearRepeat, + BilinearClamp, }; void DoPBR() { show_ui.Add(AddCollapsibleMenu("PBR", "_PBR")); @@ -248,8 +255,12 @@ public class ToonerGUI : ShaderGUI { EditorGUI.EndChangeCheck(); bc.floatValue = (int) sampler_mode; - SetKeyword($"_PBR_SAMPLER_REPEAT", sampler_mode == SamplerMode.Repeat); - SetKeyword($"_PBR_SAMPLER_CLAMP", sampler_mode == SamplerMode.Clamp); + SetKeyword($"_PBR_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat); + SetKeyword($"_PBR_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp); + SetKeyword($"_PBR_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat); + SetKeyword($"_PBR_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp); + SetKeyword($"_PBR_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat); + SetKeyword($"_PBR_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp); } EditorGUI.indentLevel -= 1; show_ui.RemoveAt(show_ui.Count - 1); @@ -446,6 +457,8 @@ public class ToonerGUI : ShaderGUI { SetKeyword($"_PBR_OVERLAY{i}_MASK", bct.textureValue); if (bct.textureValue) { + TextureScaleOffsetProperty(bct); + bc = FindProperty($"_PBR_Overlay{i}_Mask_Invert"); enabled = bc.floatValue > 1E-6; EditorGUI.BeginChangeCheck(); @@ -470,11 +483,15 @@ public class ToonerGUI : ShaderGUI { bc = FindProperty($"_PBR_Overlay{i}_Sampler_Mode"); SamplerMode sampler_mode = (SamplerMode) Math.Round(bc.floatValue); sampler_mode = (SamplerMode) EnumPopup( - MakeLabel("Sampler mode"), sampler_mode); + MakeLabel("Sampler wrapping mode"), sampler_mode); EditorGUI.EndChangeCheck(); bc.floatValue = (int) sampler_mode; - SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_REPEAT", sampler_mode == SamplerMode.Repeat); - SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_CLAMP", sampler_mode == SamplerMode.Clamp); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat); + SetKeyword($"_PBR_OVERLAY{i}_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp); bc = FindProperty($"_PBR_Overlay{i}_Mip_Bias"); FloatProperty(bc, "Mip bias"); @@ -826,8 +843,12 @@ public class ToonerGUI : ShaderGUI { EditorGUI.EndChangeCheck(); bc.floatValue = (int) sampler_mode; - SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_REPEAT", sampler_mode == SamplerMode.Repeat); - SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_CLAMP", sampler_mode == SamplerMode.Clamp); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_LINEAR_REPEAT", sampler_mode == SamplerMode.LinearRepeat); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_LINEAR_CLAMP", sampler_mode == SamplerMode.LinearClamp); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_BILINEAR_REPEAT", sampler_mode == SamplerMode.BilinearRepeat); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_BILINEAR_CLAMP", sampler_mode == SamplerMode.BilinearClamp); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_POINT_REPEAT", sampler_mode == SamplerMode.PointRepeat); + SetKeyword($"_RIM_LIGHTING{i}_SAMPLER_POINT_CLAMP", sampler_mode == SamplerMode.PointClamp); EditorGUI.indentLevel -= 1; } |
