summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-12-27 14:18:41 -0800
committeryum <yum.food.vr@gmail.com>2024-12-27 14:18:41 -0800
commit2743c9640efcf79843b9c985e0b48dd4403fb804 (patch)
tree5ffba6f52d57e13fc002f6ea347eb4af5c0ec2f4
parent4f78fa07364d921d3dca811442cdf05e6a384370 (diff)
More LTCGI cleanup
Debugging why shadowmap LTCGI emissions don't show up. This patch makes the shader match the appearance of the LTCGI surface shaders much more closely.
-rw-r--r--Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc26
-rw-r--r--pbr.cginc36
-rw-r--r--tooner.shader5
-rw-r--r--tooner_lighting.cginc5
4 files changed, 37 insertions, 35 deletions
diff --git a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
index 6b2c99a..1ddb38a 100644
--- a/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
+++ b/Third_Party/at.pimaker.ltcgi/Shaders/LTCGI_config.cginc
@@ -20,9 +20,8 @@
/// a bit more with global screen color data. Slight performance cost.
//#define LTCGI_BLENDED_DIFFUSE_SAMPLING
-/// Slightly simplified and thus faster sampling for reflections at the cost of quality.
-/// Consider using this if your scene looks about the same with this enabled.
-//#define LTCGI_FAST_SAMPLING
+/// Disable extra specular detail LUT, saves a sampler.
+//#define LTCGI_DISABLE_LUT2
/// Use bicubic filtering for LTCGI lightmap. Recommended on.
#define LTCGI_BICUBIC_LIGHTMAP
@@ -50,12 +49,7 @@
///
-// Allow statically textured lights.
-// (deprecated: doesn't really cause any improvement when disabled...)
-#define LTCGI_STATIC_TEXTURES
-
-
-// keep in sync with LTCGI_Controller.cs
+// automatically kept in sync with LTCGI_Controller.cs
#define MAX_SOURCES 16
// set according to the LUT specified on CONTROLLER
@@ -63,13 +57,13 @@
static float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;
const float LUT_BIAS = 0.5/LUT_SIZE;
-// will be set automatically if audiolink is available
+// will be set automatically if audiolink is available and in use
//#define LTCGI_AUDIOLINK
#ifdef LTCGI_AUDIOLINK
#ifndef AUDIOLINK_WIDTH
#ifndef AUDIOLINK_CGINC_INCLUDED
-#include "Packages/com.llealloo.audiolink/Runtime/Shaders/AudioLink.cginc"
+#include "Packages/at.pimaker.ltcgi/Shaders/LTCGI_AudioLinkNoOp.cginc"
#define AUDIOLINK_CGINC_INCLUDED
#endif
#endif
@@ -78,10 +72,16 @@ const float LUT_BIAS = 0.5/LUT_SIZE;
// Bake screen data into texture for better performance. Disables moveable screens.
#define LTCGI_STATIC_UNIFORMS
+// Allow statically textured lights.
+//#define LTCGI_STATIC_TEXTURES
+
// Enable support for cylindrical screens.
-#define LTCGI_CYLINDER
+//#define LTCGI_CYLINDER
// Activate avatar mode, which overrides certain configs from above.
-#define LTCGI_AVATAR_MODE
+//#define LTCGI_AVATAR_MODE
+
+// Slightly simplified and thus faster sampling for reflections at the cost of quality.
+//#define LTCGI_FAST_SAMPLING
#endif
diff --git a/pbr.cginc b/pbr.cginc
index 0095654..8dda05d 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -254,12 +254,13 @@ float4 getLitColor(
normal,
view_dir,
GetRoughness(smoothness),
- 0);
+ i.uv2);
indirect_light.diffuse += acc.diffuse;
indirect_light.specular += acc.specular;
}
#endif
+#if defined(_BRIGHTNESS_CLAMP) || defined(_PROXIMITY_DIMMING)
direct_light.color = RGBtoHSV(direct_light.color);
indirect_light.specular = RGBtoHSV(indirect_light.specular);
indirect_light.diffuse = RGBtoHSV(indirect_light.diffuse);
@@ -275,17 +276,19 @@ float4 getLitColor(
indirect_light.diffuse[2]);
// Do this to avoid division by 0. If both light sources are black,
// sum_brightness could be 0;
+ const float min_brightness = max(_Min_Brightness, 1E-6);
#if defined(_BRIGHTNESS_CLAMP)
//brightnesses = smooth_max(brightnesses, _Min_Brightness);
- brightnesses = max(brightnesses, _Min_Brightness);
-#endif
- float sum_brightness = brightnesses[0] + brightnesses[1];
+ brightnesses = max(brightnesses, min_brightness);
+
+ float sum_brightness = max(brightnesses[0] + brightnesses[1], min_brightness);
float2 brightness_proportions = brightnesses / sum_brightness;
-#if defined(_BRIGHTNESS_CLAMP)
- sum_brightness = smooth_clamp(sum_brightness, _Min_Brightness, _Max_Brightness);
-#endif
+
+ sum_brightness = smooth_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];
+#endif
#if defined(_PROXIMITY_DIMMING)
{
@@ -304,20 +307,19 @@ float4 getLitColor(
}
#endif
- direct_light.color[2] *= _Lighting_Factor * _Direct_Lighting_Factor * enable_direct;
- indirect_light.specular[2] *= _Lighting_Factor *
- _Indirect_Specular_Lighting_Factor *
- _Indirect_Specular_Lighting_Factor2;
- indirect_light.diffuse[2] *= _Lighting_Factor * _Indirect_Diffuse_Lighting_Factor;
-
// 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] = smooth_clamp(indirect_light.specular[2], min_brightness, _Max_Brightness);
#endif
direct_light.color = HSVtoRGB(direct_light.color);
indirect_light.specular = HSVtoRGB(indirect_light.specular);
indirect_light.diffuse = HSVtoRGB(indirect_light.diffuse);
+#endif
+ // _BRIGHTNESS_CLAMP || _PROXIMITY_DIMMING
+ direct_light.color *= _Lighting_Factor * _Direct_Lighting_Factor * enable_direct;
+ indirect_light.specular *= _Lighting_Factor * _Indirect_Specular_Lighting_Factor * _Indirect_Specular_Lighting_Factor2;
+ indirect_light.diffuse *= _Lighting_Factor * _Indirect_Diffuse_Lighting_Factor;
// Apply AO
indirect_light.diffuse *= ao;
@@ -389,15 +391,15 @@ float4 getLitColor(
normal,
view_dir,
1.0 - smoothness,
- 0);
+ i.uv2);
pbr.rgb += acc.diffuse * pbr.rgb + acc.specular;
}
#endif
// TODO formalize with parameters
// Break up color banding by adding some dithering to shaded color.
- float screen_dither = ign(tdata.screen_uv_round) * .00390625;
- pbr += screen_dither;
+ //float screen_dither = ign(tdata.screen_uv_round) * .00390625;
+ //pbr += screen_dither;
#if defined(_CLEARCOAT)
// Direct lighting
diff --git a/tooner.shader b/tooner.shader
index 275cce9..025e7b1 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -1001,8 +1001,8 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
- #pragma multi_compile_instancing
+ #pragma multi_compile_instancing
#pragma multi_compile_fwdbase
#pragma multi_compile_fog
#pragma multi_compile _ VERTEXLIGHT_ON
@@ -1037,9 +1037,10 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
- #pragma multi_compile_instancing
+ #pragma multi_compile_instancing
#pragma multi_compile_fwdadd_fullshadows
+
#include "feature_macros.cginc"
#pragma vertex vert
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index e5bcd13..7224152 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -583,9 +583,8 @@ float get_glitter(float2 uv, float3 worldPos, float3 centerCamPos,
}
#endif // _GLITTER
-float3 CreateBinormal (float3 normal, float3 tangent, float binormalSign) {
- return cross(normal, tangent.xyz) *
- (binormalSign * unity_WorldTransformParams.w);
+float3 CreateBinormal(float3 normal, float3 tangent, float binormalSign) {
+ return cross(normal, tangent) * (binormalSign * unity_WorldTransformParams.w);
}
float2 matcap_distortion0(float2 matcap_uv) {