diff options
| author | yum <yum.food.vr@gmail.com> | 2024-12-27 14:18:41 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-12-27 14:18:41 -0800 |
| commit | 2743c9640efcf79843b9c985e0b48dd4403fb804 (patch) | |
| tree | 5ffba6f52d57e13fc002f6ea347eb4af5c0ec2f4 /pbr.cginc | |
| parent | 4f78fa07364d921d3dca811442cdf05e6a384370 (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.
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -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 |
