summaryrefslogtreecommitdiff
path: root/src/mbgl/programs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r--src/mbgl/programs/attributes.hpp7
-rw-r--r--src/mbgl/programs/heatmap_program.cpp7
-rw-r--r--src/mbgl/programs/heatmap_program.hpp49
-rw-r--r--src/mbgl/programs/heatmap_texture_program.cpp7
-rw-r--r--src/mbgl/programs/heatmap_texture_program.hpp43
-rw-r--r--src/mbgl/programs/programs.hpp6
-rw-r--r--src/mbgl/programs/uniforms.hpp5
7 files changed, 123 insertions, 1 deletions
diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp
index 5d7a6474cf..c677c84d5d 100644
--- a/src/mbgl/programs/attributes.hpp
+++ b/src/mbgl/programs/attributes.hpp
@@ -30,7 +30,7 @@ MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_anchor_pos);
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos);
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_normal_ed);
MBGL_DEFINE_ATTRIBUTE(uint8_t, 1, a_fade_opacity);
-MBGL_DEFINE_ATTRIBUTE(uint8_t, 2, a_placed);
+MBGL_DEFINE_ATTRIBUTE(uint8_t, 2, a_placed);
template <typename T, std::size_t N>
struct a_data {
@@ -142,6 +142,11 @@ struct a_halo_blur {
using Type = gl::Attribute<float, 1>;
};
+struct a_weight {
+ static auto name() { return "a_weight"; }
+ using Type = gl::Attribute<float, 1>;
+};
+
} // namespace attributes
struct PositionOnlyLayoutAttributes : gl::Attributes<
diff --git a/src/mbgl/programs/heatmap_program.cpp b/src/mbgl/programs/heatmap_program.cpp
new file mode 100644
index 0000000000..67f84fbd52
--- /dev/null
+++ b/src/mbgl/programs/heatmap_program.cpp
@@ -0,0 +1,7 @@
+#include <mbgl/programs/heatmap_program.hpp>
+
+namespace mbgl {
+
+static_assert(sizeof(HeatmapLayoutVertex) == 4, "expected HeatmapLayoutVertex size");
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/heatmap_program.hpp b/src/mbgl/programs/heatmap_program.hpp
new file mode 100644
index 0000000000..2d9b80404f
--- /dev/null
+++ b/src/mbgl/programs/heatmap_program.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shaders/heatmap.hpp>
+#include <mbgl/util/geometry.hpp>
+#include <mbgl/style/layers/heatmap_layer_properties.hpp>
+
+namespace mbgl {
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_intensity);
+} // namespace uniforms
+
+class HeatmapProgram : public Program<
+ shaders::heatmap,
+ gl::Triangle,
+ gl::Attributes<
+ attributes::a_pos>,
+ gl::Uniforms<
+ uniforms::u_intensity,
+ uniforms::u_matrix,
+ uniforms::heatmap::u_extrude_scale>,
+ style::HeatmapPaintProperties>
+{
+public:
+ using Program::Program;
+
+ /*
+ * @param {number} x vertex position
+ * @param {number} y vertex position
+ * @param {number} ex extrude normal
+ * @param {number} ey extrude normal
+ */
+ static LayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
+ return LayoutVertex {
+ {{
+ static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
+ static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
+ }}
+ };
+ }
+};
+
+using HeatmapLayoutVertex = HeatmapProgram::LayoutVertex;
+using HeatmapAttributes = HeatmapProgram::Attributes;
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/heatmap_texture_program.cpp b/src/mbgl/programs/heatmap_texture_program.cpp
new file mode 100644
index 0000000000..3b0e24eab8
--- /dev/null
+++ b/src/mbgl/programs/heatmap_texture_program.cpp
@@ -0,0 +1,7 @@
+#include <mbgl/programs/heatmap_texture_program.hpp>
+
+namespace mbgl {
+
+static_assert(sizeof(HeatmapTextureLayoutVertex) == 4, "expected HeatmapTextureLayoutVertex size");
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/heatmap_texture_program.hpp b/src/mbgl/programs/heatmap_texture_program.hpp
new file mode 100644
index 0000000000..7afe8060d0
--- /dev/null
+++ b/src/mbgl/programs/heatmap_texture_program.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shaders/heatmap_texture.hpp>
+#include <mbgl/style/properties.hpp>
+#include <mbgl/util/geometry.hpp>
+
+namespace mbgl {
+
+namespace uniforms {
+MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_color_ramp);
+} // namespace uniforms
+
+class HeatmapTextureProgram : public Program<
+ shaders::heatmap_texture,
+ gl::Triangle,
+ gl::Attributes<attributes::a_pos>,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_world,
+ uniforms::u_image,
+ uniforms::u_color_ramp,
+ uniforms::u_opacity>,
+ style::Properties<>> {
+public:
+ using Program::Program;
+
+ static LayoutVertex layoutVertex(Point<int16_t> p) {
+ return LayoutVertex{
+ {{
+ p.x,
+ p.y
+ }}
+ };
+ }
+};
+
+using HeatmapTextureLayoutVertex = HeatmapTextureProgram::LayoutVertex;
+using HeatmapTextureAttributes = HeatmapTextureProgram::Attributes;
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp
index f533a6f633..b703323d9c 100644
--- a/src/mbgl/programs/programs.hpp
+++ b/src/mbgl/programs/programs.hpp
@@ -6,6 +6,8 @@
#include <mbgl/programs/extrusion_texture_program.hpp>
#include <mbgl/programs/fill_program.hpp>
#include <mbgl/programs/fill_extrusion_program.hpp>
+#include <mbgl/programs/heatmap_program.hpp>
+#include <mbgl/programs/heatmap_texture_program.hpp>
#include <mbgl/programs/hillshade_program.hpp>
#include <mbgl/programs/hillshade_prepare_program.hpp>
#include <mbgl/programs/line_program.hpp>
@@ -30,6 +32,8 @@ public:
fillPattern(context, programParameters),
fillOutline(context, programParameters),
fillOutlinePattern(context, programParameters),
+ heatmap(context, programParameters),
+ heatmapTexture(context, programParameters),
hillshade(context, programParameters),
hillshadePrepare(context, programParameters),
line(context, programParameters),
@@ -55,6 +59,8 @@ public:
ProgramMap<FillPatternProgram> fillPattern;
ProgramMap<FillOutlineProgram> fillOutline;
ProgramMap<FillOutlinePatternProgram> fillOutlinePattern;
+ ProgramMap<HeatmapProgram> heatmap;
+ HeatmapTextureProgram heatmapTexture;
HillshadeProgram hillshade;
HillshadePrepareProgram hillshadePrepare;
ProgramMap<LineProgram> line;
diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp
index 107c084918..071a27c808 100644
--- a/src/mbgl/programs/uniforms.hpp
+++ b/src/mbgl/programs/uniforms.hpp
@@ -37,9 +37,14 @@ MBGL_DEFINE_UNIFORM_SCALAR(Size, u_texsize);
MBGL_DEFINE_UNIFORM_SCALAR(bool, u_pitch_with_map);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_camera_to_center_distance);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_fade_change);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_weight);
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_extrude_scale);
+namespace heatmap {
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_extrude_scale);
+} // namespace heatmap
+
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_tl_a);
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_br_a);
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, u_pattern_tl_b);