Line layer UBO improvements (#1946)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -19,11 +19,15 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -34,8 +38,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -46,7 +50,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -160,9 +164,8 @@ mediump float width = u_width;
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePropertiesUBO {
|
||||
@@ -173,8 +176,8 @@ layout (std140) uniform LinePropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineInterpolationUBO {
|
||||
@@ -185,7 +188,7 @@ layout (std140) uniform LineInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp vec2 pad3;
|
||||
highp vec2 pad7;
|
||||
};
|
||||
|
||||
in vec2 v_width2;
|
||||
|
||||
@@ -23,11 +23,15 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -37,8 +41,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -48,8 +52,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -154,9 +158,8 @@ mediump float width = u_width;
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineGradientUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientPropertiesUBO {
|
||||
@@ -166,8 +169,8 @@ layout (std140) uniform LineGradientPropertiesUBO {
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
|
||||
highp float pad1;
|
||||
highp vec2 pad2;
|
||||
highp float pad5;
|
||||
highp vec2 pad6;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientInterpolationUBO {
|
||||
@@ -177,8 +180,8 @@ layout (std140) uniform LineGradientInterpolationUBO {
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
|
||||
highp float pad3;
|
||||
highp vec2 pad4;
|
||||
highp float pad7;
|
||||
highp vec2 pad8;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -23,16 +23,17 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
@@ -185,12 +186,8 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
highp mat4 u_matrix;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
mediump float u_ratio;
|
||||
highp float u_fade;
|
||||
|
||||
lowp float pad0;
|
||||
highp float pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternPropertiesUBO {
|
||||
|
||||
@@ -23,9 +23,13 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform LineDynamicUBO {
|
||||
highp vec2 u_units_to_pixels;
|
||||
lowp float pad0, pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -33,8 +37,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_tex_y_b;
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -46,7 +49,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -58,7 +61,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
@@ -186,7 +189,6 @@ lowp float floorwidth = u_floorwidth;
|
||||
static constexpr const char* fragment = R"(
|
||||
layout (std140) uniform LineSDFUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
mediump float u_ratio;
|
||||
@@ -195,7 +197,7 @@ layout (std140) uniform LineSDFUBO {
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
|
||||
lowp float pad0;
|
||||
lowp float pad2, pad3, pad4;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFPropertiesUBO {
|
||||
@@ -207,7 +209,7 @@ layout (std140) uniform LineSDFPropertiesUBO {
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
|
||||
highp vec2 pad1;
|
||||
highp vec2 pad5;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFInterpolationUBO {
|
||||
@@ -219,7 +221,7 @@ layout (std140) uniform LineSDFInterpolationUBO {
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
|
||||
highp float pad2;
|
||||
highp float pad6;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -5,11 +5,17 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
struct alignas(16) LineDynamicUBO {
|
||||
/* 0 */ std::array<float, 2> units_to_pixels;
|
||||
/* 8 */ float pad1, pad2;
|
||||
/* 16 */
|
||||
};
|
||||
static_assert(sizeof(LineDynamicUBO) == 16);
|
||||
|
||||
struct alignas(16) LineUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
static_assert(sizeof(LineUBO) % 16 == 0);
|
||||
|
||||
@@ -40,10 +46,8 @@ struct alignas(16) LinePatternUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 4> scale;
|
||||
std::array<float, 2> texsize;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float fade;
|
||||
float pad1, pad2;
|
||||
};
|
||||
static_assert(sizeof(LinePatternUBO) % 16 == 0);
|
||||
|
||||
@@ -59,7 +63,6 @@ static_assert(sizeof(LinePatternPropertiesUBO) % 16 == 0);
|
||||
|
||||
struct alignas(16) LineSDFUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
std::array<float, 2> patternscale_a;
|
||||
std::array<float, 2> patternscale_b;
|
||||
float ratio;
|
||||
@@ -67,7 +70,7 @@ struct alignas(16) LineSDFUBO {
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
static_assert(sizeof(LineSDFUBO) % 16 == 0);
|
||||
|
||||
@@ -83,7 +86,13 @@ struct alignas(16) LineSDFPropertiesUBO {
|
||||
};
|
||||
static_assert(sizeof(LineSDFPropertiesUBO) % 16 == 0);
|
||||
|
||||
using LineBasicUBO = LineUBO;
|
||||
struct alignas(16) LineBasicUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
std::array<float, 2> units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
};
|
||||
static_assert(sizeof(LineBasicUBO) % 16 == 0);
|
||||
|
||||
struct alignas(16) LineBasicPropertiesUBO {
|
||||
Color color;
|
||||
|
||||
@@ -54,11 +54,15 @@ float4 unpack_mix_color(const float4 packedColors, const float t) {
|
||||
decode_color(float2(packedColors[2], packedColors[3])), t);
|
||||
}
|
||||
|
||||
struct alignas(16) LineDynamicUBO {
|
||||
float2 units_to_pixels;
|
||||
float pad1, pad2;
|
||||
};
|
||||
|
||||
struct alignas(16) LineUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LineBasicUBO {
|
||||
@@ -70,9 +74,8 @@ struct alignas(16) LineBasicUBO {
|
||||
|
||||
struct alignas(16) LineGradientUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePropertiesUBO {
|
||||
|
||||
@@ -15,7 +15,7 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 8> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 0> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -61,9 +61,10 @@ struct FragmentStage {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineUBO& line [[buffer(8)]],
|
||||
device const LinePropertiesUBO& props [[buffer(9)]],
|
||||
device const LineInterpolationUBO& interp [[buffer(10)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(8)]],
|
||||
device const LineUBO& line [[buffer(9)]],
|
||||
device const LinePropertiesUBO& props [[buffer(10)]],
|
||||
device const LineInterpolationUBO& interp [[buffer(11)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -115,7 +116,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
const float extrude_length_without_perspective = length(dist);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -136,8 +137,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineUBO& line [[buffer(8)]],
|
||||
device const LinePropertiesUBO& props [[buffer(9)]]) {
|
||||
device const LineUBO& line [[buffer(9)]],
|
||||
device const LinePropertiesUBO& props [[buffer(10)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
#endif
|
||||
@@ -178,7 +179,7 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 9> attributes;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<UniformBlockInfo, 5> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -234,10 +235,8 @@ struct alignas(16) LinePatternUBO {
|
||||
float4x4 matrix;
|
||||
float4 scale;
|
||||
float2 texsize;
|
||||
float2 units_to_pixels;
|
||||
float ratio;
|
||||
float fade;
|
||||
float pad1, pad2;
|
||||
};
|
||||
|
||||
struct alignas(16) LinePatternPropertiesUBO {
|
||||
@@ -266,10 +265,11 @@ struct alignas(16) LinePatternTilePropertiesUBO {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LinePatternUBO& line [[buffer(9)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(10)]],
|
||||
device const LinePatternInterpolationUBO& interp [[buffer(11)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(12)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(9)]],
|
||||
device const LinePatternUBO& line [[buffer(10)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(11)]],
|
||||
device const LinePatternInterpolationUBO& interp [[buffer(12)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(13)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -323,7 +323,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
const float extrude_length_without_perspective = length(dist);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -348,9 +348,9 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LinePatternUBO& line [[buffer(9)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(10)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(12)]],
|
||||
device const LinePatternUBO& line [[buffer(10)]],
|
||||
device const LinePatternPropertiesUBO& props [[buffer(11)]],
|
||||
device const LinePatternTilePropertiesUBO& tileProps [[buffer(13)]],
|
||||
texture2d<float, access::sample> image0 [[texture(0)]],
|
||||
sampler image0_sampler [[sampler(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
@@ -430,7 +430,7 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 9> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -485,7 +485,6 @@ struct FragmentStage {
|
||||
|
||||
struct alignas(16) LineSDFUBO {
|
||||
float4x4 matrix;
|
||||
float2 units_to_pixels;
|
||||
float2 patternscale_a;
|
||||
float2 patternscale_b;
|
||||
float ratio;
|
||||
@@ -493,7 +492,7 @@ struct alignas(16) LineSDFUBO {
|
||||
float tex_y_b;
|
||||
float sdfgamma;
|
||||
float mix;
|
||||
float pad;
|
||||
float pad1, pad2, pad3;
|
||||
};
|
||||
|
||||
struct alignas(16) LineSDFPropertiesUBO {
|
||||
@@ -519,9 +518,10 @@ struct alignas(16) LineSDFInterpolationUBO {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineSDFUBO& line [[buffer(9)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(10)]],
|
||||
device const LineSDFInterpolationUBO& interp [[buffer(11)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(9)]],
|
||||
device const LineSDFUBO& line [[buffer(10)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(11)]],
|
||||
device const LineSDFInterpolationUBO& interp [[buffer(12)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_gapwidth)
|
||||
const auto gapwidth = props.gapwidth / 2;
|
||||
@@ -580,7 +580,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
const float extrude_length_without_perspective = length(dist);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -606,8 +606,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineSDFUBO& line [[buffer(9)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(10)]],
|
||||
device const LineSDFUBO& line [[buffer(10)]],
|
||||
device const LineSDFPropertiesUBO& props [[buffer(11)]],
|
||||
texture2d<float, access::sample> image0 [[texture(0)]],
|
||||
sampler image0_sampler [[sampler(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
|
||||
@@ -15,7 +15,7 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal> {
|
||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||
|
||||
static const std::array<AttributeInfo, 7> attributes;
|
||||
static const std::array<UniformBlockInfo, 3> uniforms;
|
||||
static const std::array<UniformBlockInfo, 4> uniforms;
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto source = R"(
|
||||
@@ -45,9 +45,10 @@ struct FragmentStage {
|
||||
};
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const LineGradientUBO& line [[buffer(7)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(8)]],
|
||||
device const LineGradientInterpolationUBO& interp [[buffer(9)]]) {
|
||||
device const LineDynamicUBO& dynamic [[buffer(7)]],
|
||||
device const LineGradientUBO& line [[buffer(8)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(9)]],
|
||||
device const LineGradientInterpolationUBO& interp [[buffer(10)]]) {
|
||||
|
||||
#if !defined(HAS_UNIFORM_u_blur)
|
||||
const auto blur = unpack_mix_float(vertx.blur, interp.blur_t);
|
||||
@@ -106,7 +107,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
const float extrude_length_without_perspective = length(dist);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels);
|
||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * dynamic.units_to_pixels);
|
||||
|
||||
return {
|
||||
.position = position,
|
||||
@@ -125,8 +126,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const LineGradientUBO& line [[buffer(7)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(8)]],
|
||||
device const LineGradientUBO& line [[buffer(8)]],
|
||||
device const LineGradientPropertiesUBO& props [[buffer(9)]],
|
||||
texture2d<float, access::sample> gradientTexture [[texture(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
|
||||
Reference in New Issue
Block a user