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

Commit

Permalink
[core] Fix: fill-extrusion-vertical-gradient was ignored. #14784
Browse files Browse the repository at this point in the history
fill-extrusion-vertical-gradient "property-type": "data-constant" and it shouldn't be computed through property binders.

Fixes: #14784
  • Loading branch information
astojilj committed May 31, 2019
1 parent 0181ef8 commit 62f6338
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/mbgl/programs/fill_extrusion_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ float lightIntensity(const EvaluatedLight& light) {
}

FillExtrusionProgram::LayoutUniformValues FillExtrusionProgram::layoutUniformValues(
mat4 matrix, const TransformState& state, const float opacity, const EvaluatedLight& light) {
mat4 matrix, const TransformState& state, const float opacity, const EvaluatedLight& light, const float verticalGradient) {
return {
uniforms::matrix::Value( matrix ),
uniforms::opacity::Value( opacity ),
uniforms::lightcolor::Value( lightColor(light) ),
uniforms::lightpos::Value( lightPosition(light, state) ),
uniforms::lightintensity::Value( lightIntensity(light) )
uniforms::lightintensity::Value( lightIntensity(light) ),
uniforms::vertical_gradient::Value( verticalGradient )
};
}

Expand All @@ -51,7 +52,8 @@ FillExtrusionPatternProgram::layoutUniformValues(mat4 matrix,
const float opacity,
const float heightFactor,
const float pixelRatio,
const EvaluatedLight& light) {
const EvaluatedLight& light,
const float verticalGradient) {
const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, state.getIntegerZoom());
int32_t tileSizeAtNearestZoom = util::tileSize * state.zoomScale(state.getIntegerZoom() - tileID.canonical.z);
int32_t pixelX = tileSizeAtNearestZoom * (tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z));
Expand All @@ -69,6 +71,7 @@ FillExtrusionPatternProgram::layoutUniformValues(mat4 matrix,
uniforms::lightcolor::Value( lightColor(light) ),
uniforms::lightpos::Value( lightPosition(light, state) ),
uniforms::lightintensity::Value( lightIntensity(light) ),
uniforms::vertical_gradient::Value( verticalGradient )
};
}

Expand Down
12 changes: 8 additions & 4 deletions src/mbgl/programs/fill_extrusion_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace uniforms {
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightpos);
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightcolor);
MBGL_DEFINE_UNIFORM_SCALAR(float, lightintensity);
MBGL_DEFINE_UNIFORM_SCALAR(float, vertical_gradient);
MBGL_DEFINE_UNIFORM_SCALAR(float, height_factor);
} // namespace uniforms

Expand All @@ -36,7 +37,8 @@ using FillExtrusionUniforms = TypeList<
uniforms::opacity,
uniforms::lightcolor,
uniforms::lightpos,
uniforms::lightintensity>;
uniforms::lightintensity,
uniforms::vertical_gradient>;

using FillExtrusionPatternUniforms = TypeList<
uniforms::matrix,
Expand All @@ -49,7 +51,8 @@ using FillExtrusionPatternUniforms = TypeList<
uniforms::height_factor,
uniforms::lightcolor,
uniforms::lightpos,
uniforms::lightintensity>;
uniforms::lightintensity,
uniforms::vertical_gradient>;

class FillExtrusionProgram : public Program<
FillExtrusionProgram,
Expand Down Expand Up @@ -83,7 +86,7 @@ class FillExtrusionProgram : public Program<
}

static LayoutUniformValues
layoutUniformValues(mat4, const TransformState&, const float opacity, const EvaluatedLight&);
layoutUniformValues(mat4, const TransformState&, const float opacity, const EvaluatedLight&, const float verticalGradient);
};

class FillExtrusionPatternProgram : public Program<
Expand All @@ -106,7 +109,8 @@ class FillExtrusionPatternProgram : public Program<
const float opacity,
const float heightFactor,
const float pixelRatio,
const EvaluatedLight&);
const EvaluatedLight&,
const float verticalGradient);
};

using FillExtrusionLayoutVertex = FillExtrusionProgram::LayoutVertex;
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
parameters.state),
parameters.state,
evaluated.get<FillExtrusionOpacity>(),
parameters.evaluatedLight
parameters.evaluatedLight,
evaluated.get<FillExtrusionVerticalGradient>()
),
{},
{},
Expand Down Expand Up @@ -188,7 +189,8 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
evaluated.get<FillExtrusionOpacity>(),
-std::pow(2, tile.id.canonical.z) / util::tileSize / 8.0f,
parameters.pixelRatio,
parameters.evaluatedLight
parameters.evaluatedLight,
evaluated.get<FillExtrusionVerticalGradient>()
),
patternPosA,
patternPosB,
Expand Down

0 comments on commit 62f6338

Please sign in to comment.