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

Support GL face culling #12725

Merged
merged 3 commits into from
Sep 13, 2018
Merged

Support GL face culling #12725

merged 3 commits into from
Sep 13, 2018

Conversation

brunoabinader
Copy link
Member

@brunoabinader brunoabinader commented Aug 23, 2018

This is a common OpenGL optimization technique that skips rendering e.g. back-facing triangles. For that, we need to apply a common winding order (either clockwise or counter-clockwise) when ordering the triangle vertices we use when drawing.

When enabling face culling, GL culls back-facing triangles and assumes front-facing triangles being ones ordered counter-clockwise by default. This required some changes in our winding order when populating our buckets.

We enable face culling by default. We apply counter-clockwise winding order for culling back-facing triangles when rendering in the main buffer, and clockwise winding order for culling front-facing triangles when rendering offscreen (heatmaps, hillshade and fill extrusions). We disable face culling when rendering custom layers.

Depends on mapbox/mapbox-gl-js#7178.

@brunoabinader brunoabinader added GL JS parity For feature parity with Mapbox GL JS performance Speed, stability, CPU usage, memory usage, or power usage Core The cross-platform C++ core, aka mbgl labels Aug 23, 2018
@brunoabinader brunoabinader self-assigned this Aug 23, 2018
@brunoabinader brunoabinader force-pushed the gl-face-culling branch 2 times, most recently from 4d72bf3 to 0af0bff Compare August 23, 2018 09:15
@brunoabinader brunoabinader force-pushed the gl-face-culling branch 5 times, most recently from 8241202 to b9f97d9 Compare August 24, 2018 08:57
@brunoabinader
Copy link
Member Author

CI failures are caused due to recent unrelated GL JS changes - will solve those once mapbox/mapbox-gl-js#7178 is merged.

@brunoabinader
Copy link
Member Author

Mapbox GL JS benchmark results for reference: mapbox/mapbox-gl-js#7178 (comment)

@brunoabinader brunoabinader force-pushed the gl-face-culling branch 2 times, most recently from 9b43af8 to a8441b3 Compare August 30, 2018 13:04
@brunoabinader brunoabinader force-pushed the gl-face-culling branch 2 times, most recently from 65bc3b4 to 1072d4c Compare August 30, 2018 22:26
@brunoabinader
Copy link
Member Author

Same as last week (#12725 (comment)), recent GL JS changes are causing CI to fail.

@mollymerp
Copy link
Contributor

@brunoabinader sorry about that! hoping to merge #12284 asap and that should resolve failures.

@brunoabinader
Copy link
Member Author

Thank you @mollymerp 🙇‍♂️ @nagineni is going to push this forward while I'm on vacations.

@anderco anderco self-assigned this Sep 7, 2018
@anderco
Copy link
Contributor

anderco commented Sep 10, 2018

I started to implement the same feedback given to the JS version to this PR. See https://github.com/mapbox/mapbox-gl-native/tree/anderco-face-culling

Add a parameter to Program::draw to control whether face culling should
be enabled. This will be used in a follow up commit to enable face
culling for fill extrusion layers.
Use face culling for fill extrusion layers. Winding order is changed to
ensure correct rendering.
Custom layers are not implemented in node platform so ignore tests that
require it.
@anderco
Copy link
Contributor

anderco commented Sep 12, 2018

I updated this PR to match what was done in mapbox/mapbox-gl-js#7178, so face culling is only enabled for fill extrusion layers by adding a face culling mode parameter to Program::draw().

/cc @ansis

Copy link
Contributor

@ansis ansis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks!

@anderco anderco merged commit 6367fcb into master Sep 13, 2018
@tmpsantos tmpsantos deleted the gl-face-culling branch October 26, 2018 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl GL JS parity For feature parity with Mapbox GL JS performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants