summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/paint_parameters.cpp
diff options
context:
space:
mode:
authorAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-07-07 13:40:22 +0300
committerAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-07-09 15:13:38 +0200
commit2c5528e691b502673b16723205c83add62317734 (patch)
treed4e27fecc8b867a5472e5392f52953f38c9327d7 /src/mbgl/renderer/paint_parameters.cpp
parent929824ecc3176c01a5f3e74d80e2ae2ba2cf1e51 (diff)
downloadqtlocation-mapboxgl-2c5528e691b502673b16723205c83add62317734.tar.gz
Fix layers rendering after fill-extrusion
This fixes following issues: * Fix some false passing combinations/fill-extrusion-translucent--XXXX tests * Fix and enable other, failing but ignored, combinations/fill-extrusion-translucent--XXXX tests * Fix rendering of layers that are on top of fill-extrusion layers state.getProjMatrix(nearClippedProjMatrix, 100) caused that tests with size 64x64 were not rendering fill extrusions: far plane calculated as 96.9 and near plane set to 100 was the cause. near plane is changed from hardcoded 100 to depend on state.getCameraToCenterDistance() - producing similar value but one that follows max zoom. This caused that e.g. combinations/fill-extrusion-translucent--fill-opaque was falsely passing as only fill-opaque layer got rendered. combinations/fill-extrusion-translucent--XXXX tests expose regression https://github.com/mapbox/mapbox-gl-native/issues/14844#issuecomment-503600034 in #14844, #14779. Fix (opaquePassCutoff, is3D) is ported from https://github.com/mapbox/mapbox-gl-js/pull/7821 Fixes: #14844, #14779, #15039
Diffstat (limited to 'src/mbgl/renderer/paint_parameters.cpp')
-rw-r--r--src/mbgl/renderer/paint_parameters.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp
index 1539c0fbcb..6c6abc008b 100644
--- a/src/mbgl/renderer/paint_parameters.cpp
+++ b/src/mbgl/renderer/paint_parameters.cpp
@@ -19,10 +19,11 @@ TransformParameters::TransformParameters(const TransformState& state_)
// odd viewport sizes.
state.getProjMatrix(alignedProjMatrix, 1, true);
- // Calculate a second projection matrix with the near plane clipped to 100 so as
- // not to waste lots of depth buffer precision on very close empty space, for layer
- // types (fill-extrusion) that use the depth buffer to emulate real-world space.
- state.getProjMatrix(nearClippedProjMatrix, 100);
+ // Calculate a second projection matrix with the near plane moved further,
+ // to a tenth of the far value, so as not to waste depth buffer precision on
+ // very close empty space, for layer types (fill-extrusion) that use the
+ // depth buffer to emulate real-world space.
+ state.getProjMatrix(nearClippedProjMatrix, 0.1 * state.getCameraToCenterDistance());
}
PaintParameters::PaintParameters(gfx::Context& context_,
@@ -72,6 +73,9 @@ mat4 PaintParameters::matrixForTile(const UnwrappedTileID& tileID, bool aligned)
}
gfx::DepthMode PaintParameters::depthModeForSublayer(uint8_t n, gfx::DepthMaskType mask) const {
+ if (currentLayer < opaquePassCutoff) {
+ return gfx::DepthMode::disabled();
+ }
float depth = depthRangeSize + ((1 + currentLayer) * numSublayers + n) * depthEpsilon;
return gfx::DepthMode { gfx::DepthFunctionType::LessEqual, mask, { depth, depth } };
}