Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Enable face culling for fill extrusion layers
Browse files Browse the repository at this point in the history
Use face culling for fill extrusion layers. Winding order is changed to
ensure correct rendering.
  • Loading branch information
brunoabinader authored and anderco committed Sep 13, 2018
1 parent 05a7b78 commit 5b1925d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
vertices.emplace_back(
FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, edgeDistance));

triangles.emplace_back(triangleIndex, triangleIndex + 1, triangleIndex + 2);
// ┌──────┐
// │ 0 1 │ Counter-Clockwise winding order.
// │ │ Triangle 1: 0 => 2 => 1
// │ 2 3 │ Triangle 2: 1 => 2 => 3
// └──────┘
triangles.emplace_back(triangleIndex, triangleIndex + 2, triangleIndex + 1);
triangles.emplace_back(triangleIndex + 1, triangleIndex + 2, triangleIndex + 3);
triangleIndex += 4;
triangleSegment.vertexLength += 4;
Expand All @@ -141,8 +146,9 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
assert(nIndices % 3 == 0);

for (uint32_t i = 0; i < nIndices; i += 3) {
triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 1]],
flatIndices[indices[i + 2]]);
// Counter-Clockwise winding order.
triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 2]],
flatIndices[indices[i + 1]]);
}

triangleSegment.vertexLength += totalVertices;
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
parameters.depthModeFor3D(gl::DepthMode::ReadWrite),
gl::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gl::CullFaceMode::disabled(),
gl::CullFaceMode::backCCW(),
*tileBucket.indexBuffer,
tileBucket.triangleSegments,
allUniformValues,
Expand Down

0 comments on commit 5b1925d

Please sign in to comment.