diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-17 18:19:48 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-23 12:59:27 -0700 |
commit | 71c8f6aa10368084bc0a365b15f004d0629a8b67 (patch) | |
tree | 14f22e8b37c0ca5112f5c4cefe34e72882dee3b7 /src/mbgl/programs | |
parent | 72b13cef6a83594b15f47bfeaee782504def619e (diff) | |
download | qtlocation-mapboxgl-71c8f6aa10368084bc0a365b15f004d0629a8b67.tar.gz |
[core] Move pattern coordinate division by texture size into shader
This makes pattern usage more like icons, and will be necessary for data-driven *-pattern properties.
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r-- | src/mbgl/programs/fill_extrusion_program.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/fill_extrusion_program.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/fill_program.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/fill_program.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/line_program.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/line_program.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/symbol_program.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/symbol_program.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/programs/uniforms.hpp | 1 |
9 files changed, 14 insertions, 2 deletions
diff --git a/src/mbgl/programs/fill_extrusion_program.cpp b/src/mbgl/programs/fill_extrusion_program.cpp index 63d1cbeb59..1b0f483b1a 100644 --- a/src/mbgl/programs/fill_extrusion_program.cpp +++ b/src/mbgl/programs/fill_extrusion_program.cpp @@ -45,6 +45,7 @@ FillExtrusionUniforms::values(mat4 matrix, FillExtrusionPatternUniforms::Values FillExtrusionPatternUniforms::values(mat4 matrix, + Size atlasSize, const SpriteAtlasElement& a, const SpriteAtlasElement& b, const Faded<std::string>& fading, @@ -66,6 +67,7 @@ FillExtrusionPatternUniforms::values(mat4 matrix, uniforms::u_pattern_size_b::Value{ b.size }, uniforms::u_scale_a::Value{ fading.fromScale }, uniforms::u_scale_b::Value{ fading.toScale }, + uniforms::u_texsize::Value{ atlasSize }, uniforms::u_mix::Value{ fading.t }, uniforms::u_image::Value{ 0 }, uniforms::u_pixel_coord_upper::Value{ std::array<float, 2>{{ float(pixelX >> 16), float(pixelY >> 16) }} }, diff --git a/src/mbgl/programs/fill_extrusion_program.hpp b/src/mbgl/programs/fill_extrusion_program.hpp index 48fca44ee8..7f1c76a6ad 100644 --- a/src/mbgl/programs/fill_extrusion_program.hpp +++ b/src/mbgl/programs/fill_extrusion_program.hpp @@ -55,6 +55,7 @@ struct FillExtrusionPatternUniforms : gl::Uniforms< uniforms::u_pattern_size_b, uniforms::u_scale_a, uniforms::u_scale_b, + uniforms::u_texsize, uniforms::u_mix, uniforms::u_image, uniforms::u_pixel_coord_upper, @@ -66,6 +67,7 @@ struct FillExtrusionPatternUniforms : gl::Uniforms< uniforms::u_lightintensity> { static Values values(mat4, + Size atlasSize, const SpriteAtlasElement&, const SpriteAtlasElement&, const Faded<std::string>&, diff --git a/src/mbgl/programs/fill_program.cpp b/src/mbgl/programs/fill_program.cpp index 4310f01164..13f7b00e35 100644 --- a/src/mbgl/programs/fill_program.cpp +++ b/src/mbgl/programs/fill_program.cpp @@ -13,6 +13,7 @@ static_assert(sizeof(FillLayoutVertex) == 4, "expected FillLayoutVertex size"); FillPatternUniforms::Values FillPatternUniforms::values(mat4 matrix, Size framebufferSize, + Size atlasSize, const SpriteAtlasElement& a, const SpriteAtlasElement& b, const Faded<std::string>& fading, @@ -26,6 +27,7 @@ FillPatternUniforms::values(mat4 matrix, return FillPatternUniforms::Values { uniforms::u_matrix::Value{ matrix }, uniforms::u_world::Value{ framebufferSize }, + uniforms::u_texsize::Value{ atlasSize }, uniforms::u_pattern_tl_a::Value{ a.tl }, uniforms::u_pattern_br_a::Value{ a.br }, uniforms::u_pattern_tl_b::Value{ b.tl }, diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp index 63751e740a..093485fc7f 100644 --- a/src/mbgl/programs/fill_program.hpp +++ b/src/mbgl/programs/fill_program.hpp @@ -33,6 +33,7 @@ struct FillUniforms : gl::Uniforms< struct FillPatternUniforms : gl::Uniforms< uniforms::u_matrix, uniforms::u_world, + uniforms::u_texsize, uniforms::u_pattern_tl_a, uniforms::u_pattern_br_a, uniforms::u_pattern_tl_b, @@ -49,6 +50,7 @@ struct FillPatternUniforms : gl::Uniforms< { static Values values(mat4 matrix, Size framebufferSize, + Size atlasSize, const SpriteAtlasElement&, const SpriteAtlasElement&, const Faded<std::string>&, diff --git a/src/mbgl/programs/line_program.cpp b/src/mbgl/programs/line_program.cpp index e7e5c58e47..1e296963f2 100644 --- a/src/mbgl/programs/line_program.cpp +++ b/src/mbgl/programs/line_program.cpp @@ -88,6 +88,7 @@ LinePatternProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated& const RenderTile& tile, const TransformState& state, const std::array<float, 2>& pixelsToGLUnits, + const Size atlasSize, const SpriteAtlasElement& posA, const SpriteAtlasElement& posB) { std::array<float, 2> sizeA {{ @@ -111,6 +112,7 @@ LinePatternProgram::uniformValues(const LinePaintProperties::PossiblyEvaluated& uniforms::u_pattern_br_b::Value{ posB.br }, uniforms::u_pattern_size_a::Value{ sizeA }, uniforms::u_pattern_size_b::Value{ sizeB }, + uniforms::u_texsize::Value{ atlasSize }, uniforms::u_fade::Value{ properties.get<LinePattern>().t }, uniforms::u_image::Value{ 0 } ); diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp index 9ad3882e72..6f6ceeb32b 100644 --- a/src/mbgl/programs/line_program.hpp +++ b/src/mbgl/programs/line_program.hpp @@ -112,6 +112,7 @@ class LinePatternProgram : public Program< uniforms::u_pattern_br_b, uniforms::u_pattern_size_a, uniforms::u_pattern_size_b, + uniforms::u_texsize, uniforms::u_fade, uniforms::u_image>, style::LinePaintProperties> @@ -123,6 +124,7 @@ public: const RenderTile&, const TransformState&, const std::array<float, 2>& pixelsToGLUnits, + Size atlasSize, const SpriteAtlasElement& posA, const SpriteAtlasElement& posB); }; diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 1fb4ae5c5e..cdbd6b9713 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -51,7 +51,7 @@ Values makeValues(const bool isText, values.translateAnchor, state) }, uniforms::u_extrude_scale::Value{ extrudeScale }, - uniforms::u_texsize::Value{ std::array<float, 2> {{ float(texsize.width), float(texsize.height) }} }, + uniforms::u_texsize::Value{ texsize }, uniforms::u_zoom::Value{ float(state.getZoom()) }, uniforms::u_rotate_with_map::Value{ values.rotationAlignment == AlignmentType::Map }, uniforms::u_texture::Value{ 0 }, diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index f86b2d97b7..48928988e6 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -29,7 +29,6 @@ class RenderTile; class TransformState; namespace uniforms { -MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_texsize); MBGL_DEFINE_UNIFORM_SCALAR(bool, u_rotate_with_map); MBGL_DEFINE_UNIFORM_SCALAR(bool, u_pitch_with_map); MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_texture); diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp index 972405d5a9..a2bfe396b1 100644 --- a/src/mbgl/programs/uniforms.hpp +++ b/src/mbgl/programs/uniforms.hpp @@ -18,6 +18,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_pitch); MBGL_DEFINE_UNIFORM_SCALAR(float, u_bearing); MBGL_DEFINE_UNIFORM_SCALAR(Size, u_world); +MBGL_DEFINE_UNIFORM_SCALAR(Size, u_texsize); MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_extrude_scale); |