summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Editor/tooner.cs121
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc58
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc2
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc22
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc15
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc4
-rw-r--r--downstairs_02.cginc439
-rw-r--r--feature_macros.cginc2
-rw-r--r--globals.cginc30
-rw-r--r--iq_sdf.cginc22
-rw-r--r--oklab.cginc2
-rw-r--r--pbr.cginc10
-rw-r--r--tooner.shader36
-rw-r--r--tooner_lighting.cginc28
14 files changed, 762 insertions, 29 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs
index 60a5c2d..118c0fa 100644
--- a/Editor/tooner.cs
+++ b/Editor/tooner.cs
@@ -1802,6 +1802,118 @@ public class ToonerGUI : ShaderGUI {
EditorGUI.indentLevel -= 1;
}
+ void DoGimmickDownstairs2() {
+ MaterialProperty bc;
+ bc = FindProperty("_Gimmick_DS2_Enable_Static");
+ bool enabled = (bc.floatValue != 0.0);
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Downstairs 2", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ SetKeyword("_GIMMICK_DS2", enabled);
+
+ if (!enabled) {
+ return;
+ }
+
+ EditorGUI.indentLevel += 1;
+
+ bc = FindProperty("_Gimmick_DS2_Mask");
+ TexturePropertySingleLine(MakeLabel(bc, "Mask"), bc);
+ bc = FindProperty("_Gimmick_DS2_Noise");
+ TexturePropertySingleLine(MakeLabel(bc, "Noise"), bc);
+ bc = FindProperty("_Gimmick_DS2_Albedo_Factor");
+ FloatProperty(bc, "Albedo factor");
+ bc = FindProperty("_Gimmick_DS2_Emission_Factor");
+ FloatProperty(bc, "Emission factor");
+
+ bc = FindProperty("_Gimmick_DS2_00_Enable_Dynamic");
+ enabled = (bc.floatValue != 0.0);
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable effect 00", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+
+ if (enabled) {
+ EditorGUI.indentLevel += 1;
+
+ bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Octaves");
+ FloatProperty(bc, "Domain warping octaves");
+ bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Strength");
+ FloatProperty(bc, "Domain warping strength");
+ bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Scale");
+ FloatProperty(bc, "Domain warping scale");
+ bc = FindProperty("_Gimmick_DS2_00_Domain_Warping_Speed");
+ FloatProperty(bc, "Domain warping speed");
+
+ EditorGUI.indentLevel -= 1;
+ }
+
+ bc = FindProperty("_Gimmick_DS2_01_Enable_Dynamic");
+ enabled = (bc.floatValue != 0.0);
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable effect 01", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+
+ if (enabled) {
+ EditorGUI.indentLevel += 1;
+
+ bc = FindProperty("_Gimmick_DS2_01_Period");
+ VectorProperty(bc, "Period");
+ bc = FindProperty("_Gimmick_DS2_01_Count");
+ VectorProperty(bc, "Count");
+ bc = FindProperty("_Gimmick_DS2_01_Radius");
+ FloatProperty(bc, "Radius");
+
+ bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Octaves");
+ FloatProperty(bc, "Domain warping octaves");
+ bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Strength");
+ FloatProperty(bc, "Domain warping strength");
+ bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Scale");
+ FloatProperty(bc, "Domain warping scale");
+ bc = FindProperty("_Gimmick_DS2_01_Domain_Warping_Speed");
+ FloatProperty(bc, "Domain warping speed");
+
+ EditorGUI.indentLevel -= 1;
+ }
+
+ bc = FindProperty("_Gimmick_DS2_02_Enable_Dynamic");
+ enabled = (bc.floatValue != 0.0);
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable effect 02", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+
+ if (enabled) {
+ EditorGUI.indentLevel += 1;
+
+ EditorGUI.indentLevel -= 1;
+ }
+
+ bc = FindProperty("_Gimmick_DS2_03_Enable_Dynamic");
+ enabled = (bc.floatValue != 0.0);
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Enable effect 03", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+
+ if (enabled) {
+ EditorGUI.indentLevel += 1;
+
+ bc = FindProperty("_Gimmick_DS2_03_Period");
+ VectorProperty(bc, "Period");
+ bc = FindProperty("_Gimmick_DS2_03_Count");
+ VectorProperty(bc, "Count");
+ bc = FindProperty("_Gimmick_DS2_03_Edge_Length");
+ FloatProperty(bc, "Edge length");
+
+ EditorGUI.indentLevel -= 1;
+ }
+
+ EditorGUI.indentLevel -= 1;
+ }
+
void DoGimmickHalo00() {
MaterialProperty bc;
bc = FindProperty("_Gimmick_Halo00_Enable_Static");
@@ -2473,6 +2585,7 @@ public class ToonerGUI : ShaderGUI {
DoGimmickEyes00();
DoGimmickEyes01();
DoGimmickEyes02();
+ DoGimmickDownstairs2();
DoGimmickHalo00();
DoGimmickPixellate();
DoGimmickTrochoid();
@@ -2963,6 +3076,14 @@ public class ToonerGUI : ShaderGUI {
EditorGUI.indentLevel -= 1;
}
+ bc = FindProperty("_Force_World_Lighting");
+ enabled = bc.floatValue > 1E-6;
+ EditorGUI.BeginChangeCheck();
+ enabled = Toggle("Force world lighting", enabled);
+ EditorGUI.EndChangeCheck();
+ bc.floatValue = enabled ? 1.0f : 0.0f;
+ SetKeyword("_FORCE_WORLD_LIGHTING", enabled);
+
bc = FindProperty("_Aces_Filmic_Enable_Static");
enabled = bc.floatValue > 1E-6;
EditorGUI.BeginChangeCheck();
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc
index c6ad0b7..b976972 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI.cginc
@@ -41,9 +41,8 @@ void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x
{
if (!input.flags.lmdOnly) {
// very approximate lol
- float3 ctr = (input.Lw[0] + input.Lw[1])/2;
- float dist = length(ctr);
- if (dist > LTCGI_DISTANCE_FADE_APPROX_MULT)
+ float3 ctr = (input.Lw[0] + input.Lw[1]) * 0.5f;
+ if (dot(ctr, ctr) > LTCGI_DISTANCE_FADE_APPROX_MULT * LTCGI_DISTANCE_FADE_APPROX_MULT)
{
return;
}
@@ -53,6 +52,7 @@ void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x
#define RET1_IF_LMDIFF [branch] if (/*const*/ diffuse && input.flags.diffFromLm) { output.intensity = 1.0f; return; }
+ [branch]
if (input.flags.colormode == LTCGI_COLORMODE_SINGLEUV) {
float2 uv = input.uvStart;
if (uv.x < 0) uv.xy = uv.yx;
@@ -69,6 +69,7 @@ void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x
}
#ifdef LTCGI_AUDIOLINK
+ [branch]
if (input.flags.colormode == LTCGI_COLORMODE_AUDIOLINK) {
float al = AudioLinkData(ALPASS_AUDIOLINK + uint2(0, input.flags.alBand)).r;
output.color *= al;
@@ -133,6 +134,7 @@ void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x
LTCGI_ClipQuadToHorizon(L, n);
// early out if everything was clipped below horizon
+ [branch]
if (n == 0)
return;
@@ -140,15 +142,20 @@ void LTCGI_Evaluate(ltcgi_input input, float3 worldNorm, float3 viewDir, float3x
L[1] = normalize(L[1]);
L[2] = normalize(L[2]);
L[3] = normalize(L[3]);
- L[4] = normalize(L[4]);
- // integrate (and pray that constant folding works well)
+ // integrate
float sum = 0;
- [unroll(5)]
- for (uint v = 0; v < max(3, (uint)n); v++) {
- float3 a = L[v];
- float3 b = L[(v + 1) % 5];
- sum += LTCGI_IntegrateEdge(a, b).z;
+ sum += LTCGI_IntegrateEdge(L[0], L[1]).z;
+ sum += LTCGI_IntegrateEdge(L[1], L[2]).z;
+ sum += LTCGI_IntegrateEdge(L[2], L[3]).z;
+ [branch]
+ if (n >= 4)
+ {
+ L[4] = normalize(L[4]);
+ sum += LTCGI_IntegrateEdge(L[3], L[4]).z;
+ [branch]
+ if (n == 5)
+ sum += LTCGI_IntegrateEdge(L[4], L[0]).z;
}
// doublesided is accounted for with optimization at the start, so return abs
@@ -172,6 +179,15 @@ void LTCGI_Contribution(
totalSpecularIntensity = 0;
totalDiffuseIntensity = 0;
#endif
+
+ #ifdef LTCGI_SPECULAR_OFF
+ specular = 0;
+ #endif
+ #ifdef LTCGI_DIFFUSE_OFF
+ diffuse = 0;
+ #endif
+
+ [branch]
if (_Udon_LTCGI_GlobalEnable == 0.0f) {
return;
}
@@ -181,10 +197,6 @@ void LTCGI_Contribution(
float2 uv = float2(roughness, theta/(0.5*UNITY_PI));
uv = uv*LUT_SCALE + LUT_BIAS;
- #ifndef UNITY_UV_STARTS_AT_TOP
- uv.y = 1 - uv.y;
- #endif
-
// calculate LTCGI custom lightmap UV and sample
float3 lms = LTCGI_SampleShadowmap(lmuv);
@@ -210,9 +222,12 @@ void LTCGI_Contribution(
Minv = mul(Minv, identityBrdf);
// specular brightness
+ float spec_amp = 1.0f;
#ifndef LTCGI_SPECULAR_OFF
+ #ifndef LTCGI_DISABLE_LUT2
#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER
- float spec_amp = _Udon_LTCGI_lut2.SampleLevel(LTCGI_SAMPLER, uv, 0).x;
+ spec_amp = _Udon_LTCGI_lut2.SampleLevel(LTCGI_SAMPLER, uv, 0).x;
+ #endif
#endif
#endif
@@ -231,8 +246,14 @@ void LTCGI_Contribution(
#endif
// loop through all lights and add them to the output
+#if MAX_SOURCES != 1
uint count = min(_Udon_LTCGI_ScreenCount, MAX_SOURCES);
[loop]
+#else
+ // mobile config
+ const uint count = 1;
+ [unroll(1)]
+#endif
for (uint i = 0; i < count; i++) {
// skip masked and black lights
if (_Udon_LTCGI_Mask[i]) continue;
@@ -298,6 +319,7 @@ void LTCGI_Contribution(
lmd = smoothstep(0.0, LTCGI_SPECULAR_LIGHTMAP_STEP, saturate(lm - LTCGI_LIGHTMAP_CUTOFF));
}
ltcgi_output diff;
+ diff.color = 0;
LTCGI_Evaluate(input, worldNorm, viewDir, identityBrdf, roughness, true, diff);
diff.intensity *= lmd;
@@ -317,6 +339,7 @@ void LTCGI_Contribution(
if (flags.specular)
{
ltcgi_output spec;
+ spec.color = 0;
LTCGI_Evaluate(input, worldNorm, viewDir, Minv, roughness, false, spec);
spec.intensity *= spec_amp * smoothstep(0.0, LTCGI_SPECULAR_LIGHTMAP_STEP, saturate(lm - LTCGI_LIGHTMAP_CUTOFF));
@@ -336,14 +359,16 @@ void LTCGI_Contribution(
#ifndef LTCGI_API_V2
+// missing totalSpecularIntensity, totalDiffuseIntensity, specular
void LTCGI_Contribution(
float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse
) {
- half3 _u1;
+ half3 _u1 = (half3)0;
float _u2, _u3;
LTCGI_Contribution(worldPos, worldNorm, viewDir, roughness, lmuv, diffuse, _u1, _u2, _u3);
}
+// missing totalSpecularIntensity, totalDiffuseIntensity
void LTCGI_Contribution(
float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse, inout half3 specular
) {
@@ -351,6 +376,7 @@ void LTCGI_Contribution(
LTCGI_Contribution(worldPos, worldNorm, viewDir, roughness, lmuv, diffuse, specular, _u1, _u2);
}
+// missing totalDiffuseIntensity
void LTCGI_Contribution(
float3 worldPos, float3 worldNorm, float3 viewDir, float roughness, float2 lmuv, inout half3 diffuse, inout half3 specular, out float totalSpecularIntensity
) {
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
index 1ddb38a..e64f5a3 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
@@ -73,7 +73,7 @@ const float LUT_BIAS = 0.5/LUT_SIZE;
#define LTCGI_STATIC_UNIFORMS
// Allow statically textured lights.
-//#define LTCGI_STATIC_TEXTURES
+#define LTCGI_STATIC_TEXTURES
// Enable support for cylindrical screens.
//#define LTCGI_CYLINDER
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc
index ff33c87..08df1c7 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_functions.cginc
@@ -138,16 +138,28 @@ half3 premul_alpha(half4 i)
return i.rgb * i.a;
}
+half max2(half2 v)
+{
+ return max(v.x, v.y);
+}
+
void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
{
+#ifndef LTCGI_STATIC_TEXTURES
+ idx = 0; // optimize away the branches below
+#endif
+
#ifdef LTCGI_FAST_SAMPLING
#ifndef SHADER_TARGET_SURFACE_ANALYSIS
- blend *= 2.5f;
+ float outside = max2(abs(uv - 0.5f) - 0.5f);
+ float outmod = smoothstep(-0.1f, 0.1f, outside) * 2.5f;
+ blend = blend * 2.5f + outmod;
[branch]
if (idx == 0)
{
result = premul_alpha(_Udon_LTCGI_Texture_LOD0.SampleLevel(LTCGI_SAMPLER, uv, blend));
}
+ #ifdef LTCGI_STATIC_TEXTURES
else
{
result = UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD(
@@ -157,14 +169,12 @@ void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
blend
).rgb;
}
+ #endif
#else
result = 0;
#endif
#else
result = 0;
- #ifndef LTCGI_STATIC_TEXTURES
- idx = 0; // optimize away the branches below
- #endif
[branch]
if (lod == 0)
@@ -191,6 +201,7 @@ void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
return;
#endif
}
+ #ifdef LTCGI_STATIC_TEXTURES
else
{
result = premul_alpha(UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD(
@@ -201,6 +212,7 @@ void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
));
return;
}
+ #endif
}
}
@@ -227,6 +239,7 @@ void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
return;
#endif
}
+ #ifdef LTCGI_STATIC_TEXTURES
else
{
[forcecase]
@@ -258,6 +271,7 @@ void LTCGI_sample(float2 uv, uint lod, uint idx, float blend, out float3 result)
return;
}
}
+ #endif
#endif
}
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc
index 922c567..2c4a598 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_shadowmap.cginc
@@ -25,7 +25,7 @@ float4 LTCGI_cubic(float v)
// Unity's SampleTexture2DBicubic doesn't exist in 2018, which is our target here.
// So this is a similar function with tweaks to have similar semantics.
-float4 LTCGI_SampleTexture2DBicubicFilter(Texture2D tex, SamplerState smp, float2 coord, float4 texSize)
+float4 LTCGI_SampleTexture2DBicubicFilter(Texture2D tex, SamplerState smp, float2 coord, float4 texSize, bool lightmap = false)
{
coord = coord * texSize.xy - 0.5;
float fx = frac(coord.x);
@@ -45,6 +45,13 @@ float4 LTCGI_SampleTexture2DBicubicFilter(Texture2D tex, SamplerState smp, float
float4 sample2 = tex.Sample(smp, float2(offset.x, offset.w) * texSize.zw);
float4 sample3 = tex.Sample(smp, float2(offset.y, offset.w) * texSize.zw);
+ if (lightmap) {
+ sample0 = float4(DecodeLightmap(sample0), 1.0);
+ sample1 = float4(DecodeLightmap(sample1), 1.0);
+ sample2 = float4(DecodeLightmap(sample2), 1.0);
+ sample3 = float4(DecodeLightmap(sample3), 1.0);
+ }
+
float sx = s.x / (s.x + s.y);
float sy = s.z / (s.z + s.w);
@@ -68,10 +75,12 @@ float4 LTCGI_SampleShadowmap(float2 lmuv)
return LTCGI_SampleTexture2DBicubicFilter(
_Udon_LTCGI_Lightmap, LTCGI_SAMPLER,
- lmuv, _Udon_LTCGI_Lightmap_TexelSize
+ lmuv, _Udon_LTCGI_Lightmap_TexelSize,
+ true
);
#else
- return _Udon_LTCGI_Lightmap.Sample(LTCGI_SAMPLER, lmuv);
+ fixed4 sample = _Udon_LTCGI_Lightmap.Sample(LTCGI_SAMPLER, lmuv);
+ return float4(DecodeLightmap(sample), 1.0);
#endif
#endif
}
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc
index 116cedd..2bf4673 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_uniform.cginc
@@ -10,7 +10,9 @@ SamplerState sampler_LTCGI_trilinear_clamp_sampler;
// LUTs
#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER
+#ifndef LTCGI_DISABLE_LUT2
uniform Texture2D<float4> _Udon_LTCGI_lut2;
+#endif
uniform Texture2D<float4> _Udon_LTCGI_lut1;
#endif
@@ -120,12 +122,14 @@ uniform Texture2D<float4> _Udon_LTCGI_Texture_LOD3;
#endif
// static textures
+#ifdef LTCGI_STATIC_TEXTURES
UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD0_arr);
#ifndef LTCGI_FAST_SAMPLING
UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD1_arr);
UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD2_arr);
UNITY_DECLARE_TEX2DARRAY_NOSAMPLER(_Udon_LTCGI_Texture_LOD3_arr);
#endif
+#endif
// lightmap
#ifndef SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER
diff --git a/downstairs_02.cginc b/downstairs_02.cginc
new file mode 100644
index 0000000..844731c
--- /dev/null
+++ b/downstairs_02.cginc
@@ -0,0 +1,439 @@
+#include "atrix256.cginc"
+#include "globals.cginc"
+#include "interpolators.cginc"
+#include "iq_sdf.cginc"
+#include "math.cginc"
+#include "oklab.cginc"
+
+#ifndef __DOWNSTAIRS_02_INC
+#define __DOWNSTAIRS_02_INC
+
+#if defined(_GIMMICK_DS2)
+
+// All gimmicks here return this structure.
+struct Gimmick_DS2_Output {
+ float4 albedo;
+ float3 emission;
+ float3 normal;
+ float3 worldPos;
+ float metallic;
+ float roughness;
+};
+
+
+float ds2_00_distance_from_sphere(float3 p, float3 c, float r)
+{
+ return length(p - c) - r;
+}
+
+float ds2_00_map(float3 p, out float which)
+{
+ float t = _Time.y;
+ float theta = sin(_Time[0]) / 2;
+ float2x2 rot = float2x2(
+ cos(theta), -sin(theta),
+ sin(theta), cos(theta));
+
+ which = 0;
+ float dist = 1000 * 1000 * 1000;
+ #define Y_STEPS 5
+ for (int y = 0; y < Y_STEPS; y++)
+ {
+ const int yy = y - Y_STEPS/2;
+ #define X_STEPS 5
+ for (int x = 0; x < X_STEPS; x++)
+ {
+ const int xx = x - X_STEPS/2;
+ float2 pp = float2(xx * 2, yy * 2);
+ pp = mul(rot, pp);
+ float radius = cos((x + y + _Time[0]) * 3.14159) * 0.5 + 1;
+ float sphere = ds2_00_distance_from_sphere(p, float3(pp.x, pp.y, 0.0), radius);
+ which = lerp(which, y * Y_STEPS + x, sphere < dist);
+ dist = min(dist, sphere);
+ dist += sin(5.0 * pp.x) * sin(5.0 * pp.y) * 0.5;
+ }
+ }
+
+ return dist;
+}
+
+float3 ds2_00_calc_normal(in float3 p)
+{
+ const float3 small_step = float3(1E-4, 0.0, 0.0);
+
+ float which;
+ float center = ds2_00_map(p, which);
+ float gradient_x = ds2_00_map(p + small_step.xyy, which) - center;
+ float gradient_y = ds2_00_map(p + small_step.yxy, which) - center;
+ float gradient_z = ds2_00_map(p + small_step.yyx, which) - center;
+
+ float3 normal = float3(gradient_x, gradient_y, gradient_z);
+
+ return normalize(normal);
+}
+
+bool __ds2_00_march(float3 ro, float3 rd, inout float3 normal, out float which)
+{
+ float total_distance_traveled = 0.0;
+ const float MINIMUM_HIT_DISTANCE = 0.001;
+ const float MAXIMUM_TRACE_DISTANCE = 1000.0;
+
+ #define DS2_00_MARCH_STEPS 10
+ float distance_to_closest;
+ float3 current_position;
+ for (int i = 0; i < DS2_00_MARCH_STEPS; i++)
+ {
+ current_position = ro + total_distance_traveled * rd;
+
+ distance_to_closest = ds2_00_map(current_position, which);
+
+ if (distance_to_closest < MINIMUM_HIT_DISTANCE)
+ {
+ break;
+ }
+
+ if (total_distance_traveled > MAXIMUM_TRACE_DISTANCE)
+ {
+ break;
+ }
+ total_distance_traveled += distance_to_closest;
+ }
+
+ if (distance_to_closest < MINIMUM_HIT_DISTANCE) {
+ normal = ds2_00_calc_normal(current_position);
+ return true;
+ }
+
+ return false;
+}
+
+Gimmick_DS2_Output Gimmick_DS2_00(v2f i)
+{
+ float2 uv = i.uv0;
+ uv *= 2;
+ uv -= 1;
+ float2 warping_speed_vector = normalize(float2(97, 101));
+ for (uint ii = 0; ii < _Gimmick_DS2_00_Domain_Warping_Octaves; ii++)
+ {
+ float2 noise = _Gimmick_DS2_Noise.SampleLevel(linear_repeat_s, uv * _Gimmick_DS2_00_Domain_Warping_Scale + _Time[0] * _Gimmick_DS2_00_Domain_Warping_Speed * warping_speed_vector, 0);
+ uv += noise * _Gimmick_DS2_00_Domain_Warping_Strength;
+ }
+
+ float3 camera_position = float3(0.0, 0.0, -5.0);
+ float3 ro = camera_position;
+ float3 rd = float3(uv.x, uv.y, 1.0);
+
+ float3 normal;
+ float which;
+ bool hit = __ds2_00_march(ro, rd, normal, which);
+
+ float3 shaded_color = LRGBtoOKLCH(float3(0.7, 0, 0));
+ shaded_color[2] = which * TAU * 1.1 + _Time[1];
+ shaded_color = OKLCHtoLRGB(shaded_color);
+
+ shaded_color *= hit;
+
+ Gimmick_DS2_Output o;
+ o.albedo = float4(shaded_color * 5, 1.0);
+ o.emission = shaded_color;
+ o.normal = normal;
+ o.metallic = 0;
+ o.roughness = 1;
+ o.worldPos = i.worldPos;
+ return o;
+}
+
+float ds2_01_map(float3 p)
+{
+ p.z -= _Gimmick_DS2_01_Radius;
+ return distance_from_sphere(p, _Gimmick_DS2_01_Radius);
+}
+
+float3 ds2_01_nudge_p(float3 p, float3 e)
+{
+ return p + sin(e*TAU+_Time[0]*4) * _Gimmick_DS2_01_Radius * .5;
+}
+
+float ds2_01_map_dr(
+ float3 p,
+ float3 period,
+ float3 count,
+ out float3 which
+ )
+{
+ which = round(p / period);
+ // Direction to nearest neighboring cell.
+ float3 min_d = p - period * which;
+ float3 o = sign(min_d);
+
+ float d = 1E9;
+ float3 which_tmp = which;
+ for (uint xi = 0; xi < 2; xi++)
+ for (uint yi = 0; yi < 2; yi++)
+ {
+ float3 rid = which + float3(xi, yi, 0) * o;
+ rid = clamp(rid, ceil(-(count)*0.5), floor((count-1)*0.5));
+ float3 r = p - period * rid;
+ float3 e = float3(
+ rand3(rid / 100.0),
+ rand3(rid / 100.0 + 1),
+ rand3(rid / 100.0 + 2));
+ r = ds2_01_nudge_p(r, e);
+ float cur_d = ds2_01_map(r);
+ which_tmp = cur_d < d ? rid : which_tmp;
+ d = min(d, cur_d);
+ }
+
+ which = which_tmp;
+ return d;
+}
+
+
+float3 ds2_01_calc_normal(float3 p, float3 period, float3 count)
+{
+ const float3 small_step = float3(1E-5, 0.0, 0.0);
+ float3 which;
+ float center = ds2_01_map_dr(p, period, count, which);
+ return normalize(float3(
+ ds2_01_map_dr(p + small_step.xyz, period, count, which) - center,
+ ds2_01_map_dr(p + small_step.zxy, period, count, which) - center,
+ ds2_01_map_dr(p + small_step.yzx, period, count, which) - center
+ ));
+}
+
+Gimmick_DS2_Output Gimmick_DS2_01(inout v2f i)
+{
+ float3 camera_position = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1));
+ float3 ro = i.objPos;
+ float3 rd = normalize(i.objPos - camera_position);
+
+ float2 warping_speed_vector = normalize(float2(97, 101));
+ for (uint ii = 0; ii < _Gimmick_DS2_01_Domain_Warping_Octaves; ii++)
+ {
+ float2 noise = _Gimmick_DS2_Noise.SampleLevel(linear_repeat_s, ro.xy * _Gimmick_DS2_01_Domain_Warping_Scale + _Time[0] * _Gimmick_DS2_01_Domain_Warping_Speed * warping_speed_vector, 0);
+ ro.xy += noise * _Gimmick_DS2_01_Domain_Warping_Strength;
+ }
+
+#define DS2_01_MARCH_STEPS 8
+ float total_distance_traveled = 0.0;
+ const float MINIMUM_HIT_DISTANCE = 1E-4;
+ const float MAXIMUM_TRACE_DISTANCE = 30.0;
+ float distance_to_closest;
+ float3 which;
+ for (uint ii = 0; ii < DS2_01_MARCH_STEPS; ii++)
+ {
+ float3 current_position = ro + total_distance_traveled * rd;
+ distance_to_closest = ds2_01_map_dr(current_position,
+ _Gimmick_DS2_01_Period.xyz, _Gimmick_DS2_01_Count.xyz, which);
+ total_distance_traveled += distance_to_closest;
+ if (distance_to_closest < MINIMUM_HIT_DISTANCE ||
+ total_distance_traveled > MAXIMUM_TRACE_DISTANCE) {
+ break;
+ }
+ }
+
+ float3 normal = i.normal;
+ bool hit = distance_to_closest < MINIMUM_HIT_DISTANCE;
+ float3 color = LRGBtoOKLCH(float3(0.7, 0, 0));
+ color[0] += _Gimmick_DS2_Noise.SampleLevel(linear_repeat_s, ((which.xy / _Gimmick_DS2_01_Count.xy) + _Time[0]) / 10, 0);
+ color[2] = ign(which.xy + _Gimmick_DS2_01_Count.xy) * TAU * .1;
+ color[2] += _Gimmick_DS2_Noise.SampleLevel(linear_repeat_s, ((which.xy / _Gimmick_DS2_01_Count.xy) + _Time[0]) / 100, 0) * 5;
+ color = OKLCHtoLRGB(color);
+ if (hit) {
+ normal = ds2_01_calc_normal(ro + total_distance_traveled * rd,
+ _Gimmick_DS2_01_Period.xyz, _Gimmick_DS2_01_Count.xyz);
+ normal = UnityObjectToWorldNormal(normal);
+ }
+
+ Gimmick_DS2_Output o;
+ o.albedo = hit ? float4(color, 1) : 0;
+ o.emission = o.albedo;
+ o.normal = normal;
+ o.metallic = 0;
+ o.roughness = 0;
+ o.worldPos = i.worldPos;
+ return o;
+}
+
+float ds2_02_map(float3 p, out float which)
+{
+ float depth = .2;
+ which = 0;
+
+ // Create frame for lights.
+ float d0 = distance_from_box(p - float3(0, 0, depth), float3(.50, .50, depth));
+ float d1 = distance_from_box(p - float3(0, 0, 0), float3(.45, .45, depth));
+ float d2 = op_sub(d1, d0);
+
+ // Create lights.
+ float light_spacing = .12;
+ float d3 = d2;
+ which = -1;
+ for (uint i = 0; i < 3; i++) {
+ float d4 = distance_from_capped_cylinder(abs(p) - float3(i * light_spacing + light_spacing * .5, .45, depth * .5), .05, .03);
+ d3 = min(d3, d4);
+ }
+ for (uint i = 0; i < 3; i++) {
+ float d4 = distance_from_cylinder(abs(p) - float3(i * light_spacing + light_spacing * .5, 0, depth * .5), float3(0, 0, .025));
+ which = d4 < d3 ? ((int) i + 1) * 2 + (sign(p.x) > 0 ? 1 : 0) : which;
+ d3 = min(d3, d4);
+ }
+
+ return d3;
+}
+
+float3 ds2_02_calc_normal(float3 p)
+{
+ float3 small_step = float3(1E-5, 0.0, 0.0);
+ float which;
+ float center = ds2_02_map(p, which);
+ return normalize(float3(
+ ds2_02_map(p + small_step.xyz, which) - center,
+ ds2_02_map(p + small_step.zxy, which) - center,
+ ds2_02_map(p + small_step.yzx, which) - center
+ ));
+}
+
+Gimmick_DS2_Output Gimmick_DS2_02(inout v2f i)
+{
+ float3 camera_position = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1));
+ float3 ro = i.objPos;
+ float3 rd = normalize(i.objPos - camera_position);
+
+ #define DS2_02_MARCH_STEPS 30
+ float total_distance_traveled = 0.0;
+ const float MINIMUM_HIT_DISTANCE = 1E-3;
+ const float MAXIMUM_TRACE_DISTANCE = 30.0;
+ float distance_to_closest;
+ float which;
+ for (uint ii = 0; ii < DS2_02_MARCH_STEPS; ii++)
+ {
+ float3 current_position = ro + total_distance_traveled * rd;
+ distance_to_closest = ds2_02_map(current_position, which);
+ total_distance_traveled += distance_to_closest;
+ if (distance_to_closest < MINIMUM_HIT_DISTANCE ||
+ total_distance_traveled > MAXIMUM_TRACE_DISTANCE) {
+ break;
+ }
+ }
+
+ float3 normal = i.normal;
+ bool hit = distance_to_closest < MINIMUM_HIT_DISTANCE;
+ float3 color = (which == -1 ? 0.01 : 1.5);
+ if (hit) {
+ normal = ds2_02_calc_normal(ro + total_distance_traveled * rd);
+ normal = UnityObjectToWorldNormal(normal);
+ }
+
+ Gimmick_DS2_Output o;
+ o.albedo = hit ? float4(color, 1) : 0;
+ o.emission = color;
+ o.normal = normal;
+ o.metallic = 0;
+ o.roughness = 0.3;
+ o.worldPos = mul(unity_ObjectToWorld, float4(ro + total_distance_traveled * rd, 1));
+ return o;
+}
+
+float ds2_03_map(float3 p)
+{
+ float edge = _Gimmick_DS2_03_Edge_Length;
+ float thickness = edge*10;
+ return distance_from_round_box(p - float3(0, 0, thickness*.99), float3(edge, edge, thickness), edge * .1);
+}
+
+float3 ds2_03_nudge_p(float3 p, float3 which)
+{
+ float noise = _Gimmick_DS2_Noise.SampleLevel(linear_repeat_s, which.xy * _Gimmick_DS2_03_Period.xy * .2 + _Time[0] * .1, 0);
+ return p - float3(0, 0, noise * .01);
+ //return p + sin(e*TAU+_Time[0]*4) * _Gimmick_DS2_03_Edge_Length * .2 - noise;
+ //return p;
+}
+
+float ds2_03_map_dr(
+ float3 p,
+ float3 period,
+ float3 count,
+ out float3 which
+ )
+{
+ which = round(p / period);
+ // Direction to nearest neighboring cell.
+ float3 min_d = p - period * which;
+ float3 o = sign(min_d);
+
+ float d = 1E9;
+ float3 which_tmp = which;
+ for (uint xi = 0; xi < 2; xi++)
+ for (uint yi = 0; yi < 2; yi++)
+ {
+ float3 rid = which + float3(xi, yi, 0) * o;
+ rid = clamp(rid, ceil(-(count)*0.5), floor((count-1)*0.5));
+ float3 r = p - period * rid;
+ r = ds2_03_nudge_p(r, rid);
+ float cur_d = ds2_03_map(r);
+ which_tmp = cur_d < d ? rid : which_tmp;
+ d = min(d, cur_d);
+ }
+
+ which = which_tmp;
+ return d;
+}
+
+float3 ds2_03_calc_normal(float3 p)
+{
+ float3 small_step = float3(1E-5, 0.0, 0.0);
+ float3 which;
+ float center = ds2_03_map_dr(p, _Gimmick_DS2_03_Period.xyz, _Gimmick_DS2_03_Count.xyz, which);
+ return normalize(float3(
+ ds2_03_map_dr(p + small_step.xyz, _Gimmick_DS2_03_Period.xyz, _Gimmick_DS2_03_Count.xyz, which) - center,
+ ds2_03_map_dr(p + small_step.zxy, _Gimmick_DS2_03_Period.xyz, _Gimmick_DS2_03_Count.xyz, which) - center,
+ ds2_03_map_dr(p + small_step.yzx, _Gimmick_DS2_03_Period.xyz, _Gimmick_DS2_03_Count.xyz, which) - center
+ ));
+}
+
+Gimmick_DS2_Output Gimmick_DS2_03(inout v2f i)
+{
+ float3 camera_position = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1));
+ float3 ro = i.objPos;
+ float3 rd = normalize(i.objPos - camera_position);
+
+ #define DS2_03_MARCH_STEPS 30
+ float total_distance_traveled = 0.0;
+ const float MINIMUM_HIT_DISTANCE = 1E-3;
+ const float MAXIMUM_TRACE_DISTANCE = 30.0;
+ float distance_to_closest;
+ float3 which;
+ for (uint ii = 0; ii < DS2_03_MARCH_STEPS; ii++)
+ {
+ float3 current_position = ro + total_distance_traveled * rd;
+ distance_to_closest = ds2_03_map_dr(current_position, _Gimmick_DS2_03_Period.xyz, _Gimmick_DS2_03_Count.xyz, which);
+ total_distance_traveled += distance_to_closest;
+ if (distance_to_closest < MINIMUM_HIT_DISTANCE ||
+ total_distance_traveled > MAXIMUM_TRACE_DISTANCE) {
+ break;
+ }
+ }
+
+ bool hit = distance_to_closest < MINIMUM_HIT_DISTANCE;
+ float3 normal = hit ? UnityObjectToWorldNormal(ds2_03_calc_normal(ro + total_distance_traveled * rd)) : i.normal;
+
+ float3 light_dir = normalize(float3(0.5, -0.5, -0.5));
+ float3 light_color = float3(1, 1, 1);
+ float ndotl = saturate(dot(normal, light_dir));
+ float wrap_factor = 0.5;
+ float4 wrapped = pow(max(1E-4, (ndotl + wrap_factor) / (1 + wrap_factor)), 1 + wrap_factor);
+ float3 light_intensity = light_color * wrapped;
+
+ Gimmick_DS2_Output o;
+ o.albedo = hit ? float4(light_intensity, 1) : 0;
+ o.emission = o.albedo;
+ o.normal = normal;
+ o.metallic = 0;
+ o.roughness = 0;
+ o.worldPos = mul(unity_ObjectToWorld, float4(ro + total_distance_traveled * rd, 1));
+ return o;
+}
+
+#endif // _GIMMICK_DS2
+#endif // __DOWNSTAIRS_02_INC
diff --git a/feature_macros.cginc b/feature_macros.cginc
index 3c358fb..2502ebd 100644
--- a/feature_macros.cginc
+++ b/feature_macros.cginc
@@ -225,6 +225,7 @@
#pragma shader_feature_local _ _DECAL9_MASK
#pragma shader_feature_local _ _DECAL9_DOMAIN_WARPING
#pragma shader_feature_local _ _LTCGI
+#pragma shader_feature_local _ _FORCE_WORLD_LIGHTING
#pragma shader_feature_local _ _TESSELLATION
#pragma shader_feature_local _ _MATCAP0_DISTORTION0
#pragma shader_feature_local _ _MATCAP1_DISTORTION0
@@ -237,6 +238,7 @@
#pragma shader_feature_local _ _GIMMICK_EYES_00
#pragma shader_feature_local _ _GIMMICK_EYES_01
#pragma shader_feature_local _ _GIMMICK_EYES_02
+#pragma shader_feature_local _ _GIMMICK_DS2
#pragma shader_feature_local _ _GIMMICK_HALO_00
#pragma shader_feature_local _ _PIXELLATE
#pragma shader_feature_local _ _TROCHOID
diff --git a/globals.cginc b/globals.cginc
index f63453b..40e216d 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -756,6 +756,36 @@ float _Gimmick_Eyes02_Roughness;
float3 _Gimmick_Eyes02_Emission;
#endif
+#if defined(_GIMMICK_DS2)
+float _Gimmick_DS2_Enable_Static;
+texture2D _Gimmick_DS2_Mask;
+texture2D _Gimmick_DS2_Noise;
+// 00
+float _Gimmick_DS2_00_Enable_Dynamic;
+float _Gimmick_DS2_Albedo_Factor;
+float _Gimmick_DS2_Emission_Factor;
+float _Gimmick_DS2_00_Domain_Warping_Octaves;
+float _Gimmick_DS2_00_Domain_Warping_Strength;
+float _Gimmick_DS2_00_Domain_Warping_Scale;
+float _Gimmick_DS2_00_Domain_Warping_Speed;
+// 01
+float _Gimmick_DS2_01_Enable_Dynamic;
+float4 _Gimmick_DS2_01_Period;
+float4 _Gimmick_DS2_01_Count;
+float _Gimmick_DS2_01_Radius;
+float _Gimmick_DS2_01_Domain_Warping_Octaves;
+float _Gimmick_DS2_01_Domain_Warping_Strength;
+float _Gimmick_DS2_01_Domain_Warping_Scale;
+float _Gimmick_DS2_01_Domain_Warping_Speed;
+// 02
+float _Gimmick_DS2_02_Enable_Dynamic;
+// 03
+float _Gimmick_DS2_03_Enable_Dynamic;
+float4 _Gimmick_DS2_03_Period;
+float4 _Gimmick_DS2_03_Count;
+float _Gimmick_DS2_03_Edge_Length;
+#endif
+
#if defined(_PIXELLATE)
float _Gimmick_Pixellate_Enable_Static;
float _Gimmick_Pixellate_Resolution_U;
diff --git a/iq_sdf.cginc b/iq_sdf.cginc
index 6320e57..fa5f2c5 100644
--- a/iq_sdf.cginc
+++ b/iq_sdf.cginc
@@ -56,6 +56,12 @@ float distance_from_box(float3 p, float3 b)
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
+float distance_from_round_box(float3 p, float3 b, float r)
+{
+ float3 q = abs(p) - b + r;
+ return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) - r;
+}
+
float distance_from_box_frame(float3 p, float3 b, float e)
{
p = abs(p)-b;
@@ -97,11 +103,27 @@ float distance_from_plane(float3 p, float3 n, float h)
return dot(p,n) + h;
}
+float distance_from_cylinder(float3 p, float3 c)
+{
+ return length(p.xz-c.xy)-c.z;
+}
+
+float distance_from_capped_cylinder(float3 p, float h, float r)
+{
+ float2 d = abs(float2(length(p.xz),p.y)) - float2(r,h);
+ return min(max(d.x,d.y),0.0) + length(max(d,0.0));
+}
+
float3 op_rep(in float3 p, in float3 c)
{
return glsl_mod(p+0.5*c,c)-0.5*c;
}
+float op_sub(float d1, float d2)
+{
+ return max(-d1,d2);
+}
+
// End licensed section
#endif // __IQ_SDF_INC
diff --git a/oklab.cginc b/oklab.cginc
index 004dbc4..0a354f3 100644
--- a/oklab.cginc
+++ b/oklab.cginc
@@ -29,7 +29,7 @@
#ifndef __OKLAB_INC
#define __OKLAB_INC
-#if defined(_OKLAB) || defined(_GIMMICK_LETTER_GRID_COLOR_WAVE) || defined(_GIMMICK_AL_CHROMA_00_HUE_SHIFT) || defined(_GIMMICK_FOG_00)
+#if defined(_OKLAB) || defined(_GIMMICK_LETTER_GRID_COLOR_WAVE) || defined(_GIMMICK_AL_CHROMA_00_HUE_SHIFT) || defined(_GIMMICK_FOG_00) || defined(_GIMMICK_DS2)
// Utilities relating to the OKLAB color space, as defined here:
// https://bottosson.github.io/posts/oklab/
diff --git a/pbr.cginc b/pbr.cginc
index 8dda05d..c839dcc 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -245,7 +245,8 @@ float4 getLitColor(
direct_light.color *= (1 - e);
}
-#if 0 && defined(_LTCGI)
+#if defined(_LTCGI)
+#if !defined(LIGHTMAP_ON) && !defined(_FORCE_WORLD_LIGHTING)
ltcgi_acc acc = (ltcgi_acc) 0;
if (_LTCGI_Enabled_Dynamic) {
LTCGI_Contribution(
@@ -259,6 +260,7 @@ float4 getLitColor(
indirect_light.specular += acc.specular;
}
#endif
+#endif
#if defined(_BRIGHTNESS_CLAMP) || defined(_PROXIMITY_DIMMING)
direct_light.color = RGBtoHSV(direct_light.color);
@@ -382,7 +384,8 @@ float4 getLitColor(
#endif
-#if 1 && defined(_LTCGI)
+#if defined(_LTCGI)
+#if defined(LIGHTMAP_ON) || defined(_FORCE_WORLD_LIGHTING)
ltcgi_acc acc = (ltcgi_acc) 0;
if (_LTCGI_Enabled_Dynamic) {
LTCGI_Contribution(
@@ -392,9 +395,10 @@ float4 getLitColor(
view_dir,
1.0 - smoothness,
i.uv2);
- pbr.rgb += acc.diffuse * pbr.rgb + acc.specular;
+ pbr.rgb += (acc.diffuse * pbr.rgb + acc.specular) * albedo.a;
}
#endif
+#endif
// TODO formalize with parameters
// Break up color banding by adding some dithering to shaded color.
diff --git a/tooner.shader b/tooner.shader
index 025e7b1..fe6627c 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -3,7 +3,7 @@ Shader "yum_food/tooner"
// Unity fucking sucks ass and sometimes incorrectly uses an old cached
// version of the shader. Bump the nonce below to encourage it to use the
// current version.
- // Build nonce: 34
+ // Build nonce: 35
Properties
{
_Color("Base color", Color) = (0.8, 0.8, 0.8, 1)
@@ -733,6 +733,8 @@ Shader "yum_food/tooner"
_LTCGI_SpecularColor("LTCGI specular color", Color) = (1, 1, 1, 1)
_LTCGI_DiffuseColor("LTCGI diffuse color", Color) = (1, 1, 1, 1)
+ _Force_World_Lighting("Force world lighting", Float) = 0.0
+
_Cutout_Mode("Cutout rendering mode", Float) = 0.0
_Render_Queue_Offset("Render queue offset", Integer) = 0
@@ -794,6 +796,35 @@ Shader "yum_food/tooner"
_Gimmick_Eyes02_Roughness ("Roughness", Range(0, 1)) = 0.5
_Gimmick_Eyes02_Emission ("Emission", Color) = (0, 0, 0, 1)
+ _Gimmick_DS2_Enable_Static ("Enable (static)", Float) = 0
+ _Gimmick_DS2_Noise ("Noise", 2D) = "black" {}
+ _Gimmick_DS2_Mask("Mask", 2D) = "white" {}
+ _Gimmick_DS2_Albedo_Factor("Albedo factor", Float) = 1
+ _Gimmick_DS2_Emission_Factor("Emission factor", Float) = 1
+ // Effect 00
+ _Gimmick_DS2_00_Enable_Dynamic("Enable effect 00 (dynamic)", Float) = 0
+ _Gimmick_DS2_00_Domain_Warping_Octaves("Domain warping octaves", Float) = 3
+ _Gimmick_DS2_00_Domain_Warping_Strength("Domain warping strength", Float) = 1
+ _Gimmick_DS2_00_Domain_Warping_Scale("Domain warping scale", Float) = 1
+ _Gimmick_DS2_00_Domain_Warping_Speed("Domain warping speed", Float) = 1
+ // Effect 01
+ _Gimmick_DS2_01_Enable_Dynamic("Enable effect 01 (dynamic)", Float) = 0
+ _Gimmick_DS2_01_Period("Period", Vector) = (1, 1, 1, 1)
+ _Gimmick_DS2_01_Count("Count", Vector) = (1, 1, 1, 1)
+ _Gimmick_DS2_01_Radius("Radius", Float) = 1
+ _Gimmick_DS2_01_Domain_Warping_Octaves("Domain warping octaves", Float) = 3
+ _Gimmick_DS2_01_Domain_Warping_Strength("Domain warping strength", Float) = 1
+ _Gimmick_DS2_01_Domain_Warping_Scale("Domain warping scale", Float) = 1
+ _Gimmick_DS2_01_Domain_Warping_Speed("Domain warping speed", Float) = 1
+ // Effect 02
+ _Gimmick_DS2_02_Enable_Dynamic("Enable effect 02 (dynamic)", Float) = 0
+ // Effect 03
+ _Gimmick_DS2_03_Enable_Dynamic("Enable effect 03 (dynamic)", Float) = 0
+ _Gimmick_DS2_03_Period("Period", Vector) = (1, 1, 1, 1)
+ _Gimmick_DS2_03_Count("Count", Vector) = (1, 1, 1, 1)
+ _Gimmick_DS2_03_Edge_Length("Edge length", Float) = 0.1
+
+
_Gimmick_Halo00_Enable_Static("Enable halo", Float) = 0.0
_Gimmick_Pixellate_Enable_Static("Enable pixellation", Float) = 0.0
@@ -986,6 +1017,7 @@ Shader "yum_food/tooner"
"RenderType"="Opaque"
"Queue"="Geometry"
"LightMode"="ForwardBase"
+ "LTCGI"="ALWAYS"
}
Blend [_SrcBlend] [_DstBlend]
ZWrite [_ZWrite]
@@ -1018,6 +1050,7 @@ Shader "yum_food/tooner"
#include "tooner_lighting.cginc"
ENDCG
}
+ /*
Pass {
Tags {
"RenderType"="Opaque"
@@ -1099,6 +1132,7 @@ Shader "yum_food/tooner"
#include "mochie_shadow_caster.cginc"
ENDCG
}
+ */
}
CustomEditor "ToonerGUI"
}
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index 7224152..21d97b0 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -7,6 +7,7 @@
#include "clones.cginc"
#include "cnlohr.cginc"
#include "disinfo.cginc"
+#include "downstairs_02.cginc"
#include "eyes.cginc"
#include "fog.cginc"
#include "gerstner.cginc"
@@ -2747,6 +2748,30 @@ float4 effect(inout v2f i, out float depth)
albedo.rgb += glitter_color_unlit * _Glitter_Brightness_Lit;
#endif
+#if defined(_GIMMICK_DS2)
+ Gimmick_DS2_Output ds2 = (Gimmick_DS2_Output)0;
+ // TODO if these remain mutually exclusive, we should use an enum + switch
+ if (_Gimmick_DS2_00_Enable_Dynamic) {
+ ds2 = Gimmick_DS2_00(i);
+ } else if (_Gimmick_DS2_01_Enable_Dynamic) {
+ ds2 = Gimmick_DS2_01(i);
+ } else if (_Gimmick_DS2_02_Enable_Dynamic) {
+ ds2 = Gimmick_DS2_02(i);
+ } else if (_Gimmick_DS2_03_Enable_Dynamic) {
+ ds2 = Gimmick_DS2_03(i);
+ }
+ float ds2_mask = _Gimmick_DS2_Mask.SampleLevel(linear_clamp_s, i.uv0, 0);
+ albedo = ds2.albedo * _Gimmick_DS2_Albedo_Factor * ds2_mask;
+ normal = ds2.normal;
+ metallic = ds2.metallic;
+ roughness = ds2.roughness;
+ i.worldPos = ds2.worldPos;
+ {
+ float4 clip_pos = mul(UNITY_MATRIX_VP, float4(ds2.worldPos, 1.0));
+ depth = clip_pos.z / clip_pos.w;
+ }
+#endif
+
float4 lit = getLitColor(vertex_light_color, albedo, i.worldPos, normal,
metallic, 1.0 - roughness, i.uv0, ao, /*enable_direct=*/true,
diffuse_contrib, i, tdata);
@@ -2778,6 +2803,9 @@ float4 effect(inout v2f i, out float depth)
#if defined(_GLITTER)
result.rgb += glitter_color_unlit * _Glitter_Brightness;
#endif
+#if defined(_GIMMICK_DS2)
+ result.rgb += ds2.emission * _Gimmick_DS2_Emission_Factor * ds2_mask;
+#endif
#if defined(_ACES_FILMIC)
result.rgb = aces_filmic(max(result.rgb, 0));