Skip to content

Commit 4246b76

Browse files
authored
FIx shadow banding on cockpits (scp-fs2open#7495)
1 parent 05534f7 commit 4246b76

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

code/def_files/data/effects/z-compress.sdr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ float compress_depth_value(float linear) {
66
linear = max(-linear, 0.0);
77

88
if(linear < 10.0) {
9-
linear_mult = 0.00000999908;
10-
exponent_mult = 1.32878452580;
11-
offset = 0.0;
9+
//Special handling for very close values. For smooth shadows at very close distances, equidistant steps get too inaccurate.
10+
//Scaling this down linearly will push more accuracy to closer distances. Due to the scaling, this does not lose accuracy
11+
//at any point over the worse of uncompressed / z-compress, but it does trade the gained accuracy from compression at 10m
12+
//distance for accuracy lost due to compression below 0.5m (roughly)
13+
return linear * 0.01;
1214
}
1315
else if (linear < 100.0) {
1416
linear_mult = 0.05550473078;
@@ -70,9 +72,7 @@ float uncompress_depth_value(float compressed) {
7072
offset = 3000.0;
7173
}
7274
else if (compressed < 0.1) {
73-
linear_mult = 0.00000999908;
74-
exponent_mult = 1.32878452580;
75-
offset = 0.0;
75+
return compressed * -100.0;
7676
}
7777
else if (compressed < 20.0) {
7878
linear_mult = 0.05550473078;

0 commit comments

Comments
 (0)