diff options
| author | yum <yum.food.vr@gmail.com> | 2024-11-03 15:23:21 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-11-03 15:23:21 -0800 |
| commit | cb55e813456480a036673d1d32608e10b10c8f87 (patch) | |
| tree | d54c125b2fd01403fec0b4f26d470ffbbeff2468 /pbr.cginc | |
| parent | 9cc586ddce424f619a2a1fba192c5f3e4c01a29d (diff) | |
Lots of tweaks
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -347,21 +347,6 @@ float4 getLitColor( screenPos = float4(i.screenPos, 0, i.pos.w); #endif -// TODO optimize this -// Break up color banding by adding some dithering to direct light. -{ - float2 screen_uv; - { - float3 full_vec_eye_to_geometry = i.worldPos - _WorldSpaceCameraPos; - float3 world_dir = normalize(i.worldPos - _WorldSpaceCameraPos); - float perspective_divide = 1.0 / i.pos.w; - float perspective_factor = length(full_vec_eye_to_geometry * perspective_divide); - screen_uv = i.screenPos.xy * perspective_divide; - } - uint2 screen_uv_round = floor(screen_uv * _ScreenParams.xy); - direct_light.color += ign(screen_uv_round) * 0.00390625; -} - #if 1 float reflection_strength = _ReflectionStrength; #if defined(_REFLECTION_STRENGTH_TEX) @@ -404,6 +389,23 @@ float4 getLitColor( indirect_light).xyz; #endif + // TODO optimize this and formalize with parameters + // Break up color banding by adding some dithering to shaded color. + float screen_dither; + { + float2 screen_uv; + { + float3 full_vec_eye_to_geometry = i.worldPos - _WorldSpaceCameraPos; + float3 world_dir = normalize(i.worldPos - _WorldSpaceCameraPos); + float perspective_divide = 1.0 / i.pos.w; + float perspective_factor = length(full_vec_eye_to_geometry * perspective_divide); + screen_uv = i.screenPos.xy * perspective_divide; + } + uint2 screen_uv_round = floor(screen_uv * _ScreenParams.xy); + screen_dither = ign(screen_uv_round) * 0.00390625; + } + pbr += screen_dither; + #if defined(_CLEARCOAT) // Direct lighting // TODO add keywords to optimize away mask samples when not used |
