[core] Update circle shader code
Ported the following patches: - [convert mat4 exMatrix to a vec2 extrudeScale](a8d549b7a4) - [Enabled data-driven styling for circle-radius](4356e41fa6) - [Reduce shader boilerplate, refactor "Bucket"](7d3da8f191)
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
"devDependencies": {
|
||||
"aws-sdk": "^2.3.5",
|
||||
"express": "^4.11.1",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#4a567b438be303fbbf13e5ddf49d72d8debd811d",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#13aad76282c1b6c4d38fd46f373325dfec69ab01",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#b3441d9a285ffbe9b876677acb13d7df07e5b975",
|
||||
"node-gyp": "^3.3.1",
|
||||
"request": "^2.72.0",
|
||||
|
||||
@@ -100,6 +100,8 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a
|
||||
// The extrusion matrix.
|
||||
matrix::ortho(extrudeMatrix, 0, state.getWidth(), state.getHeight(), 0, 0, -1);
|
||||
|
||||
extrudeScale = {{ (2.0f / state.getWidth()) * state.getAltitude(), -2.0f / state.getHeight() * state.getAltitude() }};
|
||||
|
||||
// The native matrix is a 1:1 matrix that paints the coordinates at the
|
||||
// same screen position as the vertex specifies.
|
||||
matrix::identity(nativeMatrix);
|
||||
|
||||
@@ -158,6 +158,8 @@ private:
|
||||
mat4 nativeMatrix;
|
||||
mat4 extrudeMatrix;
|
||||
|
||||
std::array<float, 2> extrudeScale;
|
||||
|
||||
// used to composite images and flips the geometry upside down
|
||||
const mat4 flipMatrix = []{
|
||||
mat4 flip;
|
||||
|
||||
@@ -33,11 +33,12 @@ void Painter::renderCircle(CircleBucket& bucket,
|
||||
config.program = circleShader->getID();
|
||||
|
||||
circleShader->u_matrix = vtxMatrix;
|
||||
circleShader->u_exmatrix = extrudeMatrix;
|
||||
circleShader->u_extrude_scale = extrudeScale;
|
||||
circleShader->u_devicepixelratio = frame.pixelRatio;
|
||||
circleShader->u_color = properties.circleColor;
|
||||
circleShader->u_opacity = properties.circleOpacity;
|
||||
circleShader->u_radius = properties.circleRadius;
|
||||
circleShader->u_blur = std::max<float>(properties.circleBlur, antialiasing);
|
||||
circleShader->u_size = properties.circleRadius;
|
||||
circleShader->u_opacity = properties.circleOpacity;
|
||||
|
||||
bucket.drawCircles(*circleShader, glObjectStore);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,13 @@ public:
|
||||
|
||||
void bind(GLbyte *offset) final;
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
UniformMatrix<4> u_exmatrix = {"u_exmatrix", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
Uniform<GLfloat> u_size = {"u_size", *this};
|
||||
Uniform<GLfloat> u_blur = {"u_blur", *this};
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<GLfloat, 2>> u_extrude_scale = {"u_extrude_scale", *this};
|
||||
Uniform<GLfloat> u_devicepixelratio = {"u_devicepixelratio", *this};
|
||||
Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
|
||||
Uniform<GLfloat> u_radius = {"u_radius", *this};
|
||||
Uniform<GLfloat> u_blur = {"u_blur", *this};
|
||||
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user