diff options
| author | yum <yum.food.vr@gmail.com> | 2024-10-17 17:56:05 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-10-17 17:56:05 -0700 |
| commit | dd46f7e166eabee42564b6dfe4c0a4e1d54b5e7d (patch) | |
| tree | c5c204f1e96b8b171dad1a0b7eaa9d4b3976661c | |
| parent | 182e51776a51977d480ac19e668d3c209e601766 (diff) | |
Begin work on aurora gimmick
| -rw-r--r-- | Editor/tooner.cs | 19 | ||||
| -rw-r--r-- | aurora.cginc | 65 | ||||
| -rw-r--r-- | feature_macros.cginc | 1 | ||||
| -rw-r--r-- | fog.cginc | 15 | ||||
| -rw-r--r-- | tooner.shader | 4 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 11 |
6 files changed, 100 insertions, 15 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 028b971..7007f30 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -2097,6 +2097,24 @@ public class ToonerGUI : ShaderGUI { EditorGUI.indentLevel -= 1; } + void DoGimmickAurora() { + MaterialProperty bc; + + bc = FindProperty("_Gimmick_Aurora_Enable_Static"); + bool enabled = (bc.floatValue != 0.0); + EditorGUI.BeginChangeCheck(); + enabled = Toggle("Aurora", enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = enabled ? 1.0f : 0.0f; + SetKeyword("_GIMMICK_AURORA", enabled); + + if (!enabled) { + return; + } + EditorGUI.indentLevel += 1; + EditorGUI.indentLevel -= 1; + } + void DoGimmicks() { show_ui.Add(AddCollapsibleMenu("Gimmicks", "_Gimmicks")); EditorGUI.indentLevel += 1; @@ -2117,6 +2135,7 @@ public class ToonerGUI : ShaderGUI { DoGimmickLetterGrid(); DoGimmickAudiolinkChroma00(); DoGimmickFog0(); + DoGimmickAurora(); DoClones(); DoExplosion(); DoGeoScroll(); diff --git a/aurora.cginc b/aurora.cginc new file mode 100644 index 0000000..c926482 --- /dev/null +++ b/aurora.cginc @@ -0,0 +1,65 @@ +#include "globals.cginc" +#include "interpolators.cginc" +#include "math.cginc" +#include "noise.cginc" +#include "cnlohr.cginc" + +#ifndef __AURORA_INC +#define __AURORA_INC + +struct AuroraPBR { + float4 albedo; + float3 diffuse; + float depth; +}; + +float2 rotate2D(float2 v, float theta) { + return mul(float2x2( + cos(theta), -sin(theta), + sin(theta), cos(theta)), v); +} + +AuroraPBR getAurora(v2f i) { + AuroraPBR result; + result.albedo.a = 1; + + // Map onto [-1, 1] + float t = _Time[1]; + float2 uv = i.uv0; + float c = 0; + + uv = rotate2D(uv, t * .101); + uv *= 0.9; + float c_term = sin(3.14159265 * uv.x * uv.x + t) - 0.25; + c = c_term * c_term; + + uv = rotate2D(uv, -t * .67); + c_term = (sin(-3.14159265 * uv.x * uv.x * 4 + t/4) - 0.25) * .5; + c += c_term * c_term; + + uv = rotate2D(uv, t * .31); + c += (sin(-3.14159265 * uv.y * uv.y * 16 + t/8) - 0.25) * .25; + + uv = rotate2D(uv, t * .15); + c += (sin(-3.14159265 * uv.x * uv.y * 16 + t/16) - 0.25) * .125; + + c *= 0.5; + + c -= sin(3.14159265 * uv.x * uv.y * 16) * .5 + 0.5; + + const float2 uv_c = i.uv0 * 2.0 - 1; + float center_distance_term = saturate(1.0 - dot(uv_c, uv_c)); + c *= center_distance_term * center_distance_term * center_distance_term * center_distance_term; + + result.albedo.rgb = saturate(c); + + result.diffuse = 0; + + float4 clip_pos = mul(UNITY_MATRIX_VP, float4(i.worldPos, 1.0)); + result.depth = clip_pos.z / clip_pos.w; + + return result; +} + +#endif // __AURORA_INC + diff --git a/feature_macros.cginc b/feature_macros.cginc index ff5c99f..df65e71 100644 --- a/feature_macros.cginc +++ b/feature_macros.cginc @@ -171,6 +171,7 @@ #pragma shader_feature_local _ _GIMMICK_FOG_00_EMITTER_1 #pragma shader_feature_local _ _GIMMICK_FOG_00_EMITTER_2 #pragma shader_feature_local _ _UNITY_FOG +#pragma shader_feature_local _ _GIMMICK_AURORA #endif // __FEATURE_MACROS_INC @@ -1,8 +1,8 @@ +#include "cnlohr.cginc" #include "globals.cginc" #include "interpolators.cginc" #include "math.cginc" #include "noise.cginc" -#include "cnlohr.cginc" #ifndef __FOG_INC #define __FOG_INC @@ -11,10 +11,8 @@ struct Fog00PBR { float4 albedo; - float3 normal; float3 diffuse; float depth; - float ao; }; #define FOG_PERLIN_NOISE_MODE 1 @@ -70,6 +68,7 @@ float map(float3 p, float lod) { return saturate(density); } +#if defined(_GIMMICK_FOG_00_EMITTER_TEXTURE) // Returns weighted color float3 getEmitterData(float3 p, float step_size, @@ -102,6 +101,7 @@ float3 getEmitterData(float3 p, float emitter_falloff = min(1, rcp(pow(emitter_dist, 1.4))); return in_range * emitter_falloff * em_color; } +#endif // defined(_GIMMICK_FOG_00_EMITTER_TEXTURE) Fog00PBR getFog00(v2f i) { @@ -176,8 +176,6 @@ Fog00PBR getFog00(v2f i) { const float2 em_scale_rcp = rcp(em_scale); #endif - float3 normal = i.normal; - float ao = 0; const float lod_denom = 1.0 / (_Gimmick_Fog_00_Lod_Half_Life * _Gimmick_Fog_00_Density); for (uint ii = 0; ii < step_count; ii++) { @@ -211,15 +209,8 @@ Fog00PBR getFog00(v2f i) { Fog00PBR pbr; pbr.albedo.rgb = 1; pbr.albedo.a = saturate(acc.a); - pbr.ao = 1; pbr.diffuse = acc.rgb; -#if 1 - pbr.normal = normalize(normal); -#else - pbr.normal = i.normal; -#endif - float4 clip_pos = mul(UNITY_MATRIX_VP, float4(ro, 1.0)); pbr.depth = clip_pos.z / clip_pos.w; diff --git a/tooner.shader b/tooner.shader index 2ddfb41..a7ccba6 100644 --- a/tooner.shader +++ b/tooner.shader @@ -184,7 +184,7 @@ Shader "yum_food/tooner" _Indirect_Specular_Lighting_Factor2("Indirect specular lighting factor", Range(0, 5)) = 1 _Indirect_Diffuse_Lighting_Factor("Indirect diffuse lighting factor", Range(0, 5)) = 1 _Reflection_Probe_Saturation("Reflection probe saturation", Range(0, 1)) = 1 - _Enable_Brightness_Clamp("Enable brightness clamp", Float) = 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 _Mesh_Normal_Strength("Mesh normal strength", Range(0, 10)) = 1 @@ -652,6 +652,8 @@ Shader "yum_food/tooner" _Gimmick_Fog_00_Emitter2_Normal("fog", Vector) = (-1, 0, 0, 0) _Gimmick_Fog_00_Emitter2_Scale_X("fog", Float) = 1 _Gimmick_Fog_00_Emitter2_Scale_Y("fog", Float) = 1 + + _Gimmick_Aurora_Enable_Static("Enable aurora", Float) = 0 } SubShader { diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index f771f4a..63cd69d 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -3,6 +3,7 @@ #include "UnityPBSLighting.cginc" #include "audiolink.cginc" +#include "aurora.cginc" #include "clones.cginc" #include "cnlohr.cginc" #include "disinfo.cginc" @@ -2203,8 +2204,14 @@ float4 effect(inout v2f i, out float depth) { Fog00PBR pbr = getFog00(i); albedo = pbr.albedo; - normal = pbr.normal; - ao = pbr.ao; + depth = pbr.depth; + diffuse_contrib += pbr.diffuse; + } +#endif +#if defined(_GIMMICK_AURORA) + { + AuroraPBR pbr = getAurora(i); + albedo = pbr.albedo; depth = pbr.depth; diffuse_contrib += pbr.diffuse; } |
