more efficient depth mipmaping

We simply pick one of the 4 depth texel based on its screen
space offset. Literature showed it doesn't impact AO
significantly.
This commit is contained in:
Mathias Agopian
2019-05-29 13:25:45 -07:00
committed by Mathias Agopian
parent 0f23633809
commit e4c6dcf3bc

View File

@@ -24,23 +24,8 @@ material {
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
int level = materialParams.level;
ivec2 xy = ivec2(gl_FragCoord.xy) * 2;
highp float d00 = texelFetch(materialParams_depth, xy + ivec2(0, 0), level).r;
highp float d10 = texelFetch(materialParams_depth, xy + ivec2(1, 0), level).r;
highp float d01 = texelFetch(materialParams_depth, xy + ivec2(0, 1), level).r;
highp float d11 = texelFetch(materialParams_depth, xy + ivec2(1, 1), level).r;
gl_FragDepth =
// conservative occlusion
//max(d00, max(d01, max(d10, d11)));
// conservative visibility
//min(d00, min(d01, min(d10, d11)));
// arithmetic mean: preserve screen-space area
(d00 + d01 + d10 + d11) * 0.25;
gl_FragDepth = texelFetch(materialParams_depth, xy + ivec2(xy.x & 1, xy.y & 1), level).r;
}
}