diff options
-rw-r--r-- | cmake/core-files.cmake | 10 | ||||
m--------- | mapbox-gl-js | 0 | ||||
-rw-r--r-- | src/mbgl/programs/attributes.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/programs/background_program.cpp | 47 | ||||
-rw-r--r-- | src/mbgl/programs/background_program.hpp | 83 | ||||
-rw-r--r-- | src/mbgl/programs/clipping_mask_program.hpp | 26 | ||||
-rw-r--r-- | src/mbgl/programs/fill_program.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/programs/programs.hpp | 12 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_background_layer.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/renderer/render_static_data.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/renderer/render_static_data.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/render_tile.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer_impl.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_image_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/shaders/background.cpp | 34 | ||||
-rw-r--r-- | src/mbgl/shaders/background.hpp | 16 | ||||
-rw-r--r-- | src/mbgl/shaders/background_pattern.cpp | 65 | ||||
-rw-r--r-- | src/mbgl/shaders/background_pattern.hpp | 16 | ||||
-rw-r--r-- | src/mbgl/shaders/clipping_mask.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/shaders/clipping_mask.hpp | 16 |
20 files changed, 387 insertions, 40 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 5c060f4698..cfe543e102 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -128,10 +128,13 @@ set(MBGL_CORE_FILES # programs src/mbgl/programs/attributes.hpp + src/mbgl/programs/background_program.cpp + src/mbgl/programs/background_program.hpp src/mbgl/programs/binary_program.cpp src/mbgl/programs/binary_program.hpp src/mbgl/programs/circle_program.cpp src/mbgl/programs/circle_program.hpp + src/mbgl/programs/clipping_mask_program.hpp src/mbgl/programs/collision_box_program.cpp src/mbgl/programs/collision_box_program.hpp src/mbgl/programs/debug_program.hpp @@ -254,8 +257,14 @@ set(MBGL_CORE_FILES src/mbgl/renderer/sources/render_vector_source.hpp # shaders + src/mbgl/shaders/background.cpp + src/mbgl/shaders/background.hpp + src/mbgl/shaders/background_pattern.cpp + src/mbgl/shaders/background_pattern.hpp src/mbgl/shaders/circle.cpp src/mbgl/shaders/circle.hpp + src/mbgl/shaders/clipping_mask.cpp + src/mbgl/shaders/clipping_mask.hpp src/mbgl/shaders/collision_box.cpp src/mbgl/shaders/collision_box.hpp src/mbgl/shaders/collision_circle.cpp @@ -630,6 +639,7 @@ set(MBGL_CORE_FILES include/mbgl/util/tileset.hpp include/mbgl/util/timer.hpp include/mbgl/util/traits.hpp + include/mbgl/util/tuple.hpp include/mbgl/util/type_list.hpp include/mbgl/util/unique_any.hpp include/mbgl/util/unitbezier.hpp diff --git a/mapbox-gl-js b/mapbox-gl-js -Subproject 2c127fabb5f57d403d6d825693007137a8102e8 +Subproject 5e44e625ccf6e9d5e6d48011bb11281d1a4a197 diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp index b0582b0bc2..5d7a6474cf 100644 --- a/src/mbgl/programs/attributes.hpp +++ b/src/mbgl/programs/attributes.hpp @@ -143,4 +143,9 @@ struct a_halo_blur { }; } // namespace attributes + +struct PositionOnlyLayoutAttributes : gl::Attributes< + attributes::a_pos> +{}; + } // namespace mbgl diff --git a/src/mbgl/programs/background_program.cpp b/src/mbgl/programs/background_program.cpp new file mode 100644 index 0000000000..52a9638d6b --- /dev/null +++ b/src/mbgl/programs/background_program.cpp @@ -0,0 +1,47 @@ +#include <mbgl/programs/background_program.hpp> +#include <mbgl/renderer/image_atlas.hpp> +#include <mbgl/renderer/cross_faded_property_evaluator.hpp> +#include <mbgl/tile/tile_id.hpp> +#include <mbgl/map/transform_state.hpp> + +namespace mbgl { + +using namespace style; + +static_assert(sizeof(BackgroundLayoutVertex) == 4, "expected BackgroundLayoutVertex size"); + +BackgroundPatternUniforms::Values +BackgroundPatternUniforms::values(mat4 matrix, + float opacity, + Size atlasSize, + const ImagePosition& a, + const ImagePosition& b, + const Faded<std::string>& fading, + const UnwrappedTileID& tileID, + const TransformState& state) +{ + 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)); + int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y; + + return BackgroundPatternUniforms::Values { + uniforms::u_matrix::Value{ matrix }, + uniforms::u_opacity::Value{ opacity }, + 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() }, + uniforms::u_pattern_br_b::Value{ b.br() }, + uniforms::u_pattern_size_a::Value{ a.displaySize() }, + uniforms::u_pattern_size_b::Value{ b.displaySize() }, + uniforms::u_scale_a::Value{ fading.fromScale }, + uniforms::u_scale_b::Value{ fading.toScale }, + 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) }} }, + uniforms::u_pixel_coord_lower::Value{ std::array<float, 2> {{ float(pixelX & 0xFFFF), float(pixelY & 0xFFFF) }} }, + uniforms::u_tile_units_to_pixels::Value{ 1.0f / tileID.pixelsToTileUnits(1.0f, state.getIntegerZoom()) }, + }; +} + +} // namespace mbgl diff --git a/src/mbgl/programs/background_program.hpp b/src/mbgl/programs/background_program.hpp new file mode 100644 index 0000000000..b76318938c --- /dev/null +++ b/src/mbgl/programs/background_program.hpp @@ -0,0 +1,83 @@ +#pragma once + +#include <mbgl/programs/program.hpp> +#include <mbgl/programs/attributes.hpp> +#include <mbgl/programs/uniforms.hpp> +#include <mbgl/shaders/background.hpp> +#include <mbgl/shaders/background_pattern.hpp> +#include <mbgl/util/geometry.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/size.hpp> +#include <mbgl/style/layers/background_layer_properties.hpp> + +#include <string> + +namespace mbgl { + +class ImagePosition; +class UnwrappedTileID; +class TransformState; +template <class> class Faded; + +using BackgroundLayoutAttributes = PositionOnlyLayoutAttributes; + +struct BackgroundUniforms : gl::Uniforms< + uniforms::u_matrix, + uniforms::u_color, + uniforms::u_opacity> +{}; + +struct BackgroundPatternUniforms : gl::Uniforms< + uniforms::u_matrix, + uniforms::u_opacity, + uniforms::u_texsize, + uniforms::u_pattern_tl_a, + uniforms::u_pattern_br_a, + uniforms::u_pattern_tl_b, + uniforms::u_pattern_br_b, + uniforms::u_pattern_size_a, + uniforms::u_pattern_size_b, + uniforms::u_scale_a, + uniforms::u_scale_b, + uniforms::u_mix, + uniforms::u_image, + uniforms::u_pixel_coord_upper, + uniforms::u_pixel_coord_lower, + uniforms::u_tile_units_to_pixels> +{ + static Values values(mat4 matrix, + float opacity, + Size atlasSize, + const ImagePosition&, + const ImagePosition&, + const Faded<std::string>&, + const UnwrappedTileID&, + const TransformState&); +}; + +class BackgroundProgram : public Program< + shaders::background, + gl::Triangle, + BackgroundLayoutAttributes, + BackgroundUniforms, + style::Properties<>> +{ +public: + using Program::Program; +}; + +class BackgroundPatternProgram : public Program< + shaders::background_pattern, + gl::Triangle, + BackgroundLayoutAttributes, + BackgroundPatternUniforms, + style::Properties<>> +{ +public: + using Program::Program; +}; + +using BackgroundLayoutVertex = BackgroundProgram::LayoutVertex; +using BackgroundAttributes = BackgroundProgram::Attributes; + +} // namespace mbgl diff --git a/src/mbgl/programs/clipping_mask_program.hpp b/src/mbgl/programs/clipping_mask_program.hpp new file mode 100644 index 0000000000..5dff4849fe --- /dev/null +++ b/src/mbgl/programs/clipping_mask_program.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include <mbgl/programs/program.hpp> +#include <mbgl/programs/attributes.hpp> +#include <mbgl/programs/uniforms.hpp> +#include <mbgl/shaders/clipping_mask.hpp> +#include <mbgl/style/properties.hpp> + +namespace mbgl { + +class ClippingMaskProgram : public Program< + shaders::clipping_mask, + gl::Triangle, + PositionOnlyLayoutAttributes, + gl::Uniforms< + uniforms::u_matrix>, + style::Properties<>> +{ +public: + using Program::Program; +}; + +using ClippingMaskLayoutVertex = ClippingMaskProgram::LayoutVertex; +using ClippingMaskAttributes = ClippingMaskProgram::Attributes; + +} // namespace mbgl diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp index 2dfeea3279..ac478250fc 100644 --- a/src/mbgl/programs/fill_program.hpp +++ b/src/mbgl/programs/fill_program.hpp @@ -21,9 +21,7 @@ class UnwrappedTileID; class TransformState; template <class> class Faded; -struct FillLayoutAttributes : gl::Attributes< - attributes::a_pos> -{}; +using FillLayoutAttributes = PositionOnlyLayoutAttributes; struct FillUniforms : gl::Uniforms< uniforms::u_matrix, diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp index d769defaaf..a3891fafac 100644 --- a/src/mbgl/programs/programs.hpp +++ b/src/mbgl/programs/programs.hpp @@ -1,6 +1,8 @@ #pragma once +#include <mbgl/programs/background_program.hpp> #include <mbgl/programs/circle_program.hpp> +#include <mbgl/programs/clipping_mask_program.hpp> #include <mbgl/programs/extrusion_texture_program.hpp> #include <mbgl/programs/fill_program.hpp> #include <mbgl/programs/fill_extrusion_program.hpp> @@ -16,7 +18,9 @@ namespace mbgl { class Programs { public: Programs(gl::Context& context, const ProgramParameters& programParameters) - : circle(context, programParameters), + : background(context, programParameters), + backgroundPattern(context, programParameters), + circle(context, programParameters), extrusionTexture(context, programParameters), fill(context, programParameters), fillExtrusion(context, programParameters), @@ -33,9 +37,12 @@ public: symbolGlyph(context, programParameters), debug(context, programParameters), collisionBox(context, programParameters), - collisionCircle(context, programParameters) { + collisionCircle(context, programParameters), + clippingMask(context, programParameters) { } + BackgroundProgram background; + BackgroundPatternProgram backgroundPattern; ProgramMap<CircleProgram> circle; ExtrusionTextureProgram extrusionTexture; ProgramMap<FillProgram> fill; @@ -55,6 +62,7 @@ public: DebugProgram debug; CollisionBoxProgram collisionBox; CollisionCircleProgram collisionCircle; + ClippingMaskProgram clippingMask; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp index 9fddba3f74..aebc4cc9aa 100644 --- a/src/mbgl/renderer/layers/render_background_layer.cpp +++ b/src/mbgl/renderer/layers/render_background_layer.cpp @@ -5,7 +5,7 @@ #include <mbgl/renderer/image_manager.hpp> #include <mbgl/renderer/render_static_data.hpp> #include <mbgl/programs/programs.hpp> -#include <mbgl/programs/fill_program.hpp> +#include <mbgl/programs/background_program.hpp> #include <mbgl/util/tile_cover.hpp> namespace mbgl { @@ -46,12 +46,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { // Note that for bottommost layers without a pattern, the background color is drawn with // glClear rather than this method. - style::FillPaintProperties::PossiblyEvaluated properties; - properties.get<FillPattern>() = evaluated.get<BackgroundPattern>(); - properties.get<FillOpacity>() = { evaluated.get<BackgroundOpacity>() }; - properties.get<FillColor>() = { evaluated.get<BackgroundColor>() }; - - const FillProgram::PaintPropertyBinders paintAttibuteData(properties, 0); + const Properties<>::PossiblyEvaluated properties; + const BackgroundProgram::PaintPropertyBinders paintAttributeData(properties, 0); if (!evaluated.get<BackgroundPattern>().to.empty()) { optional<ImagePosition> imagePosA = parameters.imageManager.getPattern(evaluated.get<BackgroundPattern>().from); @@ -63,15 +59,15 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { parameters.imageManager.bind(parameters.context, 0); for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { - parameters.programs.fillPattern.get(properties).draw( + parameters.programs.backgroundPattern.draw( parameters.context, gl::Triangles(), parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), - FillPatternUniforms::values( + BackgroundPatternUniforms::values( parameters.matrixForTile(tileID), - parameters.context.viewport.getCurrentValue().size, + evaluated.get<BackgroundOpacity>(), parameters.imageManager.getPixelSize(), *imagePosA, *imagePosB, @@ -82,7 +78,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { parameters.staticData.tileVertexBuffer, parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.tileTriangleSegments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), getID() @@ -90,20 +86,21 @@ void RenderBackgroundLayer::render(PaintParameters& parameters, RenderSource*) { } } else { for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { - parameters.programs.fill.get(properties).draw( + parameters.programs.background.draw( parameters.context, gl::Triangles(), parameters.depthModeForSublayer(0, gl::DepthMode::ReadOnly), gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), - FillProgram::UniformValues { + BackgroundProgram::UniformValues { uniforms::u_matrix::Value{ parameters.matrixForTile(tileID) }, - uniforms::u_world::Value{ parameters.context.viewport.getCurrentValue().size }, + uniforms::u_color::Value{ evaluated.get<BackgroundColor>() }, + uniforms::u_opacity::Value{ evaluated.get<BackgroundOpacity>() }, }, parameters.staticData.tileVertexBuffer, parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.tileTriangleSegments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), getID() diff --git a/src/mbgl/renderer/render_static_data.cpp b/src/mbgl/renderer/render_static_data.cpp index ccf239e643..0b3937ded0 100644 --- a/src/mbgl/renderer/render_static_data.cpp +++ b/src/mbgl/renderer/render_static_data.cpp @@ -3,12 +3,12 @@ namespace mbgl { -static gl::VertexVector<FillLayoutVertex> tileVertices() { - gl::VertexVector<FillLayoutVertex> result; - result.emplace_back(FillProgram::layoutVertex({ 0, 0 })); - result.emplace_back(FillProgram::layoutVertex({ util::EXTENT, 0 })); - result.emplace_back(FillProgram::layoutVertex({ 0, util::EXTENT })); - result.emplace_back(FillProgram::layoutVertex({ util::EXTENT, util::EXTENT })); +static gl::VertexVector<PositionOnlyLayoutAttributes::Vertex> tileVertices() { + gl::VertexVector<PositionOnlyLayoutAttributes::Vertex> result; + result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ 0, 0 }}})); + result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ util::EXTENT, 0 }}})); + result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ 0, util::EXTENT }}})); + result.emplace_back(PositionOnlyLayoutAttributes::Vertex({{{ util::EXTENT, util::EXTENT }}})); return result; } diff --git a/src/mbgl/renderer/render_static_data.hpp b/src/mbgl/renderer/render_static_data.hpp index cf58c31f4d..c2b54f3815 100644 --- a/src/mbgl/renderer/render_static_data.hpp +++ b/src/mbgl/renderer/render_static_data.hpp @@ -13,14 +13,14 @@ class RenderStaticData { public: RenderStaticData(gl::Context&, float pixelRatio, const optional<std::string>& programCacheDir); - gl::VertexBuffer<FillLayoutVertex> tileVertexBuffer; + gl::VertexBuffer<PositionOnlyLayoutAttributes::Vertex> tileVertexBuffer; gl::VertexBuffer<RasterLayoutVertex> rasterVertexBuffer; gl::VertexBuffer<ExtrusionTextureLayoutVertex> extrusionTextureVertexBuffer; gl::IndexBuffer<gl::Triangles> quadTriangleIndexBuffer; gl::IndexBuffer<gl::LineStrip> tileBorderIndexBuffer; - SegmentVector<FillAttributes> tileTriangleSegments; + SegmentVector<BackgroundAttributes> tileTriangleSegments; SegmentVector<DebugAttributes> tileBorderSegments; SegmentVector<RasterAttributes> rasterSegments; SegmentVector<ExtrusionTextureAttributes> extrusionTextureSegments; diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index 8df31f8d7c..35b34833e4 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -72,7 +72,7 @@ void RenderTile::finishRender(PaintParameters& parameters) { return; static const style::Properties<>::PossiblyEvaluated properties {}; - static const DebugProgram::PaintPropertyBinders paintAttibuteData(properties, 0); + static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0); if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) { if (!tile.debugBucket || tile.debugBucket->renderable != tile.isRenderable() || @@ -98,7 +98,7 @@ void RenderTile::finishRender(PaintParameters& parameters) { *tile.debugBucket->vertexBuffer, *tile.debugBucket->indexBuffer, tile.debugBucket->segments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), "debug" @@ -117,7 +117,7 @@ void RenderTile::finishRender(PaintParameters& parameters) { *tile.debugBucket->vertexBuffer, *tile.debugBucket->indexBuffer, tile.debugBucket->segments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), "debug" @@ -138,7 +138,7 @@ void RenderTile::finishRender(PaintParameters& parameters) { parameters.staticData.tileVertexBuffer, parameters.staticData.tileBorderIndexBuffer, parameters.staticData.tileBorderSegments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), "debug" diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 4bed0e251b..9fe421fa14 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -474,11 +474,11 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { { MBGL_DEBUG_GROUP(parameters.context, "clipping masks"); - static const style::FillPaintProperties::PossiblyEvaluated properties {}; - static const FillProgram::PaintPropertyBinders paintAttibuteData(properties, 0); + static const Properties<>::PossiblyEvaluated properties {}; + static const ClippingMaskProgram::PaintPropertyBinders paintAttributeData(properties, 0); for (const auto& clipID : parameters.clipIDGenerator.getClipIDs()) { - parameters.staticData.programs.fill.get(properties).draw( + parameters.staticData.programs.clippingMask.draw( parameters.context, gl::Triangles(), gl::DepthMode::disabled(), @@ -491,14 +491,13 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { gl::StencilMode::Replace }, gl::ColorMode::disabled(), - FillProgram::UniformValues { + ClippingMaskProgram::UniformValues { uniforms::u_matrix::Value{ parameters.matrixForTile(clipID.first) }, - uniforms::u_world::Value{ parameters.context.viewport.getCurrentValue().size }, }, parameters.staticData.tileVertexBuffer, parameters.staticData.quadTriangleIndexBuffer, parameters.staticData.tileTriangleSegments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), "clipping" diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index d215dc8d13..35b80cd998 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -56,7 +56,7 @@ void RenderImageSource::finishRender(PaintParameters& parameters) { } static const style::Properties<>::PossiblyEvaluated properties {}; - static const DebugProgram::PaintPropertyBinders paintAttibuteData(properties, 0); + static const DebugProgram::PaintPropertyBinders paintAttributeData(properties, 0); for (auto matrix : matrices) { parameters.programs.debug.draw( @@ -72,7 +72,7 @@ void RenderImageSource::finishRender(PaintParameters& parameters) { parameters.staticData.tileVertexBuffer, parameters.staticData.tileBorderIndexBuffer, parameters.staticData.tileBorderSegments, - paintAttibuteData, + paintAttributeData, properties, parameters.state.getZoom(), "debug" diff --git a/src/mbgl/shaders/background.cpp b/src/mbgl/shaders/background.cpp new file mode 100644 index 0000000000..3eafa47b49 --- /dev/null +++ b/src/mbgl/shaders/background.cpp @@ -0,0 +1,34 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#include <mbgl/shaders/background.hpp> + +namespace mbgl { +namespace shaders { + +const char* background::name = "background"; +const char* background::vertexSource = R"MBGL_SHADER( +attribute vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} + +)MBGL_SHADER"; +const char* background::fragmentSource = R"MBGL_SHADER( +uniform vec4 u_color; +uniform float u_opacity; + +void main() { + gl_FragColor = u_color * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} + +)MBGL_SHADER"; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/shaders/background.hpp b/src/mbgl/shaders/background.hpp new file mode 100644 index 0000000000..2fa6f56e29 --- /dev/null +++ b/src/mbgl/shaders/background.hpp @@ -0,0 +1,16 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#pragma once + +namespace mbgl { +namespace shaders { + +class background { +public: + static const char* name; + static const char* vertexSource; + static const char* fragmentSource; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/shaders/background_pattern.cpp b/src/mbgl/shaders/background_pattern.cpp new file mode 100644 index 0000000000..6fd0a53d19 --- /dev/null +++ b/src/mbgl/shaders/background_pattern.cpp @@ -0,0 +1,65 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#include <mbgl/shaders/background_pattern.hpp> + +namespace mbgl { +namespace shaders { + +const char* background_pattern::name = "background_pattern"; +const char* background_pattern::vertexSource = R"MBGL_SHADER( +uniform mat4 u_matrix; +uniform vec2 u_pattern_size_a; +uniform vec2 u_pattern_size_b; +uniform vec2 u_pixel_coord_upper; +uniform vec2 u_pixel_coord_lower; +uniform float u_scale_a; +uniform float u_scale_b; +uniform float u_tile_units_to_pixels; + +attribute vec2 a_pos; + +varying vec2 v_pos_a; +varying vec2 v_pos_b; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); + + v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); + v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); +} + +)MBGL_SHADER"; +const char* background_pattern::fragmentSource = R"MBGL_SHADER( +uniform vec2 u_pattern_tl_a; +uniform vec2 u_pattern_br_a; +uniform vec2 u_pattern_tl_b; +uniform vec2 u_pattern_br_b; +uniform vec2 u_texsize; +uniform float u_mix; +uniform float u_opacity; + +uniform sampler2D u_image; + +varying vec2 v_pos_a; +varying vec2 v_pos_b; + +void main() { + vec2 imagecoord = mod(v_pos_a, 1.0); + vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); + vec4 color1 = texture2D(u_image, pos); + + vec2 imagecoord_b = mod(v_pos_b, 1.0); + vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); + vec4 color2 = texture2D(u_image, pos2); + + gl_FragColor = mix(color1, color2, u_mix) * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} + +)MBGL_SHADER"; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/shaders/background_pattern.hpp b/src/mbgl/shaders/background_pattern.hpp new file mode 100644 index 0000000000..e970ffd670 --- /dev/null +++ b/src/mbgl/shaders/background_pattern.hpp @@ -0,0 +1,16 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#pragma once + +namespace mbgl { +namespace shaders { + +class background_pattern { +public: + static const char* name; + static const char* vertexSource; + static const char* fragmentSource; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/shaders/clipping_mask.cpp b/src/mbgl/shaders/clipping_mask.cpp new file mode 100644 index 0000000000..fb08d7cb00 --- /dev/null +++ b/src/mbgl/shaders/clipping_mask.cpp @@ -0,0 +1,27 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#include <mbgl/shaders/clipping_mask.hpp> + +namespace mbgl { +namespace shaders { + +const char* clipping_mask::name = "clipping_mask"; +const char* clipping_mask::vertexSource = R"MBGL_SHADER( +attribute vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} + +)MBGL_SHADER"; +const char* clipping_mask::fragmentSource = R"MBGL_SHADER( +void main() { + gl_FragColor = vec4(1.0); +} + +)MBGL_SHADER"; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/shaders/clipping_mask.hpp b/src/mbgl/shaders/clipping_mask.hpp new file mode 100644 index 0000000000..bd01ab62fa --- /dev/null +++ b/src/mbgl/shaders/clipping_mask.hpp @@ -0,0 +1,16 @@ +// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. + +#pragma once + +namespace mbgl { +namespace shaders { + +class clipping_mask { +public: + static const char* name; + static const char* vertexSource; + static const char* fragmentSource; +}; + +} // namespace shaders +} // namespace mbgl |