summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Editor/tooner.cs309
-rw-r--r--Textures/white.png.meta6
-rw-r--r--feature_macros.cginc1
-rw-r--r--globals.cginc7
-rw-r--r--math.cginc8
-rw-r--r--mochie_shadow_caster.cginc21
-rw-r--r--pbr.cginc6
-rw-r--r--tooner.shader19
-rw-r--r--tooner_lighting.cginc30
9 files changed, 260 insertions, 147 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index da8aacc..e743dc2 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -538,124 +538,200 @@ public class ToonerGUI : ShaderGUI {
show_ui.Add(AddCollapsibleMenu("Decals", "_Decal"));
EditorGUI.indentLevel += 1;
for (int i = 0; i < 10; i++) {
- show_ui.Add(AddCollapsibleMenu($"Decal {i}", $"_Decal{i}"));
- EditorGUI.indentLevel += 1;
+ show_ui.Add(AddCollapsibleMenu($"Decal {i}", $"_Decal{i}"));
+ EditorGUI.indentLevel += 1;
- MaterialProperty bc = FindProperty($"_Decal{i}_Enable");
- bool enabled = bc.floatValue > 1E-6;
- EditorGUI.BeginChangeCheck();
- enabled = Toggle("Enable", enabled);
- EditorGUI.EndChangeCheck();
- bc.floatValue = enabled ? 1.0f : 0.0f;
- SetKeyword($"_DECAL{i}", enabled);
+ MaterialProperty bc = FindProperty($"_Decal{i}_Enable");
+ bool enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ SetKeyword($"_DECAL{i}", enabled);
- if (enabled) {
- MaterialProperty bct;
- bc = FindProperty($"_Decal{i}_Color");
- bct = FindProperty($"_Decal{i}_BaseColor");
- TexturePropertySingleLine(MakeLabel(bct, "Base color (RGBA)"), bct, bc);
- // Unconditionally drive scale + offset because it affects all textures.
- TextureScaleOffsetProperty(bct);
+ if (enabled) {
+ // Add up/down buttons in a horizontal layout
+ EditorGUILayout.BeginHorizontal();
+ if (i > 0 && GUILayout.Button("↑", GUILayout.Width(30))) {
+ SwapDecalSlots(i - 1, i);
+ }
+ if (i < 9 && GUILayout.Button("↓", GUILayout.Width(30))) {
+ SwapDecalSlots(i, i + 1);
+ }
+ EditorGUILayout.EndHorizontal();
- bc = FindProperty($"_Decal{i}_BaseColor_Mode");
- BaseColorMode base_color_mode = (BaseColorMode) Math.Round(bc.floatValue);
- base_color_mode = (BaseColorMode) EnumPopup(MakeLabel("Base color mode"), base_color_mode);
- bc.floatValue = (int) base_color_mode;
+ MaterialProperty bct;
+ bc = FindProperty($"_Decal{i}_Color");
+ bct = FindProperty($"_Decal{i}_BaseColor");
+ TexturePropertySingleLine(MakeLabel(bct, "Base color (RGBA)"), bct, bc);
+ // Unconditionally drive scale + offset because it affects all textures.
+ TextureScaleOffsetProperty(bct);
- if (base_color_mode == BaseColorMode.SDF) {
- bc = FindProperty($"_Decal{i}_SDF_Threshold");
- RangeProperty(bc, "SDF threshold");
+ bc = FindProperty($"_Decal{i}_BaseColor_Mode");
+ BaseColorMode base_color_mode = (BaseColorMode) Math.Round(bc.floatValue);
+ base_color_mode = (BaseColorMode) EnumPopup(MakeLabel("Base color mode"), base_color_mode);
+ bc.floatValue = (int) base_color_mode;
- bc = FindProperty($"_Decal{i}_SDF_Softness");
- RangeProperty(bc, "SDF softness");
+ if (base_color_mode == BaseColorMode.SDF) {
+ bc = FindProperty($"_Decal{i}_SDF_Threshold");
+ RangeProperty(bc, "SDF threshold");
- bc = FindProperty($"_Decal{i}_SDF_Px_Range");
- FloatProperty(bc, "SDF px range");
- }
+ bc = FindProperty($"_Decal{i}_SDF_Softness");
+ RangeProperty(bc, "SDF softness");
- bc = FindProperty($"_Decal{i}_Roughness");
- TexturePropertySingleLine(
- MakeLabel(bc, "Roughness"),
- bc);
- SetKeyword($"_DECAL{i}_ROUGHNESS", bc.textureValue);
+ bc = FindProperty($"_Decal{i}_SDF_Px_Range");
+ FloatProperty(bc, "SDF px range");
- bc = FindProperty($"_Decal{i}_Metallic");
- TexturePropertySingleLine(
- MakeLabel(bc, "Metallic"),
- bc);
- SetKeyword($"_DECAL{i}_METALLIC", bc.textureValue);
+ bc = FindProperty($"_Decal{i}_SDF_Invert");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Invert SDF", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ }
- bc = FindProperty($"_Decal{i}_Emission_Strength");
- FloatProperty(
- bc,
- "Emission strength");
- bc = FindProperty($"_Decal{i}_Angle");
- RangeProperty(
- bc,
- "Angle");
+ bc = FindProperty($"_Decal{i}_Roughness");
+ TexturePropertySingleLine(
+ MakeLabel(bc, "Roughness"),
+ bc);
+ SetKeyword($"_DECAL{i}_ROUGHNESS", bc.textureValue);
- bc = FindProperty($"_Decal{i}_Alpha_Multiplier");
- RangeProperty(bc, "Alpha multiplier");
+ bc = FindProperty($"_Decal{i}_Metallic");
+ TexturePropertySingleLine(
+ MakeLabel(bc, "Metallic"),
+ bc);
+ SetKeyword($"_DECAL{i}_METALLIC", bc.textureValue);
- bc = FindProperty($"_Decal{i}_Round_Alpha_Multiplier");
- enabled = bc.floatValue > 1E-6;
- EditorGUI.BeginChangeCheck();
- enabled = Toggle("Round alpha multiplier", enabled);
- EditorGUI.EndChangeCheck();
- bc.floatValue = enabled ? 1.0f : 0.0f;
+ bc = FindProperty($"_Decal{i}_Emission_Strength");
+ FloatProperty(
+ bc,
+ "Emission strength");
+ bc = FindProperty($"_Decal{i}_Angle");
+ RangeProperty(
+ bc,
+ "Angle");
- bct = FindProperty($"_Decal{i}_Mask");
- TexturePropertySingleLine(MakeLabel(bct, "Mask"), bct);
- SetKeyword($"_DECAL{i}_MASK", bct.textureValue);
+ bc = FindProperty($"_Decal{i}_Alpha_Multiplier");
+ RangeProperty(bc, "Alpha multiplier");
- if (bct.textureValue) {
- bc = FindProperty($"_Decal{i}_Mask_Invert");
+ bc = FindProperty($"_Decal{i}_Round_Alpha_Multiplier");
enabled = bc.floatValue > 1E-6;
EditorGUI.BeginChangeCheck();
- enabled = Toggle("Invert mask", enabled);
+ enabled = Toggle("Round alpha multiplier", enabled);
EditorGUI.EndChangeCheck();
bc.floatValue = enabled ? 1.0f : 0.0f;
- }
- bc = FindProperty($"_Decal{i}_Tiling_Mode");
- TilingMode tiling_mode = (TilingMode) Math.Round(bc.floatValue);
- tiling_mode = (TilingMode) EnumPopup(
- MakeLabel("Tiling mode"), tiling_mode);
- bc.floatValue = (int) tiling_mode;
+ bct = FindProperty($"_Decal{i}_Mask");
+ TexturePropertySingleLine(MakeLabel(bct, "Mask"), bct);
+ SetKeyword($"_DECAL{i}_MASK", bct.textureValue);
- bc = FindProperty($"_Decal{i}_UV_Select");
- RangeProperty(
- bc,
- "UV channel");
+ if (bct.textureValue) {
+ bc = FindProperty($"_Decal{i}_Mask_Invert");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Invert mask", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ }
- bc = FindProperty($"_Decal{i}_Domain_Warping_Enable_Static");
- enabled = bc.floatValue > 1E-6;
- EditorGUI.BeginChangeCheck();
- enabled = Toggle("Enable domain warping", enabled);
- EditorGUI.EndChangeCheck();
- bc.floatValue = enabled ? 1.0f : 0.0f;
- SetKeyword($"_DECAL{i}_DOMAIN_WARPING", enabled);
+ bc = FindProperty($"_Decal{i}_Tiling_Mode");
+ TilingMode tiling_mode = (TilingMode) Math.Round(bc.floatValue);
+ tiling_mode = (TilingMode) EnumPopup(
+ MakeLabel("Tiling mode"), tiling_mode);
+ bc.floatValue = (int) tiling_mode;
- if (enabled) {
- bc = FindProperty($"_Decal{i}_Domain_Warping_Noise");
- TexturePropertySingleLine(MakeLabel(bc, "Domain warping noise"), bc);
- bc = FindProperty($"_Decal{i}_Domain_Warping_Strength");
- FloatProperty(bc, "Domain warping noise strength");
- bc = FindProperty($"_Decal{i}_Domain_Warping_Speed");
- FloatProperty(bc, "Domain warping noise speed");
- bc = FindProperty($"_Decal{i}_Domain_Warping_Octaves");
- FloatProperty(bc, "Domain warping octaves");
- bc = FindProperty($"_Decal{i}_Domain_Warping_Scale");
- FloatProperty(bc, "Domain warping scale");
+ bc = FindProperty($"_Decal{i}_UV_Select");
+ RangeProperty(
+ bc,
+ "UV channel");
+
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Enable_Static");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable domain warping", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ SetKeyword($"_DECAL{i}_DOMAIN_WARPING", enabled);
+
+ if (enabled) {
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Noise");
+ TexturePropertySingleLine(MakeLabel(bc, "Domain warping noise"), bc);
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Strength");
+ FloatProperty(bc, "Domain warping noise strength");
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Speed");
+ FloatProperty(bc, "Domain warping noise speed");
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Octaves");
+ FloatProperty(bc, "Domain warping octaves");
+ bc = FindProperty($"_Decal{i}_Domain_Warping_Scale");
+ FloatProperty(bc, "Domain warping scale");
+ }
}
- }
- EditorGUI.indentLevel -= 1;
- show_ui.RemoveAt(show_ui.Count - 1);
+ EditorGUI.indentLevel -= 1;
+ show_ui.RemoveAt(show_ui.Count - 1);
}
EditorGUI.indentLevel -= 1;
show_ui.RemoveAt(show_ui.Count - 1);
}
+ void SwapDecalSlots(int slotA, int slotB) {
+ // List of property suffixes to swap
+ string[] propertiesToSwap = new string[] {
+ "_Enable",
+ "_Color",
+ "_BaseColor",
+ "_BaseColor_Mode",
+ "_SDF_Threshold",
+ "_SDF_Softness",
+ "_SDF_Px_Range",
+ "_Roughness",
+ "_Metallic",
+ "_Emission_Strength",
+ "_Angle",
+ "_Alpha_Multiplier",
+ "_Round_Alpha_Multiplier",
+ "_Mask",
+ "_Mask_Invert",
+ "_Tiling_Mode",
+ "_UV_Select",
+ "_Domain_Warping_Enable_Static",
+ "_Domain_Warping_Noise",
+ "_Domain_Warping_Strength",
+ "_Domain_Warping_Speed",
+ "_Domain_Warping_Octaves",
+ "_Domain_Warping_Scale"
+ };
+
+ // Record undo
+ RecordAction($"Swap decal slots {slotA} and {slotB}");
+
+ // For each property, swap values between slots
+ foreach (string prop in propertiesToSwap) {
+ MaterialProperty propA = FindProperty($"_Decal{slotA}{prop}");
+ MaterialProperty propB = FindProperty($"_Decal{slotB}{prop}");
+
+ if (propA != null && propB != null) {
+ if (propA.type == MaterialProperty.PropType.Color) {
+ Color tempColor = propA.colorValue;
+ propA.colorValue = propB.colorValue;
+ propB.colorValue = tempColor;
+ } else if (propA.type == MaterialProperty.PropType.Texture) {
+ var tempTex = propA.textureValue;
+ propA.textureValue = propB.textureValue;
+ propB.textureValue = tempTex;
+
+ // Also swap texture scale and offset
+ Vector4 tempScale = propA.textureScaleAndOffset;
+ propA.textureScaleAndOffset = propB.textureScaleAndOffset;
+ propB.textureScaleAndOffset = tempScale;
+ } else {
+ var tempValue = propA.floatValue;
+ propA.floatValue = propB.floatValue;
+ propB.floatValue = tempValue;
+ }
+ }
+ }
+ }
+
void DoEmission() {
show_ui.Add(AddCollapsibleMenu("Emission", "_Emission"));
EditorGUI.indentLevel += 1;
@@ -975,6 +1051,13 @@ public class ToonerGUI : ShaderGUI {
EditorGUI.EndChangeCheck();
bc.floatValue = enabled ? 1.0f : 0.0f;
+ bc = FindProperty($"_Rim_Lighting{i}_Use_Texture_Normals");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Use texture normals", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+
EditorGUI.BeginChangeCheck();
bc = FindProperty($"_Rim_Lighting{i}_Mode");
MatcapMode mode = (MatcapMode) Math.Round(bc.floatValue);
@@ -3202,19 +3285,22 @@ public class ToonerGUI : ShaderGUI {
SetKeyword("_RENDERING_CUTOUT_NOISE_MASK", cmode == CutoutMode.NoiseMask);
EditorGUI.indentLevel += 1;
- if (cmode == CutoutMode.Cutoff) {
- bc = FindProperty("_Alpha_Cutoff");
- ShaderProperty(bc, MakeLabel(bc));
- } else if (cmode == CutoutMode.NoiseMask) {
- bc = FindProperty("_Rendering_Cutout_Noise_Mask");
- TexturePropertySingleLine(
- MakeLabel(bc, "Noise mask"),
- bc);
- } else if (cmode == CutoutMode.InterleavedGradientNoise) {
- bc = FindProperty("_Rendering_Cutout_Ign_Seed");
- FloatProperty(bc, "Seed");
- bc = FindProperty("_Rendering_Cutout_Ign_Speed");
- FloatProperty(bc, "Speed");
+ {
+ if (cmode == CutoutMode.Cutoff) {
+ bc = FindProperty("_Alpha_Cutoff");
+ ShaderProperty(bc, MakeLabel(bc));
+ } else if (cmode == CutoutMode.NoiseMask) {
+ bc = FindProperty("_Rendering_Cutout_Noise_Mask");
+ TexturePropertySingleLine(
+ MakeLabel(bc, "Noise mask"),
+ bc);
+ } else if (cmode == CutoutMode.InterleavedGradientNoise) {
+ bc = FindProperty("_Rendering_Cutout_Ign_Seed");
+ FloatProperty(bc, "Seed");
+ }
+
+ bc = FindProperty("_Rendering_Cutout_Speed");
+ FloatProperty(bc, "Speed (for stochastic methods)");
}
EditorGUI.indentLevel -= 1;
}
@@ -3222,8 +3308,17 @@ public class ToonerGUI : ShaderGUI {
bc = FindProperty("_Rendering_Cutout_Noise_Scale");
FloatProperty(bc, "Cutout noise scale");
- bc = FindProperty("_Frame_Counter");
- FloatProperty(bc, "Frame counter");
+ bc = FindProperty("_Frame_Counter_Enable_Static");
+ bool enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Frame counter", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ SetKeyword("_FRAME_COUNTER", enabled);
+ if (enabled) {
+ bc = FindProperty("_Frame_Counter");
+ FloatProperty(bc, "Frame counter");
+ }
bc = FindProperty("_Cull");
UnityEngine.Rendering.CullMode cull_mode = (UnityEngine.Rendering.CullMode) bc.floatValue;
@@ -3244,7 +3339,7 @@ public class ToonerGUI : ShaderGUI {
bc.floatValue = (float) zmode;
bc = FindProperty("_Discard_Enable_Static");
- bool enabled = bc.floatValue > 1E-6;
+ enabled = bc.floatValue > 1E-6;
EditorGUI.BeginChangeCheck();
enabled = Toggle("Discard", enabled);
EditorGUI.EndChangeCheck();
diff --git a/Textures/white.png.meta b/Textures/white.png.meta
index 9e8caf0..738c890 100644
--- a/Textures/white.png.meta
+++ b/Textures/white.png.meta
@@ -72,9 +72,9 @@ TextureImporter:
maxTextureSize: 32
resizeAlgorithm: 0
textureFormat: -1
- textureCompression: 2
- compressionQuality: 50
- crunchedCompression: 0
+ textureCompression: 3
+ compressionQuality: 0
+ crunchedCompression: 1
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
diff --git a/feature_macros.cginc b/feature_macros.cginc
index 79532b4..c3379a9 100644
--- a/feature_macros.cginc
+++ b/feature_macros.cginc
@@ -224,6 +224,7 @@
#pragma shader_feature_local _ _DECAL9_METALLIC
#pragma shader_feature_local _ _DECAL9_MASK
#pragma shader_feature_local _ _DECAL9_DOMAIN_WARPING
+#pragma shader_feature_local _ _FRAME_COUNTER
#pragma shader_feature_local _ _LTCGI
#pragma shader_feature_local _ _FORCE_WORLD_LIGHTING
#pragma shader_feature_local _ _TESSELLATION
diff --git a/globals.cginc b/globals.cginc
index 213b65f..1e21712 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -272,6 +272,7 @@ float MERGE(_Decal,n,_Angle); \
float MERGE(_Decal,n,_Alpha_Multiplier); \
float MERGE(_Decal,n,_Round_Alpha_Multiplier); \
float MERGE(_Decal,n,_SDF_Threshold); \
+float MERGE(_Decal,n,_SDF_Invert); \
float MERGE(_Decal,n,_SDF_Softness); \
float MERGE(_Decal,n,_SDF_Px_Range); \
float MERGE(_Decal,n,_Tiling_Mode); \
@@ -384,9 +385,9 @@ float _Ambient_Occlusion_Strength;
#if defined(_RENDERING_CUTOUT)
float _Alpha_Cutoff;
+float _Rendering_Cutout_Speed;
#if defined(_RENDERING_CUTOUT_IGN)
float _Rendering_Cutout_Ign_Seed;
-float _Rendering_Cutout_Ign_Speed;
#endif
#endif
@@ -505,6 +506,7 @@ float _Rim_Lighting0_Mask2_Invert_Colors;
float _Rim_Lighting0_Mask2_Invert_Alpha;
float _Rim_Lighting0_Mask2_UV_Select;
float _Rim_Lighting0_Center_Eye_Fix;
+float _Rim_Lighting0_Use_Texture_Normals;
float _Rim_Lighting0_Center;
float _Rim_Lighting0_Power;
float _Rim_Lighting0_Strength;
@@ -541,6 +543,7 @@ float _Rim_Lighting1_Mask2_Invert_Colors;
float _Rim_Lighting1_Mask2_Invert_Alpha;
float _Rim_Lighting1_Mask2_UV_Select;
float _Rim_Lighting1_Center_Eye_Fix;
+float _Rim_Lighting1_Use_Texture_Normals;
float _Rim_Lighting1_Center;
float _Rim_Lighting1_Power;
float _Rim_Lighting1_Strength;
@@ -577,6 +580,7 @@ float _Rim_Lighting2_Mask2_Invert_Colors;
float _Rim_Lighting2_Mask2_Invert_Alpha;
float _Rim_Lighting2_Mask2_UV_Select;
float _Rim_Lighting2_Center_Eye_Fix;
+float _Rim_Lighting2_Use_Texture_Normals;
float _Rim_Lighting2_Center;
float _Rim_Lighting2_Power;
float _Rim_Lighting2_Strength;
@@ -613,6 +617,7 @@ float _Rim_Lighting3_Mask2_Invert_Colors;
float _Rim_Lighting3_Mask2_Invert_Alpha;
float _Rim_Lighting3_Mask2_UV_Select;
float _Rim_Lighting3_Center_Eye_Fix;
+float _Rim_Lighting3_Use_Texture_Normals;
float _Rim_Lighting3_Center;
float _Rim_Lighting3_Power;
float _Rim_Lighting3_Strength;
diff --git a/math.cginc b/math.cginc
index 2a384fb..80fa9ab 100644
--- a/math.cginc
+++ b/math.cginc
@@ -149,20 +149,12 @@ float rand(uint seed) {
}
// Generate a random number on [0, 1].
-/*
float rand2(float2 p)
{
return frac(sin(dot(p,
float2(12.9898, 78.233)))
* 43758.5453123);
}
-*/
-float rand2(float2 p)
-{
- float3 p3 = frac(float3(p.xyx) * float3(.1031, .1030, .0973));
- p3 += dot(p3, p3.yzx + 33.33);
- return frac((p3.x + p3.y) * p3.z);
-}
// Generate a random number on [0, 1].
float rand3(float3 p)
diff --git a/mochie_shadow_caster.cginc b/mochie_shadow_caster.cginc
index 375f078..785c5bd 100644
--- a/mochie_shadow_caster.cginc
+++ b/mochie_shadow_caster.cginc
@@ -120,31 +120,32 @@ float4 frag (v2f i) : SV_Target {
mixOverlayAlbedoRoughnessMetallic(albedo, roughness, metallic, ov, one, overlay_glitter_mask);
#if defined(_RENDERING_CUTOUT)
+#if defined(_FRAME_COUNTER)
+ float frame = floor(_Frame_Counter);
+#else
float frame = 0;
if (AudioLinkIsAvailable()) {
frame = ((float) AudioLinkData(ALPASS_GENERALVU + int2(1, 0)).x);
- } else {
- frame = floor(_Frame_Counter);
}
+#endif // _FRAME_COUNTER
#if defined(_RENDERING_CUTOUT_STOCHASTIC)
float ar = rand2(i.uv0);
clip(albedo.a - ar);
#elif defined(_RENDERING_CUTOUT_IGN)
- float ar = ign_anim(
- floor(tdata.screen_uv_round * _Rendering_Cutout_Noise_Scale) + _Rendering_Cutout_Ign_Seed,
- frame, _Rendering_Cutout_Ign_Speed);
+ float ar = ign(floor(tdata.screen_uv_round * _Rendering_Cutout_Noise_Scale) + _Rendering_Cutout_Ign_Seed);
+ ar = frac(ar + frame * PHI * _Rendering_Cutout_Speed);
clip(albedo.a - ar);
#elif defined(_RENDERING_CUTOUT_NOISE_MASK)
- float ar = frac(
- _Rendering_Cutout_Noise_Mask.SampleLevel(point_repeat_s, tdata.screen_uv * _ScreenParams.xy * _Rendering_Cutout_Noise_Mask_TexelSize.xy, 0)
- + frame * PHI);
- //return float4(ar, ar, ar, 1);
+ float ar = _Rendering_Cutout_Noise_Mask.SampleLevel(point_repeat_s,
+ tdata.screen_uv * _ScreenParams.xy *
+ _Rendering_Cutout_Noise_Mask_TexelSize.xy, 0);
+ ar = frac(ar + frame * PHI * _Rendering_Cutout_Speed);
clip(albedo.a - ar);
#else
clip(albedo.a - _Alpha_Cutoff);
#endif
albedo.a = 1;
-#endif
+#endif // _RENDERING_CUTOUT
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
return 0;
diff --git a/pbr.cginc b/pbr.cginc
index ee3d22b..bbb41b3 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -287,7 +287,7 @@ float4 getLitColor(
float sum_brightness = max(brightnesses[0] + brightnesses[1], min_brightness);
float2 brightness_proportions = brightnesses / sum_brightness;
- sum_brightness = smooth_clamp(sum_brightness, min_brightness, _Max_Brightness);
+ sum_brightness = clamp(sum_brightness, min_brightness, _Max_Brightness);
direct_light.color[2] = sum_brightness * brightness_proportions[0];
indirect_light.diffuse[2] = sum_brightness * brightness_proportions[1];
@@ -312,7 +312,7 @@ float4 getLitColor(
// Specular has to be clamped separately to avoid artifacting.
#if defined(_BRIGHTNESS_CLAMP)
- indirect_light.specular[2] = smooth_clamp(indirect_light.specular[2], min_brightness, _Max_Brightness);
+ indirect_light.specular[2] = clamp(indirect_light.specular[2], min_brightness, _Max_Brightness);
#endif
direct_light.color = HSVtoRGB(direct_light.color);
@@ -451,7 +451,7 @@ float4 getLitColor(
LoH,
h,
Fc);
- pbr.rgb += cc_term * (indirect_light.specular + indirect_light.diffuse) * cc_mask;
+ pbr.rgb += cc_term * indirect_light.specular * cc_mask;
}
// Direct
{
diff --git a/tooner.shader b/tooner.shader
index 4935934..34123fa 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -21,6 +21,7 @@ Shader "yum_food/tooner"
_Clearcoat_Use_Texture_Normals("Use texture normals", Float) = 1
_Rendering_Cutout_Noise_Mask("Noise mask", 2D) = "white" {}
+ _Rendering_Cutout_Speed("Speed (for stochastic methods)", Float) = 1
_MainTex("Base color", 2D) = "white" {}
[Normal] _BumpMap("Normal", 2D) = "bump" {}
@@ -135,6 +136,7 @@ Shader "yum_food/tooner"
_Decal0_BaseColor("Base color", 2D) = "white" {}
_Decal0_BaseColor_Mode("Base color mode", Float) = 0
_Decal0_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal0_SDF_Invert("SDF invert", Float) = 0
_Decal0_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal0_SDF_Px_Range("SDF px range", Float) = 2
_Decal0_Roughness("Roughness", 2D) = "white" {}
@@ -159,6 +161,7 @@ Shader "yum_food/tooner"
_Decal1_BaseColor("Base color", 2D) = "white" {}
_Decal1_BaseColor_Mode("Base color mode", Float) = 0
_Decal1_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal1_SDF_Invert("SDF invert", Float) = 0
_Decal1_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal1_SDF_Px_Range("SDF px range", Float) = 2
_Decal1_Roughness("Roughness", 2D) = "white" {}
@@ -183,6 +186,7 @@ Shader "yum_food/tooner"
_Decal2_BaseColor("Base color", 2D) = "white" {}
_Decal2_BaseColor_Mode("Base color mode", Float) = 0
_Decal2_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal2_SDF_Invert("SDF invert", Float) = 0
_Decal2_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal2_SDF_Px_Range("SDF px range", Float) = 2
_Decal2_Roughness("Roughness", 2D) = "white" {}
@@ -207,6 +211,7 @@ Shader "yum_food/tooner"
_Decal3_BaseColor("Base color", 2D) = "white" {}
_Decal3_BaseColor_Mode("Base color mode", Float) = 0
_Decal3_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal3_SDF_Invert("SDF invert", Float) = 0
_Decal3_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal3_SDF_Px_Range("SDF px range", Float) = 2
_Decal3_Roughness("Roughness", 2D) = "white" {}
@@ -231,6 +236,7 @@ Shader "yum_food/tooner"
_Decal4_BaseColor("Base color", 2D) = "white" {}
_Decal4_BaseColor_Mode("Base color mode", Float) = 0
_Decal4_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal4_SDF_Invert("SDF invert", Float) = 0
_Decal4_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal4_SDF_Px_Range("SDF px range", Float) = 2
_Decal4_Roughness("Roughness", 2D) = "white" {}
@@ -255,6 +261,7 @@ Shader "yum_food/tooner"
_Decal5_BaseColor("Base color", 2D) = "white" {}
_Decal5_BaseColor_Mode("Base color mode", Float) = 0
_Decal5_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal5_SDF_Invert("SDF invert", Float) = 0
_Decal5_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal5_SDF_Px_Range("SDF px range", Float) = 2
_Decal5_Roughness("Roughness", 2D) = "white" {}
@@ -279,6 +286,7 @@ Shader "yum_food/tooner"
_Decal6_BaseColor("Base color", 2D) = "white" {}
_Decal6_BaseColor_Mode("Base color mode", Float) = 0
_Decal6_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal6_SDF_Invert("SDF invert", Float) = 0
_Decal6_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal6_SDF_Px_Range("SDF px range", Float) = 2
_Decal6_Roughness("Roughness", 2D) = "white" {}
@@ -303,6 +311,7 @@ Shader "yum_food/tooner"
_Decal7_BaseColor("Base color", 2D) = "white" {}
_Decal7_BaseColor_Mode("Base color mode", Float) = 0
_Decal7_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal7_SDF_Invert("SDF invert", Float) = 0
_Decal7_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal7_SDF_Px_Range("SDF px range", Float) = 2
_Decal7_Roughness("Roughness", 2D) = "white" {}
@@ -327,6 +336,7 @@ Shader "yum_food/tooner"
_Decal8_BaseColor("Base color", 2D) = "white" {}
_Decal8_BaseColor_Mode("Base color mode", Float) = 0
_Decal8_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal8_SDF_Invert("SDF invert", Float) = 0
_Decal8_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal8_SDF_Px_Range("SDF px range", Float) = 2
_Decal8_Roughness("Roughness", 2D) = "white" {}
@@ -351,6 +361,7 @@ Shader "yum_food/tooner"
_Decal9_BaseColor("Base color", 2D) = "white" {}
_Decal9_BaseColor_Mode("Base color mode", Float) = 0
_Decal9_SDF_Threshold("SDF threshold", Range(0, 1)) = 0.5
+ _Decal9_SDF_Invert("SDF invert", Float) = 0
_Decal9_SDF_Softness("SDF softness", Range(0, 1)) = 0.01
_Decal9_SDF_Px_Range("SDF px range", Float) = 2
_Decal9_Roughness("Roughness", 2D) = "white" {}
@@ -397,7 +408,7 @@ Shader "yum_food/tooner"
_Reflection_Probe_Saturation("Reflection probe saturation", Range(0, 1)) = 1
_Enable_Brightness_Clamp("Enable brightness clamp", Float) = 0
_Min_Brightness("Min brightness", Range(0, 1)) = 0
- _Max_Brightness("Max brightness", Range(0, 1.5)) = 1
+ _Max_Brightness("Max brightness", Range(0, 10)) = 1
_Mesh_Normal_Strength("Mesh normal strength", Range(0, 10)) = 1
_NormalStr("Normal strength", Range(0, 10)) = 1
_Ambient_Occlusion("Ambient occlusion", 2D) = "white" {}
@@ -417,7 +428,7 @@ Shader "yum_food/tooner"
_Alpha_Cutoff("Alpha cutoff", Range(0, 1)) = 0.5
_Rendering_Cutout_Noise_Scale("Noise scale", Float) = 1
_Rendering_Cutout_Ign_Seed("IGN seed", Float) = 0
- _Rendering_Cutout_Ign_Speed("IGN speed", Float) = 0.00001
+ _Frame_Counter_Enable_Static("Frame counter enable", Float) = 0
_Frame_Counter("Frame counter", Float) = 0
_Outline_Width("Outline width", Range(0, 0.1)) = 0.01
@@ -597,6 +608,7 @@ Shader "yum_food/tooner"
_Rim_Lighting0_Custom_View_Vector_Enabled("custom view vector", Float) = 0
_Rim_Lighting0_Custom_View_Vector("custom view vector", Vector) = (1, 0, 0, 0)
_Rim_Lighting0_Center_Eye_Fix("Enable center eye fix", Float) = 0
+ _Rim_Lighting0_Use_Texture_Normals("Use texture normals", Float) = 1
_Rim_Lighting0_Reflect_In_World_Space("Reflect in world space", Float) = 0
_Rim_Lighting1_Enabled("Enable rim lighting", Float) = 0
@@ -627,6 +639,7 @@ Shader "yum_food/tooner"
_Rim_Lighting1_Custom_View_Vector_Enabled("custom view vector", Float) = 0
_Rim_Lighting1_Custom_View_Vector("custom view vector", Vector) = (1, 0, 0, 0)
_Rim_Lighting1_Center_Eye_Fix("Enable center eye fix", Float) = 0
+ _Rim_Lighting1_Use_Texture_Normals("Use texture normals", Float) = 1
_Rim_Lighting1_Reflect_In_World_Space("Reflect in world space", Float) = 0
_Rim_Lighting2_Enabled("Enable rim lighting", Float) = 0
@@ -657,6 +670,7 @@ Shader "yum_food/tooner"
_Rim_Lighting2_Custom_View_Vector_Enabled("custom view vector", Float) = 0
_Rim_Lighting2_Custom_View_Vector("custom view vector", Vector) = (1, 0, 0, 0)
_Rim_Lighting2_Center_Eye_Fix("Enable center eye fix", Float) = 0
+ _Rim_Lighting2_Use_Texture_Normals("Use texture normals", Float) = 1
_Rim_Lighting2_Reflect_In_World_Space("Reflect in world space", Float) = 0
_Rim_Lighting3_Enabled("Enable rim lighting", Float) = 0
@@ -687,6 +701,7 @@ Shader "yum_food/tooner"
_Rim_Lighting3_Custom_View_Vector_Enabled("custom view vector", Float) = 0
_Rim_Lighting3_Custom_View_Vector("custom view vector", Vector) = (1, 0, 0, 0)
_Rim_Lighting3_Center_Eye_Fix("Enable center eye fix", Float) = 0
+ _Rim_Lighting3_Use_Texture_Normals("Use texture normals", Float) = 1
_Rim_Lighting3_Reflect_In_World_Space("Reflect in world space", Float) = 0
_OKLAB_Enabled("Enable OKLAB", Float) = 0.0
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index eef6862..9195a73 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -642,6 +642,7 @@ struct DecalParams {
float tiling_mode;
float base_color_mode;
float sdf_threshold;
+ float sdf_invert;
float sdf_softness;
float sdf_px_range;
bool domain_warping;
@@ -693,6 +694,7 @@ void applyDecalImpl(
d0_uv, _Global_Sample_Bias);
} else if (p.base_color_mode == 1) {
float sd = p.tex.SampleLevel(linear_repeat_s, d0_uv, 0);
+ sd = p.sdf_invert ? 1 - sd : sd;
float2 screen_tex_size = 1 / fwidth(d0_uv);
float2 cell_size_texels = p.tex_texelsize.zw;
@@ -721,7 +723,7 @@ void applyDecalImpl(
albedo.rgb = lerp(albedo.rgb, d0_c.rgb, d0_c.a);
albedo.a = max(albedo.a, d0_c.a);
- decal_emission += d0_c.rgb * p.emission_strength * d0_c.a;
+ decal_emission = d0_c.rgb * p.emission_strength * d0_c.a + decal_emission * (1 - d0_c.a);
if (p.do_roughness) {
float4 d0_r = p.roughness_tex.SampleBias(linear_clamp_s, saturate(d0_uv), _Global_Sample_Bias);
@@ -753,6 +755,7 @@ void applyDecalImpl(
MERGE(d,n,_params).tiling_mode = MERGE(_Decal,n,_Tiling_Mode); \
MERGE(d,n,_params).base_color_mode = MERGE(_Decal,n,_BaseColor_Mode); \
MERGE(d,n,_params).sdf_threshold = MERGE(_Decal,n,_SDF_Threshold); \
+ MERGE(d,n,_params).sdf_invert = MERGE(_Decal,n,_SDF_Invert); \
MERGE(d,n,_params).sdf_softness = MERGE(_Decal,n,_SDF_Softness); \
MERGE(d,n,_params).sdf_px_range = MERGE(_Decal,n,_SDF_Px_Range); \
MERGE(d,n,_params).domain_warping = MERGE(_Decal,n,_Domain_Warping_Enable_Static); \
@@ -1427,31 +1430,32 @@ float4 effect(inout v2f i, out float depth)
#endif
#if defined(_RENDERING_CUTOUT)
+#if defined(_FRAME_COUNTER)
+ float frame = floor(_Frame_Counter);
+#else
float frame = 0;
if (AudioLinkIsAvailable()) {
frame = ((float) AudioLinkData(ALPASS_GENERALVU + int2(1, 0)).x);
- } else {
- frame = floor(_Frame_Counter);
}
+#endif // _FRAME_COUNTER
#if defined(_RENDERING_CUTOUT_STOCHASTIC)
float ar = rand2(i.uv0);
clip(albedo.a - ar);
#elif defined(_RENDERING_CUTOUT_IGN)
- float ar = ign_anim(
- floor(tdata.screen_uv_round * _Rendering_Cutout_Noise_Scale) + _Rendering_Cutout_Ign_Seed,
- frame, _Rendering_Cutout_Ign_Speed);
+ float ar = ign(floor(tdata.screen_uv_round * _Rendering_Cutout_Noise_Scale) + _Rendering_Cutout_Ign_Seed);
+ ar = frac(ar + frame * PHI * _Rendering_Cutout_Speed);
clip(albedo.a - ar);
#elif defined(_RENDERING_CUTOUT_NOISE_MASK)
- float ar = frac(
- _Rendering_Cutout_Noise_Mask.SampleLevel(point_repeat_s, tdata.screen_uv * _ScreenParams.xy * _Rendering_Cutout_Noise_Mask_TexelSize.xy, 0)
- + frame * PHI);
- //return float4(ar, ar, ar, 1);
+ float ar = _Rendering_Cutout_Noise_Mask.SampleLevel(point_repeat_s,
+ tdata.screen_uv * _ScreenParams.xy *
+ _Rendering_Cutout_Noise_Mask_TexelSize.xy, 0);
+ ar = frac(ar + frame * PHI * _Rendering_Cutout_Speed);
clip(albedo.a - ar);
#else
clip(albedo.a - _Alpha_Cutoff);
#endif
albedo.a = 1;
-#endif
+#endif // _RENDERING_CUTOUT
#if defined(_GIMMICK_AL_CHROMA_00)
if (_Gimmick_AL_Chroma_00_Forward_Pass && AudioLinkIsAvailable()) {
@@ -1476,10 +1480,10 @@ float4 effect(inout v2f i, out float depth)
float2 rl_uv;
{
#if defined(_RIM_LIGHTING0_REFLECT_IN_WORLD)
- const float3 cam_normal = normal;
+ const float3 cam_normal = _Rim_Lighting0_Use_Texture_Normals ? normal : i.normal;
const float3 cam_view_dir = rl_view_dir;
#else
- const float3 cam_normal = normalize(mul(UNITY_MATRIX_V, float4(normal, 0)));
+ const float3 cam_normal = normalize(mul(UNITY_MATRIX_V, float4(_Rim_Lighting0_Use_Texture_Normals ? normal : i.normal, 0)));
const float3 cam_view_dir = normalize(mul(UNITY_MATRIX_V, float4(rl_view_dir, 0)));
#endif
const float3 cam_refl = -reflect(cam_view_dir, cam_normal);