summaryrefslogtreecommitdiffstats
path: root/tooner_lighting.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-01-21 19:58:34 -0800
committeryum <yum.food.vr@gmail.com>2025-01-21 19:58:34 -0800
commit4ec13bd7513f29e16ab22b7ffe7d06724c92a912 (patch)
treee82920d170455fbfade69f7487ae5f6f4d0c1dd0 /tooner_lighting.cginc
parente2911359e5acf79beb5c8359145669b96a931ab0 (diff)
Clearcoat can disable texture normals
Also: * terrain gimmick * makes some hardcoded shit into params * add alternative normal evaluation methods * stochastic method gives best results without getting into analytic normals * add FBM noise texture slot to improve perf * add initial raytrace to sphere * stabilizes appearance as camera moves * add backtracking * eliminates sharp lines without sacrificing perf * fog 00 can render on a plane now, in addition to cylinder * add epilepsy protection filter
Diffstat (limited to 'tooner_lighting.cginc')
-rw-r--r--tooner_lighting.cginc94
1 files changed, 61 insertions, 33 deletions
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index a0a5777..0a2139c 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -959,6 +959,28 @@ float4 pixellate_color(int2 px_res, float2 uv, float4 c)
}
#endif
+#if defined(_GIMMICK_EPILEPSY_MODE)
+float4 map_color_epilepsy(float4 color) {
+ [branch]
+ if (_Gimmick_Epilepsy_Mode_Enable_Dynamic) {
+ color.rgb = saturate(color.rgb);
+
+ color.rgb = LRGBtoOKLCH(color.rgb);
+ color.rgb[0] = dmin(color.rgb[0], _Gimmick_Epilepsy_Mode_Luminance_Cutoff, _Gimmick_Epilepsy_Mode_Rolloff_Power);
+ color.rgb = OKLCHtoLRGB(color.rgb);
+
+ color.rgb = RGBtoHSV(color.rgb);
+ color.rgb[1] = dmin(color.rgb[1], _Gimmick_Epilepsy_Mode_Saturation_Cutoff, _Gimmick_Epilepsy_Mode_Rolloff_Power);
+ color.rgb = HSVtoRGB(color.rgb);
+ }
+
+ return color;
+}
+#define FILTER_COLOR(color) map_color_epilepsy(color)
+#else
+#define FILTER_COLOR(color) color
+#endif
+
float4 effect(inout v2f i, out float depth)
{
ToonerData tdata;
@@ -2130,38 +2152,6 @@ float4 effect(inout v2f i, out float depth)
float ao = 1;
#endif
- float3 diffuse_contrib = 0;
-#if defined(_GIMMICK_FOG_00)
- {
- Fog00PBR pbr = getFog00(i, tdata);
- albedo = pbr.albedo;
- depth = pbr.depth;
-#if defined(_RENDERING_TRANSPARENT) || defined(_RENDERING_TRANSCLIPPING)
- albedo.rgb *= albedo.a;
-#endif
- return albedo;
- }
-#endif
-#if defined(_GIMMICK_FOG_01)
- if (!round(_Gimmick_Fog_01_Overlay_Mode)) {
- Fog01PBR fog_01_pbr = getFog01(i, tdata);
- albedo = fog_01_pbr.albedo;
- depth = fog_01_pbr.depth;
-#if defined(_RENDERING_TRANSPARENT) || defined(_RENDERING_TRANSCLIPPING)
- albedo.rgb *= albedo.a;
-#endif
- return albedo;
- }
-#endif
-#if defined(_GIMMICK_AURORA)
- {
- AuroraPBR pbr = getAurora(i);
- albedo = pbr.albedo;
- depth = pbr.depth;
- diffuse_contrib += pbr.diffuse;
- }
-#endif
-
#if defined(_GIMMICK_FLAT_COLOR)
if (round(_Gimmick_Flat_Color_Enable_Dynamic)) {
albedo = _Gimmick_Flat_Color_Color;
@@ -2223,10 +2213,48 @@ float4 effect(inout v2f i, out float depth)
}
#endif
+ float3 diffuse_contrib = 0;
+#if defined(_GIMMICK_FOG_01)
+ if (!round(_Gimmick_Fog_01_Overlay_Mode)) {
+ Fog01PBR fog_01_pbr = getFog01(i, tdata);
+ albedo = fog_01_pbr.albedo;
+ depth = fog_01_pbr.depth;
+#if defined(_RENDERING_TRANSPARENT) || defined(_RENDERING_TRANSCLIPPING)
+ albedo.rgb *= albedo.a;
+#endif
+ return albedo;
+ }
+#endif
+#if defined(_GIMMICK_AURORA)
+ {
+ AuroraPBR pbr = getAurora(i);
+ albedo = pbr.albedo;
+ depth = pbr.depth;
+ diffuse_contrib += pbr.diffuse;
+ }
+#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);
+#if defined(_GIMMICK_FOG_00)
+ {
+ if (round(_Gimmick_Fog_00_Overlay_Mode)) {
+ Fog00PBR pbr = __getFog00(i, tdata, mul(unity_WorldToObject, float4(i.worldPos, 1.0)).xyz, tdata.screen_uv);
+ lit = pbr.albedo + lit * (1 - pbr.albedo.a);
+ } else {
+ Fog00PBR pbr = getFog00(i, tdata);
+ albedo = pbr.albedo;
+ depth = pbr.depth;
+#if defined(_RENDERING_TRANSPARENT) || defined(_RENDERING_TRANSCLIPPING)
+ albedo.rgb *= albedo.a;
+#endif
+ return albedo;
+ }
+ }
+#endif
+
#if defined(_GIMMICK_FLAT_COLOR)
if (round(_Gimmick_Flat_Color_Enable_Dynamic)) {
#if defined(_RENDERING_CUTOUT)
@@ -2353,7 +2381,7 @@ fixed4 frag(v2f i
#endif
*/
- return effect(i, depth);
+ return FILTER_COLOR(effect(i, depth));
}
#endif // TOONER_LIGHTING