diff options
| author | yum <yum.food.vr@gmail.com> | 2024-10-07 14:41:33 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-10-07 14:41:33 -0700 |
| commit | e51760ab5e6d698b26b60e1811e7afce62be55d0 (patch) | |
| tree | b7bb304f703f47958ce59ebf906f6f5ad6ca4480 | |
| parent | 144d7bc5cc999b9c5f84a9a7fc2a86dafe276df1 (diff) | |
Fix center eye toggle in rim lighting
Also add bayer dithering logic (not used yet).
| -rw-r--r-- | poi.cginc | 23 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 9 |
2 files changed, 28 insertions, 4 deletions
@@ -123,4 +123,27 @@ float3 getPoiLightingIndirect() { return BetterSH9(float4(0, 0, 0, 1)); } +inline half Dither8x8Bayer(int x, int y) +{ + // Premultiplied by 1/64 + const half dither[ 64 ] = { + 0.015625, 0.765625, 0.203125, 0.953125, 0.06250, 0.81250, 0.25000, 1.00000, + 0.515625, 0.265625, 0.703125, 0.453125, 0.56250, 0.31250, 0.75000, 0.50000, + 0.140625, 0.890625, 0.078125, 0.828125, 0.18750, 0.93750, 0.12500, 0.87500, + 0.640625, 0.390625, 0.578125, 0.328125, 0.68750, 0.43750, 0.62500, 0.37500, + 0.046875, 0.796875, 0.234375, 0.984375, 0.03125, 0.78125, 0.21875, 0.96875, + 0.546875, 0.296875, 0.734375, 0.484375, 0.53125, 0.28125, 0.71875, 0.46875, + 0.171875, 0.921875, 0.109375, 0.859375, 0.15625, 0.90625, 0.09375, 0.84375, + 0.671875, 0.421875, 0.609375, 0.359375, 0.65625, 0.40625, 0.59375, 0.34375 + }; + int r = y * 8 + x; + return dither[r]; +} + +half calcDither(half2 grabPos) +{ + return Dither8x8Bayer(glsl_mod(grabPos.x, 8), glsl_mod(grabPos.y, 8)); +} + + #endif // __POI_INC diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index ad42fa9..6d70dbc 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -1276,6 +1276,7 @@ float4 effect(inout v2f i) const float3 view_dir = normalize(_WorldSpaceCameraPos.xyz - i.worldPos); const float3 view_dir_c = normalize(i.centerCamPos - i.worldPos); #define VIEW_DIR(center_eye_fix) (center_eye_fix == 1 ? view_dir_c : view_dir) +#define CAM_POS(center_eye_fix) (center_eye_fix == 1 ? i.centerCamPos : _WorldSpaceCameraPos.xyz) // Not necessarily normalized after interpolation. i.normal = normalize(i.normal); @@ -1740,7 +1741,7 @@ float4 effect(inout v2f i) #if defined(_RIM_LIGHTING0_GLITTER) float rl_glitter = get_glitter( get_uv_by_channel(i, round(_Rim_Lighting0_Glitter_UV_Select)), - i.worldPos, i.centerCamPos, normal, + i.worldPos, CAM_POS(_Rim_Lighting0_Center_Eye_Fix), normal, _Rim_Lighting0_Glitter_Density, _Rim_Lighting0_Glitter_Amount, _Rim_Lighting0_Glitter_Speed, /*mask=*/1, /*angle=*/91, /*power=*/1); @@ -1831,7 +1832,7 @@ float4 effect(inout v2f i) #if defined(_RIM_LIGHTING1_GLITTER) float rl_glitter = get_glitter( get_uv_by_channel(i, round(_Rim_Lighting1_Glitter_UV_Select)), - i.worldPos, i.centerCamPos, normal, + i.worldPos, CAM_POS(_Rim_Lighting1_Center_Eye_Fix), normal, _Rim_Lighting1_Glitter_Density, _Rim_Lighting1_Glitter_Amount, _Rim_Lighting1_Glitter_Speed, /*mask=*/1, /*angle=*/91, /*power=*/1); @@ -1922,7 +1923,7 @@ float4 effect(inout v2f i) #if defined(_RIM_LIGHTING2_GLITTER) float rl_glitter = get_glitter( get_uv_by_channel(i, round(_Rim_Lighting2_Glitter_UV_Select)), - i.worldPos, i.centerCamPos, normal, + i.worldPos, CAM_POS(_Rim_Lighting2_Center_Eye_Fix), normal, _Rim_Lighting2_Glitter_Density, _Rim_Lighting2_Glitter_Amount, _Rim_Lighting2_Glitter_Speed, /*mask=*/1, /*angle=*/91, /*power=*/1); @@ -2014,7 +2015,7 @@ float4 effect(inout v2f i) #if defined(_RIM_LIGHTING3_GLITTER) float rl_glitter = get_glitter( get_uv_by_channel(i, round(_Rim_Lighting3_Glitter_UV_Select)), - i.worldPos, i.centerCamPos, normal, + i.worldPos, CAM_POS(_Rim_Lighting3_Center_Eye_Fix), normal, _Rim_Lighting3_Glitter_Density, _Rim_Lighting3_Glitter_Amount, _Rim_Lighting3_Glitter_Speed, /*mask=*/1, /*angle=*/91, /*power=*/1); |
