UBO consolidation (#3089)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,16 +6,24 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
#define FILL_SHADER_COMMON \
|
||||
R"(
|
||||
|
||||
#define idFillDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||
#define idFillTilePropsUBO drawableReservedUBOCount
|
||||
#define idFillEvaluatedPropsUBO layerUBOStartId
|
||||
|
||||
)"
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<AttributeInfo, 3> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
static const std::array<TextureInfo, 0> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
@@ -27,14 +35,23 @@ layout(location = 1) in vec4 in_color;
|
||||
layout(location = 2) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillInterpolateUBO {
|
||||
struct FillDrawableUBO {
|
||||
mat4 matrix;
|
||||
// Interpolations
|
||||
float color_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
float pad1;
|
||||
float pad2;
|
||||
vec4 pad3;
|
||||
};
|
||||
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillDrawableUBO) readonly buffer FillDrawableUBOVector {
|
||||
FillDrawableUBO drawable_ubo[];
|
||||
} drawableVector;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_color)
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
@@ -45,13 +62,14 @@ layout(location = 1) out lowp float frag_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
const FillDrawableUBO drawable = drawableVector.drawable_ubo[constant.ubo_index];
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_color)
|
||||
frag_color = vec4(unpack_mix_color(in_color, interp.color_t));
|
||||
frag_color = vec4(unpack_mix_color(in_color, drawable.color_t));
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_opacity)
|
||||
frag_opacity = unpack_mix_float(in_opacity, interp.opacity_t);
|
||||
frag_opacity = unpack_mix_float(in_opacity, drawable.opacity_t);
|
||||
#endif
|
||||
|
||||
gl_Position = drawable.matrix * vec4(in_position, 0.0, 1.0);
|
||||
@@ -59,7 +77,7 @@ void main() {
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_color)
|
||||
layout(location = 0) in vec4 frag_color;
|
||||
@@ -71,7 +89,7 @@ layout(location = 1) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -103,12 +121,11 @@ template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillOutlineShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<AttributeInfo, 3> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
static const std::array<TextureInfo, 0> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
@@ -120,14 +137,23 @@ layout(location = 1) in vec4 in_color;
|
||||
layout(location = 2) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillInterpolateUBO {
|
||||
float color_t;
|
||||
struct FillOutlineDrawableUBO {
|
||||
mat4 matrix;
|
||||
// Interpolations
|
||||
float outline_color_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
float pad1;
|
||||
float pad2;
|
||||
vec4 pad3;
|
||||
};
|
||||
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillDrawableUBO) readonly buffer FillOutlineDrawableUBOVector {
|
||||
FillOutlineDrawableUBO drawable_ubo[];
|
||||
} drawableVector;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_outline_color)
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
@@ -140,23 +166,24 @@ layout(location = 1) out lowp float frag_opacity;
|
||||
layout(location = 2) out vec2 frag_position;
|
||||
|
||||
void main() {
|
||||
|
||||
const FillOutlineDrawableUBO drawable = drawableVector.drawable_ubo[constant.ubo_index];
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_outline_color)
|
||||
frag_color = vec4(unpack_mix_color(in_color, interp.color_t));
|
||||
frag_color = vec4(unpack_mix_color(in_color, drawable.outline_color_t));
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_opacity)
|
||||
frag_opacity = unpack_mix_float(in_opacity, interp.opacity_t);
|
||||
frag_opacity = unpack_mix_float(in_opacity, drawable.opacity_t);
|
||||
#endif
|
||||
|
||||
gl_Position = drawable.matrix * vec4(in_position, 0.0, 1.0);
|
||||
applySurfaceTransform();
|
||||
|
||||
frag_position = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * global.world_size;
|
||||
frag_position = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * paintParams.world_size;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_outline_color)
|
||||
layout(location = 0) in vec4 frag_color;
|
||||
@@ -170,7 +197,7 @@ layout(location = 2) in vec2 frag_position;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -209,12 +236,11 @@ template <>
|
||||
struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillPatternShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 5> uniforms;
|
||||
static const std::array<AttributeInfo, 4> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
@@ -230,27 +256,38 @@ layout(location = 2) in mediump uvec4 in_pattern_to;
|
||||
layout(location = 3) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillPatternDrawableUBO {
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
struct FillPatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
vec2 texsize;
|
||||
float tile_ratio;
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillPatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillPatternInterpolateUBO {
|
||||
// Interpolations
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
};
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillDrawableUBO) readonly buffer FillPatternDrawableUBOVector {
|
||||
FillPatternDrawableUBO drawable_ubo[];
|
||||
} drawableVector;
|
||||
|
||||
struct FillPatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
vec2 texsize;
|
||||
float pad1;
|
||||
float pad2;
|
||||
};
|
||||
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillTilePropsUBO) readonly buffer FillPatternTilePropsUBOVector {
|
||||
FillPatternTilePropsUBO tile_props_ubo[];
|
||||
} tilePropsVector;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -275,21 +312,23 @@ layout(location = 4) out lowp float frag_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
const FillPatternDrawableUBO drawable = drawableVector.drawable_ubo[constant.ubo_index];
|
||||
const FillPatternTilePropsUBO tileProps = tilePropsVector.tile_props_ubo[constant.ubo_index];
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const vec4 frag_pattern_from = tile.pattern_from;
|
||||
const vec4 frag_pattern_from = tileProps.pattern_from;
|
||||
#else
|
||||
frag_pattern_from = in_pattern_from;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const vec4 frag_pattern_to = tile.pattern_to;
|
||||
const vec4 frag_pattern_to = tileProps.pattern_to;
|
||||
#else
|
||||
frag_pattern_to = in_pattern_to;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_opacity)
|
||||
frag_opacity = unpack_mix_float(in_opacity, interp.opacity_t);
|
||||
frag_opacity = unpack_mix_float(in_opacity, drawable.opacity_t);
|
||||
#endif
|
||||
|
||||
const vec2 pattern_tl_a = frag_pattern_from.xy;
|
||||
@@ -297,7 +336,7 @@ void main() {
|
||||
const vec2 pattern_tl_b = frag_pattern_to.xy;
|
||||
const vec2 pattern_br_b = frag_pattern_to.zw;
|
||||
|
||||
const float pixelRatio = global.pixel_ratio;
|
||||
const float pixelRatio = paintParams.pixel_ratio;
|
||||
const float tileZoomRatio = drawable.tile_ratio;
|
||||
const float fromScale = props.from_scale;
|
||||
const float toScale = props.to_scale;
|
||||
@@ -313,7 +352,7 @@ void main() {
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in vec2 frag_pos_a;
|
||||
layout(location = 1) in vec2 frag_pos_b;
|
||||
@@ -332,21 +371,23 @@ layout(location = 4) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillPatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
vec2 texsize;
|
||||
float tile_ratio;
|
||||
float pad;
|
||||
} drawable;
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillPatternTilePropsUBO {
|
||||
struct FillPatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
vec2 texsize;
|
||||
float pad1;
|
||||
float pad2;
|
||||
};
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillTilePropsUBO) readonly buffer FillPatternTilePropsUBOVector {
|
||||
FillPatternTilePropsUBO tile_props_ubo[];
|
||||
} tilePropsVector;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -364,14 +405,16 @@ void main() {
|
||||
return;
|
||||
#endif
|
||||
|
||||
const FillPatternTilePropsUBO tileProps = tilePropsVector.tile_props_ubo[constant.ubo_index];
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const vec4 pattern_from = tile.pattern_from;
|
||||
const vec4 pattern_from = tileProps.pattern_from;
|
||||
#else
|
||||
const vec4 pattern_from = frag_pattern_from;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const vec4 pattern_to = tile.pattern_to;
|
||||
const vec4 pattern_to = tileProps.pattern_to;
|
||||
#else
|
||||
const vec4 pattern_to = frag_pattern_to;
|
||||
#endif
|
||||
@@ -388,11 +431,11 @@ void main() {
|
||||
const vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
const vec2 imagecoord = mod(frag_pos_a, 1.0);
|
||||
const vec2 pos = mix(pattern_tl_a / drawable.texsize, pattern_br_a / drawable.texsize, imagecoord);
|
||||
const vec2 pos = mix(pattern_tl_a / tileProps.texsize, pattern_br_a / tileProps.texsize, imagecoord);
|
||||
const vec4 color1 = texture(image0_sampler, pos);
|
||||
|
||||
const vec2 imagecoord_b = mod(frag_pos_b, 1.0);
|
||||
const vec2 pos2 = mix(pattern_tl_b / drawable.texsize, pattern_br_b / drawable.texsize, imagecoord_b);
|
||||
const vec2 pos2 = mix(pattern_tl_b / tileProps.texsize, pattern_br_b / tileProps.texsize, imagecoord_b);
|
||||
const vec4 color2 = texture(image0_sampler, pos2);
|
||||
|
||||
out_color = mix(color1, color2, props.fade) * opacity;
|
||||
@@ -404,12 +447,11 @@ template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillOutlinePatternShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 5> uniforms;
|
||||
static const std::array<AttributeInfo, 4> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
@@ -425,27 +467,38 @@ layout(location = 2) in mediump uvec4 in_pattern_to;
|
||||
layout(location = 3) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlinePatternDrawableUBO {
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
struct FillOutlinePatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
vec2 texsize;
|
||||
float tile_ratio;
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillOutlinePatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillOutlinePatternInterpolateUBO {
|
||||
// Interpolations
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
};
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillDrawableUBO) readonly buffer FillOutlinePatternDrawableUBOVector {
|
||||
FillOutlinePatternDrawableUBO drawable_ubo[];
|
||||
} drawableVector;
|
||||
|
||||
struct FillOutlinePatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
vec2 texsize;
|
||||
float pad1;
|
||||
float pad2;
|
||||
};
|
||||
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillTilePropsUBO) readonly buffer FillOutlinePatternTilePropsUBOVector {
|
||||
FillOutlinePatternTilePropsUBO tile_props_ubo[];
|
||||
} tilePropsVector;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -471,21 +524,23 @@ layout(location = 5) out lowp float frag_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
const FillOutlinePatternDrawableUBO drawable = drawableVector.drawable_ubo[constant.ubo_index];
|
||||
const FillOutlinePatternTilePropsUBO tileProps = tilePropsVector.tile_props_ubo[constant.ubo_index];
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const vec4 frag_pattern_from = tile.pattern_from;
|
||||
const vec4 frag_pattern_from = tileProps.pattern_from;
|
||||
#else
|
||||
frag_pattern_from = in_pattern_from;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const vec4 frag_pattern_to = tile.pattern_to;
|
||||
const vec4 frag_pattern_to = tileProps.pattern_to;
|
||||
#else
|
||||
frag_pattern_to = in_pattern_to;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_opacity)
|
||||
frag_opacity = unpack_mix_float(in_opacity, interp.opacity_t);
|
||||
frag_opacity = unpack_mix_float(in_opacity, drawable.opacity_t);
|
||||
#endif
|
||||
|
||||
const vec2 pattern_tl_a = frag_pattern_from.xy;
|
||||
@@ -493,7 +548,7 @@ void main() {
|
||||
const vec2 pattern_tl_b = frag_pattern_to.xy;
|
||||
const vec2 pattern_br_b = frag_pattern_to.zw;
|
||||
|
||||
const float pixelRatio = global.pixel_ratio;
|
||||
const float pixelRatio = paintParams.pixel_ratio;
|
||||
const float tileZoomRatio = drawable.tile_ratio;
|
||||
const float fromScale = props.from_scale;
|
||||
const float toScale = props.to_scale;
|
||||
@@ -507,11 +562,11 @@ void main() {
|
||||
|
||||
frag_pos_a = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, position2),
|
||||
frag_pos_b = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, toScale * display_size_b, tileZoomRatio, position2),
|
||||
frag_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * global.world_size;
|
||||
frag_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * paintParams.world_size;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in vec2 frag_pos_a;
|
||||
layout(location = 1) in vec2 frag_pos_b;
|
||||
@@ -531,21 +586,23 @@ layout(location = 5) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlinePatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
vec2 texsize;
|
||||
float tile_ratio;
|
||||
float pad;
|
||||
} drawable;
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillOutlinePatternTilePropsUBO {
|
||||
struct FillOutlinePatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
vec2 texsize;
|
||||
float pad1;
|
||||
float pad2;
|
||||
};
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillTilePropsUBO) readonly buffer FillOutlinePatternTilePropsUBOVector {
|
||||
FillOutlinePatternTilePropsUBO tile_props_ubo[];
|
||||
} tilePropsVector;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -563,14 +620,16 @@ void main() {
|
||||
return;
|
||||
#endif
|
||||
|
||||
const FillOutlinePatternTilePropsUBO tileProps = tilePropsVector.tile_props_ubo[constant.ubo_index];
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const vec4 pattern_from = tile.pattern_from;
|
||||
const vec4 pattern_from = tileProps.pattern_from;
|
||||
#else
|
||||
const vec4 pattern_from = frag_pattern_from;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const vec4 pattern_to = tile.pattern_to;
|
||||
const vec4 pattern_to = tileProps.pattern_to;
|
||||
#else
|
||||
const vec4 pattern_to = frag_pattern_to;
|
||||
#endif
|
||||
@@ -587,11 +646,11 @@ void main() {
|
||||
const vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
const vec2 imagecoord = mod(frag_pos_a, 1.0);
|
||||
const vec2 pos = mix(pattern_tl_a / drawable.texsize, pattern_br_a / drawable.texsize, imagecoord);
|
||||
const vec2 pos = mix(pattern_tl_a / tileProps.texsize, pattern_br_a / tileProps.texsize, imagecoord);
|
||||
const vec4 color1 = texture(image0_sampler, pos);
|
||||
|
||||
const vec2 imagecoord_b = mod(frag_pos_b, 1.0);
|
||||
const vec2 pos2 = mix(pattern_tl_b / drawable.texsize, pattern_br_b / drawable.texsize, imagecoord_b);
|
||||
const vec2 pos2 = mix(pattern_tl_b / tileProps.texsize, pattern_br_b / tileProps.texsize, imagecoord_b);
|
||||
const vec4 color2 = texture(image0_sampler, pos2);
|
||||
|
||||
const float dist = length(frag_pos - gl_FragCoord.xy);
|
||||
@@ -606,27 +665,39 @@ template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillOutlineTriangulatedShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<AttributeInfo, 2> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
static const std::array<TextureInfo, 0> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_pos_normal;
|
||||
layout(location = 1) in uvec4 in_data;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlineTriangulatedDrawableUBO {
|
||||
layout(push_constant) uniform Constants {
|
||||
int ubo_index;
|
||||
} constant;
|
||||
|
||||
struct FillOutlineTriangulatedDrawableUBO {
|
||||
mat4 matrix;
|
||||
float ratio;
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
float pad1,
|
||||
float pad2
|
||||
float pad3;
|
||||
vec4 pad1;
|
||||
};
|
||||
|
||||
layout(std140, set = LAYER_SET_INDEX, binding = idFillDrawableUBO) readonly buffer FillOutlineTriangulatedDrawableUBOVector {
|
||||
FillOutlineTriangulatedDrawableUBO drawable_ubo[];
|
||||
} drawableVector;
|
||||
|
||||
layout(location = 0) out float frag_width2;
|
||||
layout(location = 1) out vec2 frag_normal;
|
||||
layout(location = 2) out float frag_gamma_scale;
|
||||
|
||||
void main() {
|
||||
const FillOutlineTriangulatedDrawableUBO drawable = drawableVector.drawable_ubo[constant.ubo_index];
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
@@ -657,14 +728,14 @@ void main() {
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
float extrude_length_without_perspective = length(dist);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * global.units_to_pixels);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * paintParams.units_to_pixels);
|
||||
|
||||
frag_width2 = outset;
|
||||
frag_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
||||
|
||||
layout(location = 0) in float frag_width2;
|
||||
layout(location = 1) in vec2 frag_normal;
|
||||
@@ -672,7 +743,7 @@ layout(location = 2) in float frag_gamma_scale;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = idFillEvaluatedPropsUBO) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -701,395 +772,5 @@ void main() {
|
||||
)";
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillExtrusionShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<AttributeInfo, 5> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
layout(location = 1) in ivec4 in_normal_ed;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_color)
|
||||
layout(location = 2) in vec4 in_color;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_base)
|
||||
layout(location = 3) in vec2 in_base;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_height)
|
||||
layout(location = 4) in vec2 in_height;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
float height_factor;
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
float height;
|
||||
float light_intensity;
|
||||
float vertical_gradient;
|
||||
float opacity;
|
||||
float fade;
|
||||
float from_scale;
|
||||
float to_scale;
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(location = 0) out mediump vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_base)
|
||||
const float base = props.light_position_base.w;
|
||||
#else
|
||||
const float base = max(unpack_mix_float(in_base, interp.base_t), 0.0);
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_height)
|
||||
const float height = props.height;
|
||||
#else
|
||||
const float height = max(unpack_mix_float(in_height, interp.height_t), 0.0);
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_color)
|
||||
vec4 color = props.color;
|
||||
#else
|
||||
vec4 color = unpack_mix_color(in_color, interp.color_t);
|
||||
#endif
|
||||
|
||||
const vec3 normal = in_normal_ed.xyz;
|
||||
const float t = mod(normal.x, 2.0);
|
||||
const float z = t != 0.0 ? height : base;
|
||||
|
||||
gl_Position = drawable.matrix * vec4(in_position, z, 1.0);
|
||||
applySurfaceTransform();
|
||||
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
frag_color = vec4(1.0);
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Relative luminance (how dark/bright is the surface color?)
|
||||
const float luminance = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;
|
||||
|
||||
vec4 vcolor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Add slight ambient lighting so no extrusions are totally black
|
||||
color += vec4(0.03, 0.03, 0.03, 1.0);
|
||||
|
||||
// Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray
|
||||
const float directionalFraction = clamp(dot(normal / 16384.0, props.light_position_base.xyz), 0.0, 1.0);
|
||||
|
||||
// Adjust directional so that the range of values for highlight/shading is
|
||||
// narrower with lower light intensity and with lighter/brighter surface colors
|
||||
const float minDirectional = 1.0 - props.light_intensity;
|
||||
const float maxDirectional = max(1.0 - luminance + props.light_intensity, 1.0);
|
||||
float directional = mix(minDirectional, maxDirectional, directionalFraction);
|
||||
|
||||
// Add gradient along z axis of side surfaces
|
||||
if (normal.y != 0.0) {
|
||||
// This avoids another branching statement, but multiplies by a constant of 0.84 if no
|
||||
// vertical gradient, and otherwise calculates the gradient based on base + height
|
||||
// TODO: If we're optimizing to the level of avoiding branches, we should pre-compute
|
||||
// the square root when height is a uniform.
|
||||
const float fMin = mix(0.7, 0.98, 1.0 - props.light_intensity);
|
||||
const float factor = clamp((t + base) * pow(height / 150.0, 0.5), fMin, 1.0);
|
||||
directional *= (1.0 - props.vertical_gradient) + (props.vertical_gradient * factor);
|
||||
}
|
||||
|
||||
// Assign final color based on surface + ambient light color, diffuse light directional,
|
||||
// and light color with lower bounds adjusted to hue of light so that shading is tinted
|
||||
// with the complementary (opposite) color to the light color
|
||||
const vec3 light_color = props.light_color_pad.rgb;
|
||||
const vec3 minLight = mix(vec3(0.0), vec3(0.3), 1.0 - light_color.rgb);
|
||||
vcolor += vec4(clamp(color.rgb * directional * light_color.rgb, minLight, vec3(1.0)), 0.0);
|
||||
|
||||
frag_color = vcolor * props.opacity;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
|
||||
layout(location = 0) in vec4 frag_color;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main() {
|
||||
out_color = frag_color;
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "FillExtrusionPatternShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 5> uniforms;
|
||||
static const std::array<AttributeInfo, 6> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
layout(location = 1) in ivec4 in_normal_ed;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_base)
|
||||
layout(location = 2) in vec2 in_base;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_height)
|
||||
layout(location = 3) in vec2 in_height;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_from)
|
||||
layout(location = 4) in uvec4 in_pattern_from;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_to)
|
||||
layout(location = 5) in uvec4 in_pattern_to;
|
||||
#endif
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
float height_factor;
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
float height;
|
||||
float light_intensity;
|
||||
float vertical_gradient;
|
||||
float opacity;
|
||||
float fade;
|
||||
float from_scale;
|
||||
float to_scale;
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(location = 0) out mediump vec4 frag_lighting;
|
||||
layout(location = 1) out mediump vec2 frag_pos_a;
|
||||
layout(location = 2) out mediump vec2 frag_pos_b;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_from)
|
||||
layout(location = 3) out mediump vec4 frag_pattern_from;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_to)
|
||||
layout(location = 4) out mediump vec4 frag_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_base)
|
||||
const float base = props.light_position_base.w;
|
||||
#else
|
||||
const float base = max(unpack_mix_float(in_base, interp.base_t), 0.0);
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_height)
|
||||
const float height = props.height;
|
||||
#else
|
||||
const float height = max(unpack_mix_float(in_height, interp.height_t), 0.0);
|
||||
#endif
|
||||
|
||||
const vec3 normal = in_normal_ed.xyz;
|
||||
const float edgedistance = in_normal_ed.w;
|
||||
const float t = mod(normal.x, 2.0);
|
||||
const float z = t != 0.0 ? height : base;
|
||||
|
||||
gl_Position = drawable.matrix * vec4(in_position, z, 1.0);
|
||||
applySurfaceTransform();
|
||||
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
frag_color = vec4(1.0);
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const mediump vec4 pattern_from = tile.pattern_from;
|
||||
#else
|
||||
const mediump vec4 pattern_from = in_pattern_from;
|
||||
frag_pattern_from = in_pattern_from;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const mediump vec4 pattern_to = tile.pattern_to;
|
||||
#else
|
||||
const mediump vec4 pattern_to = in_pattern_to;
|
||||
frag_pattern_to = in_pattern_to;
|
||||
#endif
|
||||
|
||||
const vec2 pattern_tl_a = pattern_from.xy;
|
||||
const vec2 pattern_br_a = pattern_from.zw;
|
||||
const vec2 pattern_tl_b = pattern_to.xy;
|
||||
const vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
const float pixelRatio = global.pixel_ratio;
|
||||
const float tileZoomRatio = drawable.tile_ratio;
|
||||
const float fromScale = props.from_scale;
|
||||
const float toScale = props.to_scale;
|
||||
|
||||
const vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
const vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
|
||||
const vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0
|
||||
? vec2(in_position) // extrusion top
|
||||
: vec2(edgedistance, z * drawable.height_factor); // extrusion side
|
||||
|
||||
vec4 lighting = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
float directional = clamp(dot(normal / 16383.0, props.light_position_base.xyz), 0.0, 1.0);
|
||||
directional = mix((1.0 - props.light_intensity), max((0.5 + props.light_intensity), 1.0), directional);
|
||||
|
||||
if (normal.y != 0.0) {
|
||||
// This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient,
|
||||
// and otherwise calculates the gradient based on base + height
|
||||
directional *= (
|
||||
(1.0 - props.vertical_gradient) +
|
||||
(props.vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - props.light_intensity), 1.0)));
|
||||
}
|
||||
|
||||
lighting.rgb += clamp(directional * props.light_color_pad.rgb, mix(vec3(0.0), vec3(0.3), 1.0 - props.light_color_pad.rgb), vec3(1.0));
|
||||
lighting *= props.opacity;
|
||||
|
||||
frag_lighting = lighting;
|
||||
frag_pos_a = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, pos);
|
||||
frag_pos_b = get_pattern_pos(drawable.pixel_coord_upper, drawable.pixel_coord_lower, toScale * display_size_b, tileZoomRatio, pos);
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_from)
|
||||
frag_pattern_from = in_pattern_from;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_to)
|
||||
frag_pattern_to = in_pattern_to;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
|
||||
layout(location = 0) in mediump vec4 frag_lighting;
|
||||
layout(location = 1) in mediump vec2 frag_pos_a;
|
||||
layout(location = 2) in mediump vec2 frag_pos_b;
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_from)
|
||||
layout(location = 3) in mediump vec4 frag_pattern_from;
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_pattern_to)
|
||||
layout(location = 4) in mediump vec4 frag_pattern_to;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
float height_factor;
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
float height;
|
||||
float light_intensity;
|
||||
float vertical_gradient;
|
||||
float opacity;
|
||||
float fade;
|
||||
float from_scale;
|
||||
float to_scale;
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
out_color = vec4(1.0);
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if defined(HAS_UNIFORM_u_pattern_from)
|
||||
const vec4 pattern_from = tile.pattern_from;
|
||||
#else
|
||||
const vec4 pattern_from = frag_pattern_from;
|
||||
#endif
|
||||
#if defined(HAS_UNIFORM_u_pattern_to)
|
||||
const vec4 pattern_to = tile.pattern_to;
|
||||
#else
|
||||
const vec4 pattern_to = frag_pattern_to;
|
||||
#endif
|
||||
|
||||
const vec2 pattern_tl_a = pattern_from.xy;
|
||||
const vec2 pattern_br_a = pattern_from.zw;
|
||||
const vec2 pattern_tl_b = pattern_to.xy;
|
||||
const vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
const vec2 imagecoord = mod(frag_pos_a, 1.0);
|
||||
const vec2 pos = mix(pattern_tl_a / drawable.texsize, pattern_br_a / drawable.texsize, imagecoord);
|
||||
const vec4 color1 = texture(image0_sampler, pos);
|
||||
|
||||
const vec2 imagecoord_b = mod(frag_pos_b, 1.0);
|
||||
const vec2 pos2 = mix(pattern_tl_b / drawable.texsize, pattern_br_b / drawable.texsize, imagecoord_b);
|
||||
const vec4 color2 = texture(image0_sampler, pos2);
|
||||
|
||||
out_color = mix(color1, color2, props.fade) * frag_lighting;
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user