Skip to content

Commit 7e117b5

Browse files
committed
Remove unused depth tile calculations
The depth tile shaders calculated average and variance of the depth of the pixels in the tile, storing these in the green and alpha channels. Do not calculate these since they are not used.
1 parent 2020fd4 commit 7e117b5

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

src/engine/renderer/glsl_source/depthtile1_fp.glsl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,9 @@ void main()
115115

116116
float maxDepth = max16( depth[0], depth[1], depth[2], depth[3] );
117117

118-
float avgDepth = dot( depth[0] + depth[1] + depth[2] + depth[3],
119-
vec4( samples ) );
120-
121-
depth[0] -= avgDepth * mask[0];
122-
depth[1] -= avgDepth * mask[1];
123-
depth[2] -= avgDepth * mask[2];
124-
depth[3] -= avgDepth * mask[3];
125-
126-
float variance = dot( depth[0], depth[0] ) + dot( depth[1], depth[1] ) +
127-
dot( depth[2], depth[2] ) + dot( depth[3], depth[3] );
128-
variance *= samples;
129-
outputColor = vec4( maxDepth, minDepth, avgDepth, sqrt( variance ) );
118+
outputColor = vec4( maxDepth, minDepth, 0.0, 0.0 );
130119
} else {
131120
// found just sky pixels
132-
outputColor = vec4( 99999.0, 99999.0, 99999.0, 0.0 );
121+
outputColor = vec4( 99999.0, 99999.0, 0.0, 0.0 );
133122
}
134123
}

src/engine/renderer/glsl_source/depthtile2_fp.glsl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,16 @@ void main()
4747
vec2 st = gl_FragCoord.st * r_tileStep;
4848
float x, y;
4949
vec4 accum = vec4( 0.0, 99999.0, 0.0, 0.0 );
50-
float count = 0.0;
5150

5251
for( x = -0.375; x < 0.5; x += 0.25 ) {
5352
for( y = -0.375; y < 0.5; y += 0.25 ) {
5453
vec4 data = texture2D( u_DepthTile1, st + vec2(x, y) * r_tileStep );
5554
if( data.y < 99999.0 ) {
5655
accum.x = max( accum.x, data.x );
5756
accum.y = min( accum.y, data.y );
58-
accum.zw += data.zw;
59-
count += 1.0;
6057
}
6158
}
6259
}
6360

64-
if( count >= 1.0 ) {
65-
accum.zw *= 1.0 / count;
66-
}
67-
6861
outputColor = accum;
6962
}

src/engine/renderer/tr_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@ static void R_CreateDepthRenderImage()
25882588
imageParams.wrapType = wrapTypeEnum_t::WT_ONE_CLAMP;
25892589

25902590
imageParams.bits = IF_NOPICMIP;
2591-
imageParams.bits |= r_highPrecisionRendering.Get() ? IF_RGBA32F : IF_RGBA16F;
2591+
imageParams.bits |= r_highPrecisionRendering.Get() ? IF_TWOCOMP32F : IF_TWOCOMP16F;
25922592

25932593
tr.depthtile1RenderImage = R_CreateImage( "_depthtile1Render", nullptr, w, h, 1, imageParams );
25942594

0 commit comments

Comments
 (0)