From bd414285c4e95dd666f4ab5058b5f2ef993c5699 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 26 Nov 2024 03:15:12 -0800 Subject: Interleaved gradient noise is now parameterized by frame count I'm using an AAP (vrc.school/docs/Other/AAPs/) to create a frame counter. That frame counter then drives this parameter. Thus the sparkly pattern won't turn into gross flashing when the framerate is low. Also add a speed parameter to control IGN. --- Editor/tooner.cs | 5 +++++ atrix256.cginc | 4 ++-- globals.cginc | 3 +++ tooner.shader | 2 ++ tooner_lighting.cginc | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 3a158c8..3453e4d 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -2518,10 +2518,15 @@ public class ToonerGUI : ShaderGUI { } else if (cmode == CutoutMode.InterleavedGradientNoise) { bc = FindProperty("_Rendering_Cutout_Ign_Seed"); FloatProperty(bc, "Seed"); + bc = FindProperty("_Rendering_Cutout_Ign_Speed"); + FloatProperty(bc, "Speed"); } EditorGUI.indentLevel -= 1; } + bc = FindProperty("_Frame_Counter"); + FloatProperty(bc, "Frame counter"); + bc = FindProperty("_Cull"); UnityEngine.Rendering.CullMode cull_mode = (UnityEngine.Rendering.CullMode) bc.floatValue; EditorGUI.BeginChangeCheck(); diff --git a/atrix256.cginc b/atrix256.cginc index 3eb164c..ccdc750 100644 --- a/atrix256.cginc +++ b/atrix256.cginc @@ -33,8 +33,8 @@ float ign(float2 screen_px) { 0.00583715 * screen_px.y, 1), 1); } -float ign_anim(float2 screen_px) { - float frame = frac(_Time[0]*.0005) * 64; +float ign_anim(float2 screen_px, float frame, float speed) { + frame = fmod(frame * speed, 64); return ign(screen_px + frame * 5.588238f); } diff --git a/globals.cginc b/globals.cginc index b5b2160..a038a05 100644 --- a/globals.cginc +++ b/globals.cginc @@ -37,6 +37,8 @@ float _Reflection_Probe_Saturation; float _Min_Brightness; float _Max_Brightness; +float _Frame_Counter; + float _Mesh_Normals_Mode; float _Flatten_Mesh_Normals_Str; float _Confabulate_Normals; @@ -320,6 +322,7 @@ float _Ambient_Occlusion_Strength; float _Alpha_Cutoff; #if defined(_RENDERING_CUTOUT_IGN) float _Rendering_Cutout_Ign_Seed; +float _Rendering_Cutout_Ign_Speed; #endif #endif diff --git a/tooner.shader b/tooner.shader index 44cac77..8f895c7 100644 --- a/tooner.shader +++ b/tooner.shader @@ -207,6 +207,8 @@ Shader "yum_food/tooner" _Alpha_Cutoff("Alpha cutoff", Range(0, 1)) = 0.5 _Rendering_Cutout_Ign_Seed("IGN seed", Float) = 0 + _Rendering_Cutout_Ign_Speed("IGN speed", Float) = 0.00001 + _Frame_Counter("Frame counter", Float) = 0 _Outline_Width("Outline width", Range(0, 0.1)) = 0.01 _Outline_Color("Outline color", Color) = (0, 0, 0, 1) diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index cfe8f32..8c183ae 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -1798,7 +1798,8 @@ float4 effect(inout v2f i, out float depth) float ar = rand2(i.uv0); clip(albedo.a - ar); #elif defined(_RENDERING_CUTOUT_IGN) - float ar = ign_anim(tdata.screen_uv_round+_Rendering_Cutout_Ign_Seed); + float ar = ign_anim(tdata.screen_uv_round + _Rendering_Cutout_Ign_Seed, + floor(_Frame_Counter), _Rendering_Cutout_Ign_Speed); clip(albedo.a - ar); #elif defined(_RENDERING_CUTOUT_NOISE_MASK) float ar = _Rendering_Cutout_Noise_Mask.SampleLevel(point_repeat_s, tdata.screen_uv * _ScreenParams.xy * _Rendering_Cutout_Noise_Mask_TexelSize.xy, 0); -- cgit v1.2.3