Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,35 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_colorTexCoords;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoords;
#endif
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 pos = vec4(a_position, 1) * u_modelView * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif
}

View file

@ -0,0 +1,40 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (location = 1) out float v_intensity;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
const vec4 kNormalizedLightDir = vec4(0.3162, 0.0, 0.9486, 0.0);
void main()
{
vec4 pos = vec4(a_position, 1.0) * u_modelView;
vec4 normal = vec4(a_position + a_normal, 1.0) * u_modelView;
normal.xyw = (normal * u_projection).xyw;
normal.z = normal.z * u_zScale;
pos.xyw = (pos * u_projection).xyw;
pos.z = a_position.z * u_zScale;
vec4 normDir = normal - pos;
if (dot(normDir, normDir) != 0.0)
v_intensity = max(0.0, -dot(kNormalizedLightDir, normalize(normDir)));
else
v_intensity = 0.0;
gl_Position = u_pivotTransform * pos;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,41 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_colorTexCoords;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoords;
#endif
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 pos = vec4(a_position, 1.0) * u_modelView;
pos.xyw = (pos * u_projection).xyw;
pos.z = a_position.z * u_zScale;
gl_Position = u_pivotTransform * pos;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif
}

View file

@ -0,0 +1,19 @@
layout (location = 0) in vec3 v_normal;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
const vec3 lightDir = vec3(0.316, 0.0, 0.948);
void main()
{
float phongDiffuse = max(0.0, -dot(lightDir, v_normal));
v_FragColor = vec4((phongDiffuse * 0.5 + 0.5) * u_color.rgb, u_color.a);
}

View file

@ -0,0 +1,23 @@
layout (location = 0) in vec3 a_pos;
layout (location = 1) in vec3 a_normal;
layout (location = 0) out vec3 v_normal;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
void main()
{
vec4 position = u_transform * vec4(a_pos, 1.0);
v_normal = normalize((u_normalTransform * vec4(a_normal, 0.0)).xyz);
gl_Position = position;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
}

View file

@ -0,0 +1,16 @@
layout (location = 0) in float v_intensity;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
void main()
{
v_FragColor = vec4(u_color.rgb, u_color.a * smoothstep(0.7, 1.0, v_intensity));
}

View file

@ -0,0 +1,16 @@
layout (location = 0) in float v_intensity;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
void main()
{
v_FragColor = vec4(u_color.rgb, u_color.a * v_intensity);
}

View file

@ -0,0 +1,23 @@
layout (location = 0) in vec3 a_pos;
layout (location = 1) in vec2 a_texCoords;
layout (location = 0) out float v_intensity;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
void main()
{
vec4 position = u_transform * vec4(a_pos, 1.0);
v_intensity = a_texCoords.x;
gl_Position = position;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
}

View file

@ -0,0 +1,23 @@
layout (location = 0) in vec3 v_normal;
layout (location = 1) in vec2 v_texCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
layout (binding = 1) uniform sampler2D u_colorTex;
const vec3 lightDir = vec3(0.316, 0.0, 0.948);
void main()
{
float phongDiffuse = max(0.0, -dot(lightDir, v_normal));
vec4 color = texture(u_colorTex, v_texCoords) * u_color;
v_FragColor = vec4((phongDiffuse * 0.5 + 0.5) * color.rgb, color.a);
}

View file

@ -0,0 +1,26 @@
layout (location = 0) in vec3 a_pos;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec2 a_texCoords;
layout (location = 0) out vec3 v_normal;
layout (location = 1) out vec2 v_texCoords;
layout (binding = 0) uniform UBO
{
mat4 u_transform;
mat4 u_normalTransform;
vec4 u_color;
vec2 u_texCoordFlipping;
};
void main()
{
vec4 position = u_transform * vec4(a_pos, 1.0);
v_normal = normalize((u_normalTransform * vec4(a_normal, 0.0)).xyz);
v_texCoords = mix(a_texCoords, 1.0 - a_texCoords, u_texCoordFlipping);
gl_Position = position;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
}

View file

@ -0,0 +1,37 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoords;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 2) in vec3 v_radius;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 finalColor = v_color;
#else
LOW_P vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
#endif
float smallRadius = v_radius.z - aaPixelsCount;
float stepValue = smoothstep(smallRadius * smallRadius, v_radius.z * v_radius.z,
v_radius.x * v_radius.x + v_radius.y * v_radius.y);
finalColor.a = finalColor.a * u_opacity * (1.0 - stepValue);
v_FragColor = finalColor;
}

View file

@ -0,0 +1,39 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoords;
#endif
layout (location = 2) out vec3 v_radius;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 p = vec4(a_position, 1) * u_modelView;
vec4 pos = vec4(a_normal.xy, 0, 0) + p;
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif
v_radius = a_normal;
}

View file

@ -0,0 +1,28 @@
layout (location = 0) in vec3 v_radius;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
const float kAntialiasingScalar = 0.9;
void main()
{
float d = dot(v_radius.xy, v_radius.xy);
vec4 finalColor = v_color;
float aaRadius = v_radius.z * kAntialiasingScalar;
float stepValue = smoothstep(aaRadius * aaRadius, v_radius.z * v_radius.z, d);
finalColor.a = finalColor.a * u_opacity * (1.0 - stepValue);
v_FragColor = finalColor;
}

View file

@ -0,0 +1,28 @@
layout (location = 0) in vec3 a_normal;
layout (location = 1) in vec3 a_position;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec3 v_radius;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec3 radius = a_normal * a_position.z;
vec4 pos = vec4(a_position.xy, 0, 1) * u_modelView;
vec4 shiftedPos = vec4(radius.xy, 0, 0) + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
v_radius = radius;
v_color = a_color;
}

View file

@ -0,0 +1,41 @@
layout (location = 0) in vec4 v_normal;
#ifdef ENABLE_VTF
layout (location = 1) in LOW_P vec4 v_color;
#else
layout (location = 2) in vec2 v_colorTexCoords;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoords);
#endif
float r1 = (v_normal.z - aaPixelsCount) * (v_normal.z - aaPixelsCount);
float r2 = v_normal.x * v_normal.x + v_normal.y * v_normal.y;
float r3 = v_normal.z * v_normal.z;
float alpha = mix(step(r3, r2), smoothstep(r1, r3, r2), v_normal.w);
LOW_P vec4 finalColor = color;
finalColor.a = finalColor.a * u_opacity * (1.0 - alpha);
if (finalColor.a == 0.0)
discard;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,39 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_colorTexCoords;
layout (location = 0) out vec4 v_normal;
#ifdef ENABLE_VTF
layout (location = 1) out LOW_P vec4 v_color;
#else
layout (location = 2) out vec2 v_colorTexCoords;
#endif
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 p = vec4(a_position, 1) * u_modelView;
vec4 pos = vec4(a_normal.xy + a_colorTexCoords.zw, 0, 0) + p;
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords.xy);
#else
v_colorTexCoords = a_colorTexCoords.xy;
#endif
v_normal = a_normal;
}

View file

@ -0,0 +1,39 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_colorTexCoords;
layout (location = 0) out vec4 v_normal;
#ifdef ENABLE_VTF
layout (location = 1) out LOW_P vec4 v_color;
#else
layout (location = 2) out vec2 v_colorTexCoords;
#endif
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 pivot = vec4(a_position.xyz, 1.0) * u_modelView;
vec4 offset = vec4(a_normal.xy + a_colorTexCoords.zw, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform, 0.0, offset.xy);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords.xy);
#else
v_colorTexCoords = a_colorTexCoords.xy;
#endif
v_normal = a_normal;
}

View file

@ -0,0 +1,35 @@
layout (location = 0) in vec2 v_colorTexCoord;
layout (location = 1) in vec2 v_maskTexCoord;
//layout (location = 2) in vec2 v_halfLength;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
layout (binding = 2) uniform sampler2D u_maskTex;
//const float aaPixelsCount = 2.5;
void main()
{
vec4 color = texture(u_colorTex, v_colorTexCoord);
float mask = texture(u_maskTex, v_maskTexCoord).r;
color.a = color.a * mask * u_opacity;
// Disabled too agressive AA-like blurring of edges,
// see https://github.com/organicmaps/organicmaps/issues/6583.
//float currentW = abs(v_halfLength.x);
//float diff = v_halfLength.y - currentW;
//color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0));
v_FragColor = color;
}

View file

@ -0,0 +1,38 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec2 a_colorTexCoord;
layout (location = 3) in vec4 a_maskTexCoord;
layout (location = 0) out vec2 v_colorTexCoord;
layout (location = 1) out vec2 v_maskTexCoord;
//layout (location = 2) out vec2 v_halfLength;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec2 normal = a_normal.xy;
float halfWidth = length(normal);
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (halfWidth != 0.0)
{
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + normal,
u_modelView, halfWidth);
}
float uOffset = min(length(vec4(kShapeCoordScalar, 0, 0, 0) * u_modelView) * a_maskTexCoord.x, 1.0);
v_colorTexCoord = a_colorTexCoord;
v_maskTexCoord = vec2(a_maskTexCoord.y + uOffset * a_maskTexCoord.z, a_maskTexCoord.w);
//v_halfLength = vec2(sign(a_normal.z) * halfWidth, abs(a_normal.z));
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,11 @@
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
vec4 u_color;
};
void main()
{
v_FragColor = u_color;
}

View file

@ -0,0 +1,10 @@
layout (location = 0) in vec2 a_position;
void main()
{
gl_Position = vec4(a_position, 0, 1);
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
}

View file

@ -0,0 +1,35 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoords;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 2) in vec2 v_maskTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 2) uniform sampler2D u_maskTex;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoords);
#endif
color *= texture(u_maskTex, v_maskTexCoords);
color.a *= u_opacity;
v_FragColor = color;
}

View file

@ -0,0 +1,38 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_colorTexCoords;
layout (location = 2) in vec2 a_maskTexCoords;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoords;
#endif
layout (location = 2) out vec2 v_maskTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 pos = vec4(a_position, 1) * u_modelView * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif
v_maskTexCoords = a_maskTexCoords;
}

View file

@ -0,0 +1,12 @@
layout (location = 0) in vec2 v_texCoords;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
LOW_P vec4 color = texture(u_colorTex, v_texCoords);
v_FragColor = color * v_color;
}

View file

@ -0,0 +1,22 @@
layout (location = 0) in vec2 a_position;
layout (location = 1) in vec2 a_texCoords;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec2 v_texCoords;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_projection;
};
void main()
{
v_texCoords = a_texCoords;
v_color = a_color;
gl_Position = vec4(a_position, 0, 1) * u_projection;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
}

View file

@ -0,0 +1,39 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoord;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
//layout (location = 2) in vec2 v_halfLength;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
//const float aaPixelsCount = 2.5;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoord);
#endif
color.a *= u_opacity;
// Disabled too agressive AA-like blurring of edges,
// see https://github.com/organicmaps/organicmaps/issues/6583.
//float currentW = abs(v_halfLength.x);
//float diff = v_halfLength.y - currentW;
//color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0));
v_FragColor = color;
}

View file

@ -0,0 +1,47 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec2 a_colorTexCoord;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
//layout (location = 2) out vec2 v_halfLength;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec2 normal = a_normal.xy;
float halfWidth = length(normal);
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (halfWidth != 0.0)
{
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + normal,
u_modelView, halfWidth);
}
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif
//v_halfLength = vec2(sign(a_normal.z) * halfWidth, abs(a_normal.z));
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,26 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 1) in vec2 v_maskTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
layout (binding = 2) uniform sampler2D u_maskTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords) * texture(u_maskTex, v_maskTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,28 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 3) in vec2 a_maskTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (location = 1) out vec2 v_maskTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec4 pos = vec4(a_position.xyz, 1) * u_modelView;
vec4 shiftedPos = vec4(a_normal, 0, 0) + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
v_colorTexCoords = a_colorTexCoords;
v_maskTexCoords = a_maskTexCoords;
}

View file

@ -0,0 +1,29 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 3) in vec2 a_maskTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (location = 1) out vec2 v_maskTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec4 pivot = vec4(a_position.xyz, 1.0) * u_modelView;
vec4 offset = vec4(a_normal, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform,
a_position.w * u_zScale, offset.xy);
v_colorTexCoords = a_colorTexCoords;
v_maskTexCoords = a_maskTexCoords;
}

View file

@ -0,0 +1,33 @@
layout (location = 0) in vec2 a_normal;
layout (location = 1) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_position;
vec2 u_lineParams;
float u_accuracy;
float u_zScale;
float u_opacity;
float u_azimut;
};
void main()
{
float sinV = sin(u_azimut);
float cosV = cos(u_azimut);
mat4 rotation;
rotation[0] = vec4(cosV, sinV, 0.0, 0.0);
rotation[1] = vec4(-sinV, cosV, 0.0, 0.0);
rotation[2] = vec4(0.0, 0.0, 1.0, 0.0);
rotation[3] = vec4(0.0, 0.0, 0.0, 1.0);
vec4 pos = vec4(u_position.xyz, 1.0) * u_modelView;
vec4 normal = vec4(a_normal, 0, 0);
vec4 shiftedPos = normal * rotation + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,30 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec4 pos = vec4(a_position.xyz, 1) * u_modelView;
float normalLen = length(a_normal);
vec4 n = vec4(a_position.xy + a_normal * kShapeCoordScalar, 0.0, 0.0) * u_modelView;
vec4 norm = vec4(0.0, 0.0, 0.0, 0.0);
if (dot(n, n) != 0.0)
norm = normalize(n) * normalLen;
vec4 shiftedPos = norm + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,26 @@
layout (location = 0) in vec2 a_normal;
layout (location = 1) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_position;
vec2 u_lineParams;
float u_accuracy;
float u_zScale;
float u_opacity;
float u_azimut;
};
void main()
{
vec4 position = vec4(u_position.xy, 0.0, 1.0) * u_modelView;
vec4 normal = vec4(a_normal * u_accuracy, 0.0, 0.0);
position = (position + normal) * u_projection;
gl_Position = applyPivotTransform(position, u_pivotTransform, u_position.z * u_zScale);
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,47 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec3 v_length;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
const float kAntialiasingThreshold = 0.92;
const float kOutlineThreshold1 = 0.81;
const float kOutlineThreshold2 = 0.71;
void main()
{
if (v_length.x < v_length.z)
discard;
vec2 coefs = step(v_length.xx, u_fakeBorders);
coefs.y = 1.0 - coefs.y;
vec4 mainColor = mix(u_color, u_fakeColor, coefs.x);
mainColor = mix(mainColor, u_fakeColor, coefs.y);
vec4 mainOutlineColor = mix(u_outlineColor, u_fakeOutlineColor, coefs.x);
mainOutlineColor = mix(mainOutlineColor, u_fakeOutlineColor, coefs.y);
vec4 color = mix(mix(mainColor, vec4(v_color.rgb, 1.0), v_color.a), mainColor, step(u_routeParams.w, 0.0));
color = mix(color, mainOutlineColor, step(kOutlineThreshold1, abs(v_length.y)));
color = mix(color, mainOutlineColor, smoothstep(kOutlineThreshold2, kOutlineThreshold1, abs(v_length.y)));
color.a *= (1.0 - smoothstep(kAntialiasingThreshold, 1.0, abs(v_length.y)));
color = vec4(mix(color.rgb, u_maskColor.rgb, u_maskColor.a), color.a);
v_FragColor = color;
}

View file

@ -0,0 +1,43 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec3 a_length;
layout (location = 3) in vec4 a_color;
layout (location = 0) out vec3 v_length;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
void main()
{
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
vec2 len = vec2(a_length.x, a_length.z);
if (dot(a_normal, a_normal) != 0.0)
{
vec2 norm = a_normal * u_routeParams.x;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
if (u_routeParams.y != 0.0)
len = vec2(a_length.x + a_length.y * u_routeParams.y, a_length.z);
}
v_length = vec3(len, u_routeParams.z);
v_color = a_color;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,36 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
if (finalColor.a < 0.01)
discard;
finalColor = vec4(mix(finalColor.rgb, u_maskColor.rgb, u_maskColor.a), finalColor.a);
v_FragColor = finalColor;
}

View file

@ -0,0 +1,37 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
void main()
{
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (dot(a_normal, a_normal) != 0.0)
{
vec2 norm = a_normal * u_arrowHalfWidth;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
}
v_colorTexCoords = a_colorTexCoords;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,49 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec3 v_length;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
const float kAntialiasingThreshold = 0.92;
float alphaFromPattern(float curLen, float dashLen, float gapLen)
{
float len = dashLen + gapLen;
float offset = fract(curLen / len) * len;
return step(offset, dashLen);
}
void main()
{
if (v_length.x < v_length.z)
discard;
vec2 coefs = step(v_length.xx, u_fakeBorders);
coefs.y = 1.0 - coefs.y;
vec4 mainColor = mix(u_color, u_fakeColor, coefs.x);
mainColor = mix(mainColor, u_fakeColor, coefs.y);
vec4 color = mainColor + v_color;
color.a *= (1.0 - smoothstep(kAntialiasingThreshold, 1.0, abs(v_length.y))) *
alphaFromPattern(v_length.x, u_pattern.x, u_pattern.y);
color = vec4(mix(color.rgb, u_maskColor.rgb, u_maskColor.a), color.a);
v_FragColor = color;
}

View file

@ -0,0 +1,40 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec4 v_radius;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
const float kAntialiasingPixelsCount = 2.5;
void main()
{
vec4 finalColor = v_color;
float aaRadius = max(v_radius.z - kAntialiasingPixelsCount, 0.0);
float stepValue = smoothstep(aaRadius * aaRadius, v_radius.z * v_radius.z,
dot(v_radius.xy, v_radius.xy));
finalColor.a = finalColor.a * u_opacity * (1.0 - stepValue);
if (finalColor.a < 0.01 || u_routeParams.y > v_radius.w)
discard;
finalColor = vec4(mix(finalColor.rgb, u_maskColor.rgb, u_maskColor.a), finalColor.a);
v_FragColor = finalColor;
}

View file

@ -0,0 +1,38 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec3 a_normal;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec4 v_radius;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_routeParams;
vec4 u_color;
vec4 u_maskColor;
vec4 u_outlineColor;
vec4 u_fakeColor;
vec4 u_fakeOutlineColor;
vec2 u_fakeBorders;
vec2 u_pattern;
vec2 u_angleCosSin;
float u_arrowHalfWidth;
float u_opacity;
};
void main()
{
float r = u_routeParams.x * a_normal.z;
vec2 normal = vec2(a_normal.x * u_angleCosSin.x - a_normal.y * u_angleCosSin.y,
a_normal.x * u_angleCosSin.y + a_normal.y * u_angleCosSin.x);
vec4 radius = vec4(normal.xy * r, r, a_position.w);
vec4 pos = vec4(a_position.xy, 0, 1) * u_modelView;
vec2 shiftedPos = radius.xy + pos.xy;
pos = vec4(shiftedPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
v_radius = radius;
v_color = a_color;
}

View file

@ -0,0 +1,23 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,26 @@
layout (location = 0) in vec2 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
void main()
{
gl_Position = vec4(u_position + a_position + u_length * a_normal, 0, 1) * u_projection;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,17 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
float u_opacity;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,10 @@
layout (location = 0) in vec2 a_pos;
layout (location = 1) in vec2 a_tcoord;
layout (location = 0) out vec2 v_colorTexCoords;
void main()
{
v_colorTexCoords = a_tcoord;
gl_Position = vec4(a_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,36 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoord;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 2) in float v_lengthY;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_position;
vec2 u_lineParams;
float u_accuracy;
float u_zScale;
float u_opacity;
float u_azimut;
};
const float kAntialiasingThreshold = 0.92;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoord);
#endif
color.a *= u_opacity;
color.a *= (1.0 - smoothstep(kAntialiasingThreshold, 1.0, abs(v_lengthY)));
v_FragColor = color;
}

View file

@ -0,0 +1,52 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 3) in vec3 a_length;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out float v_lengthY;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_position;
vec2 u_lineParams;
float u_accuracy;
float u_zScale;
float u_opacity;
float u_azimut;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
const float kAntialiasingThreshold = 0.92;
void main()
{
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
vec2 len = vec2(a_length.x, a_length.z);
if (dot(a_normal, a_normal) != 0.0)
{
vec2 norm = a_normal * u_lineParams.x;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
if (u_lineParams.y != 0.0)
len = vec2(a_length.x + a_length.y * u_lineParams.y, a_length.z);
}
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoord = a_colorTexCoords;
#endif
v_lengthY = len.y;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,56 @@
ColoredSymbol colored_symbol.vsh.glsl colored_symbol.fsh.glsl
Texturing texturing.vsh.glsl texturing.fsh.glsl
MaskedTexturing masked_texturing.vsh.glsl masked_texturing.fsh.glsl
Bookmark user_mark.vsh.glsl user_mark.fsh.glsl
BookmarkAnim user_mark.vsh.glsl user_mark.fsh.glsl
TextOutlined text_outlined.vsh.glsl text.fsh.glsl
Text text.vsh.glsl text.fsh.glsl
TextStaticOutlinedGui text_outlined_gui.vsh.glsl text_outlined_gui.fsh.glsl
TextOutlinedGui text_outlined_gui.vsh.glsl text_outlined_gui.fsh.glsl
Area area.vsh.glsl solid_color.fsh.glsl
AreaOutline area.vsh.glsl solid_color.fsh.glsl
Area3d area3d.vsh.glsl texturing3d.fsh.glsl
Area3dOutline area3d_outline.vsh.glsl solid_color.fsh.glsl
Line line.vsh.glsl line.fsh.glsl
TransitCircle transit_circle.vsh.glsl transit_circle.fsh.glsl
DashedLine dashed_line.vsh.glsl dashed_line.fsh.glsl
PathSymbol path_symbol.vsh.glsl texturing.fsh.glsl
TransparentArea area.vsh.glsl solid_color.fsh.glsl
CapJoin circle.vsh.glsl circle.fsh.glsl
HatchingArea hatching_area.vsh.glsl hatching_area.fsh.glsl
TexturingGui texturing_gui.vsh.glsl texturing_gui.fsh.glsl
Ruler ruler.vsh.glsl ruler.fsh.glsl
Accuracy position_accuracy3d.vsh.glsl texturing_position.fsh.glsl
MyPosition my_position.vsh.glsl texturing_position.fsh.glsl
SelectionLine selection_line.vsh.glsl selection_line.fsh.glsl
Transit transit.vsh.glsl transit.fsh.glsl
TransitMarker transit_marker.vsh.glsl transit_marker.fsh.glsl
Route route.vsh.glsl route.fsh.glsl
RouteDash route.vsh.glsl route_dash.fsh.glsl
RouteArrow route_arrow.vsh.glsl route_arrow.fsh.glsl
RouteMarker route_marker.vsh.glsl route_marker.fsh.glsl
CirclePoint circle_point.vsh.glsl circle_point.fsh.glsl
BookmarkAboveText user_mark.vsh.glsl user_mark.fsh.glsl
BookmarkAnimAboveText user_mark.vsh.glsl user_mark.fsh.glsl
DebugRect debug_rect.vsh.glsl debug_rect.fsh.glsl
ScreenQuad screen_quad.vsh.glsl screen_quad.fsh.glsl
Arrow3d arrow3d.vsh.glsl arrow3d.fsh.glsl
Arrow3dTextured arrow3d_textured.vsh.glsl arrow3d_textured.fsh.glsl
Arrow3dShadow arrow3d_shadow.vsh.glsl arrow3d_shadow.fsh.glsl
Arrow3dOutline arrow3d_shadow.vsh.glsl arrow3d_outline.fsh.glsl
ColoredSymbolBillboard colored_symbol_billboard.vsh.glsl colored_symbol.fsh.glsl
TexturingBillboard texturing_billboard.vsh.glsl texturing.fsh.glsl
MaskedTexturingBillboard masked_texturing_billboard.vsh.glsl masked_texturing.fsh.glsl
BookmarkBillboard user_mark_billboard.vsh.glsl user_mark.fsh.glsl
BookmarkAnimBillboard user_mark_billboard.vsh.glsl user_mark.fsh.glsl
BookmarkAboveTextBillboard user_mark_billboard.vsh.glsl user_mark.fsh.glsl
BookmarkAnimAboveTextBillboard user_mark_billboard.vsh.glsl user_mark.fsh.glsl
TextOutlinedBillboard text_outlined_billboard.vsh.glsl text.fsh.glsl
TextBillboard text_billboard.vsh.glsl text.fsh.glsl
Traffic traffic.vsh.glsl traffic.fsh.glsl
TrafficLine traffic_line.vsh.glsl traffic_line.fsh.glsl
TrafficCircle traffic_circle.vsh.glsl traffic_circle.fsh.glsl
SmaaEdges smaa_edges.vsh.glsl smaa_edges.fsh.glsl
SmaaBlendingWeight smaa_blending_weight.vsh.glsl smaa_blending_weight.fsh.glsl
SmaaFinal smaa_final.vsh.glsl smaa_final.fsh.glsl
ImGui imgui.vsh.glsl imgui.fsh.glsl

View file

@ -0,0 +1,49 @@
// This is a library of functions which we are use in our shaders.
// Common (DO NOT modify this comment, it marks up block of common functions).
// Scale factor in shape's coordinates transformation from tile's coordinate
// system.
const float kShapeCoordScalar = 1000.0;
// VS (DO NOT modify this comment, it marks up block of vertex shader functions).
// This function applies a 2D->3D transformation matrix |pivotTransform| to |pivot|.
vec4 applyPivotTransform(vec4 pivot, mat4 pivotTransform, float pivotRealZ)
{
vec4 transformedPivot = pivot;
float w = transformedPivot.w;
transformedPivot.xyw = (pivotTransform * vec4(transformedPivot.xy, pivotRealZ, w)).xyw;
transformedPivot.z *= transformedPivot.w / w;
#ifdef VULKAN
transformedPivot.y = -transformedPivot.y;
transformedPivot.z = (transformedPivot.z + transformedPivot.w) / 2.0;
#endif
return transformedPivot;
}
// This function applies a 2D->3D transformation matrix to billboards.
vec4 applyBillboardPivotTransform(vec4 pivot, mat4 pivotTransform, float pivotRealZ, vec2 offset)
{
float logicZ = pivot.z / pivot.w;
vec4 transformedPivot = pivotTransform * vec4(pivot.xy, pivotRealZ, pivot.w);
vec4 scale = pivotTransform * vec4(1.0, -1.0, 0.0, 1.0);
vec4 position = vec4(transformedPivot.xy / transformedPivot.w, logicZ, 1.0) + vec4(offset / scale.w * scale.x, 0.0, 0.0);
#ifdef VULKAN
position.y = -position.y;
position.z = (position.z + position.w) / 2.0;
#endif
return position;
}
// This function calculates transformed position on an axis for line shaders family.
vec2 calcLineTransformedAxisPos(vec2 originalAxisPos, vec2 shiftedPos, mat4 modelView, float halfWidth)
{
vec2 p = (vec4(shiftedPos, 0.0, 1.0) * modelView).xy;
vec2 d = p - originalAxisPos;
if (dot(d, d) != 0.0)
return originalAxisPos + normalize(d) * halfWidth;
else
return originalAxisPos;
}
// FS (DO NOT modify this comment, it marks up block of fragment shader functions).

View file

@ -0,0 +1,160 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec4 v_coords;
layout (location = 1) in vec4 v_offset0;
layout (location = 2) in vec4 v_offset1;
layout (location = 3) in vec4 v_offset2;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
vec4 u_framebufferMetrics;
};
layout (binding = 1) uniform sampler2D u_colorTex;
layout (binding = 2) uniform sampler2D u_smaaArea;
layout (binding = 3) uniform sampler2D u_smaaSearch;
#define SMAA_SEARCHTEX_SIZE vec2(66.0, 33.0)
#define SMAA_SEARCHTEX_PACKED_SIZE vec2(64.0, 16.0)
#define SMAA_AREATEX_MAX_DISTANCE 16.0
#define SMAA_AREATEX_PIXEL_SIZE (vec2(1.0 / 256.0, 1.0 / 1024.0))
#define SMAALoopBegin(condition) while (condition) {
#define SMAALoopEnd }
#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset)
#define SMAARound(v) round((v))
#define SMAAOffset(x,y) ivec2(x,y)
const vec2 kAreaTexMaxDistance = vec2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE);
const float kActivationThreshold = 0.8281;
float SMAASearchLength(vec2 e, float offset)
{
// The texture is flipped vertically, with left and right cases taking half
// of the space horizontally.
vec2 scale = SMAA_SEARCHTEX_SIZE * vec2(0.5, -1.0);
vec2 bias = SMAA_SEARCHTEX_SIZE * vec2(offset, 1.0);
// Scale and bias to access texel centers.
scale += vec2(-1.0, 1.0);
bias += vec2( 0.5, -0.5);
// Convert from pixel coordinates to texcoords.
// (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped).
scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
// Lookup the search texture.
return SMAASampleLevelZero(u_smaaSearch, scale * e + bias).r;
}
float SMAASearchXLeft(vec2 texcoord, float end)
{
vec2 e = vec2(0.0, 1.0);
SMAALoopBegin(texcoord.x > end && e.g > kActivationThreshold && e.r == 0.0)
e = SMAASampleLevelZero(u_colorTex, texcoord).rg;
texcoord = vec2(-2.0, 0.0) * u_framebufferMetrics.xy + texcoord;
SMAALoopEnd
float offset = 3.25 - (255.0 / 127.0) * SMAASearchLength(e, 0.0);
return u_framebufferMetrics.x * offset + texcoord.x;
}
float SMAASearchXRight(vec2 texcoord, float end)
{
vec2 e = vec2(0.0, 1.0);
SMAALoopBegin(texcoord.x < end && e.g > kActivationThreshold && e.r == 0.0)
e = SMAASampleLevelZero(u_colorTex, texcoord).rg;
texcoord = vec2(2.0, 0.0) * u_framebufferMetrics.xy + texcoord;
SMAALoopEnd
float offset = 3.25 - (255.0 / 127.0) * SMAASearchLength(e, 0.5);
return -u_framebufferMetrics.x * offset + texcoord.x;
}
float SMAASearchYUp(vec2 texcoord, float end)
{
vec2 e = vec2(1.0, 0.0);
SMAALoopBegin(texcoord.y > end && e.r > kActivationThreshold && e.g == 0.0)
e = SMAASampleLevelZero(u_colorTex, texcoord).rg;
texcoord = vec2(0.0, -2.0) * u_framebufferMetrics.xy + texcoord;
SMAALoopEnd
float offset = 3.25 - (255.0 / 127.0) * SMAASearchLength(e.gr, 0.0);
return u_framebufferMetrics.y * offset + texcoord.y;
}
float SMAASearchYDown(vec2 texcoord, float end)
{
vec2 e = vec2(1.0, 0.0);
SMAALoopBegin(texcoord.y < end && e.r > kActivationThreshold && e.g == 0.0)
e = SMAASampleLevelZero(u_colorTex, texcoord).rg;
texcoord = vec2(0.0, 2.0) * u_framebufferMetrics.xy + texcoord;
SMAALoopEnd
float offset = 3.25 - (255.0 / 127.0) * SMAASearchLength(e.gr, 0.5);
return -u_framebufferMetrics.y * offset + texcoord.y;
}
// Here, we have the distance and both crossing edges. So, what are the areas
// at each side of current edge?
vec2 SMAAArea(vec2 dist, float e1, float e2)
{
// Rounding prevents precision errors of bilinear filtering.
vec2 texcoord = kAreaTexMaxDistance * SMAARound(4.0 * vec2(e1, e2)) + dist;
// We do a scale and bias for mapping to texel space.
texcoord = SMAA_AREATEX_PIXEL_SIZE * (texcoord + 0.5);
return SMAASampleLevelZero(u_smaaArea, texcoord).rg;
}
void main()
{
vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);
vec2 e = texture(u_colorTex, v_coords.xy).rg;
if (e.g > 0.0) // Edge at north
{
vec2 d;
// Find the distance to the left.
vec3 coords;
coords.x = SMAASearchXLeft(v_offset0.xy, v_offset2.x);
coords.y = v_offset1.y;
d.x = coords.x;
// Now fetch the left crossing edges, two at a time using bilinear
// filtering. Sampling at -0.25 enables to discern what value each edge has.
float e1 = SMAASampleLevelZero(u_colorTex, coords.xy).r;
// Find the distance to the right.
coords.z = SMAASearchXRight(v_offset0.zw, v_offset2.y);
d.y = coords.z;
// We want the distances to be in pixel units (doing this here allow to
// better interleave arithmetic and memory accesses).
vec2 zz = u_framebufferMetrics.zz;
d = abs(SMAARound(zz * d - v_coords.zz));
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically.
vec2 sqrt_d = sqrt(d);
// Fetch the right crossing edges.
float e2 = SMAASampleLevelZeroOffset(u_colorTex, coords.zy, SMAAOffset(1, 0)).r;
// Here we know how this pattern looks like, now it is time for getting
// the actual area.
weights.rg = SMAAArea(sqrt_d, e1, e2);
}
if (e.r > 0.0) // Edge at west
{
vec2 d;
// Find the distance to the top.
vec3 coords;
coords.y = SMAASearchYUp(v_offset1.xy, v_offset2.z);
coords.x = v_offset0.x;
d.x = coords.y;
// Fetch the top crossing edges.
float e1 = SMAASampleLevelZero(u_colorTex, coords.xy).g;
// Find the distance to the bottom.
coords.z = SMAASearchYDown(v_offset1.zw, v_offset2.w);
d.y = coords.z;
// We want the distances to be in pixel units.
vec2 ww = u_framebufferMetrics.ww;
d = abs(SMAARound(ww * d - v_coords.ww));
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically.
vec2 sqrt_d = sqrt(d);
// Fetch the bottom crossing edges.
float e2 = SMAASampleLevelZeroOffset(u_colorTex, coords.xz, SMAAOffset(0, 1)).g;
// Get the area for this direction.
weights.ba = SMAAArea(sqrt_d, e1, e2);
}
v_FragColor = weights;
}

View file

@ -0,0 +1,30 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec2 a_pos;
layout (location = 1) in vec2 a_tcoord;
layout (location = 0) out vec4 v_coords;
layout (location = 1) out vec4 v_offset0;
layout (location = 2) out vec4 v_offset1;
layout (location = 3) out vec4 v_offset2;
layout (binding = 0) uniform UBO
{
vec4 u_framebufferMetrics;
};
// SMAA_MAX_SEARCH_STEPS specifies the maximum steps performed in the
// horizontal/vertical pattern searches, at each side of the pixel.
#define SMAA_MAX_SEARCH_STEPS 8.0
const vec4 kMaxSearchSteps = vec4(-2.0 * SMAA_MAX_SEARCH_STEPS, 2.0 * SMAA_MAX_SEARCH_STEPS,
-2.0 * SMAA_MAX_SEARCH_STEPS, 2.0 * SMAA_MAX_SEARCH_STEPS);
void main()
{
v_coords = vec4(a_tcoord, a_tcoord * u_framebufferMetrics.zw);
// We will use these offsets for the searches.
v_offset0 = u_framebufferMetrics.xyxy * vec4(-0.25, -0.125, 1.25, -0.125) + a_tcoord.xyxy;
v_offset1 = u_framebufferMetrics.xyxy * vec4(-0.125, -0.25, -0.125, 1.25) + a_tcoord.xyxy;
// And these for the searches, they indicate the ends of the loops.
v_offset2 = u_framebufferMetrics.xxyy * kMaxSearchSteps + vec4(v_offset0.xz, v_offset1.yw);
gl_Position = vec4(a_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,58 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 1) in vec4 v_offset0;
layout (location = 2) in vec4 v_offset1;
layout (location = 3) in vec4 v_offset2;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 1) uniform sampler2D u_colorTex;
// SMAA_THRESHOLD specifies the threshold or sensitivity to edges.
// Lowering this value you will be able to detect more edges at the expense of
// performance.
// Range: [0, 0.5]
// 0.1 is a reasonable value, and allows to catch most visible edges.
// 0.05 is a rather overkill value, that allows to catch 'em all.
#define SMAA_THRESHOLD 0.05
const vec2 kThreshold = vec2(SMAA_THRESHOLD, SMAA_THRESHOLD);
// If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times
// bigger contrast than current edge, current edge will be discarded.
// This allows to eliminate spurious crossing edges, and is based on the fact
// that, if there is too much contrast in a direction, that will hide
// perceptually contrast in the other neighbors.
#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0
// Standard relative luminance weights.
// https://en.wikipedia.org/wiki/Relative_luminance
const vec3 kWeights = vec3(0.2126, 0.7152, 0.0722);
void main()
{
// Calculate lumas.
float L = dot(texture(u_colorTex, v_colorTexCoords).rgb, kWeights);
float Lleft = dot(texture(u_colorTex, v_offset0.xy).rgb, kWeights);
float Ltop = dot(texture(u_colorTex, v_offset0.zw).rgb, kWeights);
// We do the usual threshold.
vec4 delta;
delta.xy = abs(L - vec2(Lleft, Ltop));
vec2 edges = step(kThreshold, delta.xy);
if (dot(edges, vec2(1.0, 1.0)) == 0.0)
discard;
// Calculate right and bottom deltas.
float Lright = dot(texture(u_colorTex, v_offset1.xy).rgb, kWeights);
float Lbottom = dot(texture(u_colorTex, v_offset1.zw).rgb, kWeights);
delta.zw = abs(L - vec2(Lright, Lbottom));
// Calculate the maximum delta in the direct neighborhood.
vec2 maxDelta = max(delta.xy, delta.zw);
// Calculate left-left and top-top deltas.
float Lleftleft = dot(texture(u_colorTex, v_offset2.xy).rgb, kWeights);
float Ltoptop = dot(texture(u_colorTex, v_offset2.zw).rgb, kWeights);
delta.zw = abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop));
// Calculate the final maximum delta.
maxDelta = max(maxDelta.xy, delta.zw);
float finalDelta = max(maxDelta.x, maxDelta.y);
// Local contrast adaptation
edges *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
v_FragColor = vec4(edges, 0.0, 1.0);
}

View file

@ -0,0 +1,22 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec2 a_pos;
layout (location = 1) in vec2 a_tcoord;
layout (location = 0) out vec2 v_colorTexCoords;
layout (location = 1) out vec4 v_offset0;
layout (location = 2) out vec4 v_offset1;
layout (location = 3) out vec4 v_offset2;
layout (binding = 0) uniform UBO
{
vec4 u_framebufferMetrics;
};
void main()
{
v_colorTexCoords = a_tcoord;
v_offset0 = u_framebufferMetrics.xyxy * vec4(-1.0, 0.0, 0.0, -1.0) + a_tcoord.xyxy;
v_offset1 = u_framebufferMetrics.xyxy * vec4( 1.0, 0.0, 0.0, 1.0) + a_tcoord.xyxy;
v_offset2 = u_framebufferMetrics.xyxy * vec4(-2.0, 0.0, 0.0, -2.0) + a_tcoord.xyxy;
gl_Position = vec4(a_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,49 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 1) in vec4 v_offset;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
vec4 u_framebufferMetrics;
};
layout (binding = 1) uniform sampler2D u_colorTex;
layout (binding = 2) uniform sampler2D u_blendingWeightTex;
#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
void main()
{
// Fetch the blending weights for current pixel.
vec4 a;
a.x = texture(u_blendingWeightTex, v_offset.xy).a; // Right
a.y = texture(u_blendingWeightTex, v_offset.zw).g; // Top
a.wz = texture(u_blendingWeightTex, v_colorTexCoords).xz; // Bottom / Left
// Is there any blending weight with a value greater than 0.0?
if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5)
{
v_FragColor = texture(u_colorTex, v_colorTexCoords);
}
else
{
// Calculate the blending offsets.
vec4 blendingOffset = vec4(0.0, a.y, 0.0, a.w);
vec2 blendingWeight = a.yw;
if (max(a.x, a.z) > max(a.y, a.w))
{
blendingOffset = vec4(a.x, 0.0, a.z, 0.0);
blendingWeight = a.xz;
}
blendingWeight /= dot(blendingWeight, vec2(1.0, 1.0));
// Calculate the texture coordinates.
vec4 bc = blendingOffset * vec4(u_framebufferMetrics.xy, -u_framebufferMetrics.xy);
bc += v_colorTexCoords.xyxy;
// We exploit bilinear filtering to mix current pixel with the chosen neighbor.
vec4 color = blendingWeight.x * SMAASampleLevelZero(u_colorTex, bc.xy);
color += blendingWeight.y * SMAASampleLevelZero(u_colorTex, bc.zw);
v_FragColor = color;
}
}

View file

@ -0,0 +1,18 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
layout (location = 0) in vec2 a_pos;
layout (location = 1) in vec2 a_tcoord;
layout (location = 0) out vec2 v_colorTexCoords;
layout (location = 1) out vec4 v_offset;
layout (binding = 0) uniform UBO
{
vec4 u_framebufferMetrics;
};
void main()
{
v_colorTexCoords = a_tcoord;
v_offset = u_framebufferMetrics.xyxy * vec4(1.0, 0.0, 0.0, 1.0) + a_tcoord.xyxy;
gl_Position = vec4(a_pos, 0.0, 1.0);
}

View file

@ -0,0 +1,31 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoords;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 finalColor = v_color;
#else
LOW_P vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
#endif
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,36 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoord;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 2) in vec2 v_maskTexCoord;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 2) uniform sampler2D u_maskTex;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 glyphColor = v_color;
#else
LOW_P vec4 glyphColor = texture(u_colorTex, v_colorTexCoord);
#endif
float dist = texture(u_maskTex, v_maskTexCoord).r;
float alpha = smoothstep(u_contrastGamma.x - u_contrastGamma.y, u_contrastGamma.x + u_contrastGamma.y, dist) * u_opacity;
glyphColor.a *= alpha;
v_FragColor = glyphColor;
}

View file

@ -0,0 +1,40 @@
layout (location = 0) in vec2 a_colorTexCoord;
layout (location = 1) in vec2 a_maskTexCoord;
layout (location = 2) in vec4 a_position;
layout (location = 3) in vec2 a_normal;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out vec2 v_maskTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
void main()
{
vec4 pos = vec4(a_position.xyz, 1) * u_modelView;
vec4 shiftedPos = vec4(a_normal, 0.0, 0.0) + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif
v_maskTexCoord = a_maskTexCoord;
}

View file

@ -0,0 +1,39 @@
layout (location = 0) in vec2 a_colorTexCoord;
layout (location = 1) in vec2 a_maskTexCoord;
layout (location = 2) in vec4 a_position;
layout (location = 3) in vec2 a_normal;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out vec2 v_maskTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 pivot = vec4(a_position.xyz, 1.0) * u_modelView;
vec4 offset = vec4(a_normal, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform,
a_position.w * u_zScale, offset.xy);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif
v_maskTexCoord = a_maskTexCoord;
}

View file

@ -0,0 +1,47 @@
layout (location = 0) in vec2 a_colorTexCoord;
layout (location = 1) in vec2 a_outlineColorTexCoord;
layout (location = 2) in vec2 a_maskTexCoord;
layout (location = 3) in vec4 a_position;
layout (location = 4) in vec2 a_normal;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out vec2 v_maskTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
const float BaseDepthShift = -10.0;
void main()
{
float isOutline = step(0.5, u_isOutlinePass);
float notOutline = 1.0 - isOutline;
float depthShift = BaseDepthShift * isOutline;
vec4 pos = (vec4(a_position.xyz, 1) + vec4(0.0, 0.0, depthShift, 0.0)) * u_modelView;
vec4 shiftedPos = vec4(a_normal, 0.0, 0.0) + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
vec2 colorTexCoord = a_colorTexCoord * notOutline + a_outlineColorTexCoord * isOutline;
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif
v_maskTexCoord = a_maskTexCoord;
}

View file

@ -0,0 +1,45 @@
layout (location = 0) in vec2 a_colorTexCoord;
layout (location = 1) in vec2 a_outlineColorTexCoord;
layout (location = 2) in vec2 a_maskTexCoord;
layout (location = 3) in vec4 a_position;
layout (location = 4) in vec2 a_normal;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out vec2 v_maskTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
const float kBaseDepthShift = -10.0;
void main()
{
float isOutline = step(0.5, u_isOutlinePass);
float depthShift = kBaseDepthShift * isOutline;
vec4 pivot = (vec4(a_position.xyz, 1.0) + vec4(0.0, 0.0, depthShift, 0.0)) * u_modelView;
vec4 offset = vec4(a_normal, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform,
a_position.w * u_zScale, offset.xy);
vec2 colorTexCoord = mix(a_colorTexCoord, a_outlineColorTexCoord, isOutline);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif
v_maskTexCoord = a_maskTexCoord;
}

View file

@ -0,0 +1,35 @@
#ifdef ENABLE_VTF
layout (location = 0) in LOW_P vec4 v_color;
#else
layout (location = 1) in vec2 v_colorTexCoord;
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
layout (location = 2) in vec2 v_maskTexCoord;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
layout (binding = 2) uniform sampler2D u_maskTex;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 glyphColor = v_color;
#else
LOW_P vec4 glyphColor = texture(u_colorTex, v_colorTexCoord);
#endif
float dist = texture(u_maskTex, v_maskTexCoord).r;
float alpha = smoothstep(u_contrastGamma.x - u_contrastGamma.y, u_contrastGamma.x + u_contrastGamma.y, dist) * u_opacity;
glyphColor.a *= alpha;
v_FragColor = glyphColor;
}

View file

@ -0,0 +1,49 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_colorTexCoord;
layout (location = 2) in vec2 a_outlineColorTexCoord;
layout (location = 3) in vec2 a_normal;
layout (location = 4) in vec2 a_maskTexCoord;
#ifdef ENABLE_VTF
layout (location = 0) out LOW_P vec4 v_color;
#else
layout (location = 1) out vec2 v_colorTexCoord;
#endif
layout (location = 2) out vec2 v_maskTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
#ifdef ENABLE_VTF
layout (binding = 1) uniform sampler2D u_colorTex;
#endif
const float kBaseDepthShift = -10.0;
void main()
{
float isOutline = step(0.5, u_isOutlinePass);
float depthShift = kBaseDepthShift * isOutline;
vec4 pos = (vec4(a_position, 1.0) + vec4(0.0, 0.0, depthShift, 0.0)) * u_modelView;
vec4 shiftedPos = vec4(a_normal, 0.0, 0.0) + pos;
gl_Position = shiftedPos * u_projection;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
vec2 colorTexCoord = mix(a_colorTexCoord, a_outlineColorTexCoord, isOutline);
#ifdef ENABLE_VTF
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif
v_maskTexCoord = a_maskTexCoord;
}

View file

@ -0,0 +1,24 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,25 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec4 pos = vec4(a_position.xyz, 1) * u_modelView;
vec4 shiftedPos = vec4(a_normal, 0, 0) + pos;
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,24 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 1) in float v_intensity;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = vec4(texture(u_colorTex, v_colorTexCoords).rgb, u_opacity);
v_FragColor = vec4((v_intensity * 0.2 + 0.8) * finalColor.rgb, finalColor.a);
}

View file

@ -0,0 +1,26 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec2 a_normal;
layout (location = 2) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec4 pivot = vec4(a_position.xyz, 1.0) * u_modelView;
vec4 offset = vec4(a_normal, 0.0, 0.0) * u_projection;
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform,
a_position.w * u_zScale, offset.xy);
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,23 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,25 @@
layout (location = 0) in vec2 a_position;
layout (location = 1) in vec2 a_colorTexCoords;
layout (location = 0) out vec2 v_colorTexCoords;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
vec2 u_contrastGamma;
vec2 u_position;
float u_isOutlinePass;
float u_opacity;
float u_length;
};
void main()
{
gl_Position = vec4(a_position, 0, 1) * u_modelView * u_projection;
#ifdef VULKAN
gl_Position.y = -gl_Position.y;
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
#endif
v_colorTexCoords = a_colorTexCoords;
}

View file

@ -0,0 +1,25 @@
layout (location = 0) in vec2 v_colorTexCoords;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_position;
vec2 u_lineParams;
float u_accuracy;
float u_zScale;
float u_opacity;
float u_azimut;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,41 @@
layout (location = 0) in vec2 v_colorTexCoord;
layout (location = 1) in vec2 v_maskTexCoord;
layout (location = 2) in float v_halfLength;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
layout (binding = 1) uniform sampler2D u_colorTex;
layout (binding = 2) uniform sampler2D u_maskTex;
const float kAntialiasingThreshold = 0.92;
const float kOutlineThreshold1 = 0.8;
const float kOutlineThreshold2 = 0.5;
const float kMaskOpacity = 0.7;
void main()
{
vec4 color = texture(u_colorTex, v_colorTexCoord);
float alphaCode = color.a;
vec4 mask = texture(u_maskTex, v_maskTexCoord);
color.a = u_opacity * (1.0 - smoothstep(kAntialiasingThreshold, 1.0, abs(v_halfLength)));
color.rgb = mix(color.rgb, mask.rgb * mix(u_lightArrowColor.rgb, u_darkArrowColor.rgb, step(alphaCode, 0.6)), mask.a * kMaskOpacity);
if (u_outline > 0.0)
{
color.rgb = mix(color.rgb, u_outlineColor.rgb, step(kOutlineThreshold1, abs(v_halfLength)));
color.rgb = mix(color.rgb, u_outlineColor.rgb, smoothstep(kOutlineThreshold2, kOutlineThreshold1, abs(v_halfLength)));
}
v_FragColor = color;
}

View file

@ -0,0 +1,44 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_colorTexCoord;
layout (location = 0) out vec2 v_colorTexCoord;
layout (location = 1) out vec2 v_maskTexCoord;
layout (location = 2) out float v_halfLength;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
const float kArrowVSize = 0.25;
void main()
{
vec2 normal = a_normal.xy;
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (dot(normal, normal) != 0.0)
{
vec2 norm = normal * u_trafficParams.x;
if (a_normal.z < 0.0)
norm = normal * u_trafficParams.y;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
}
float uOffset = length(vec4(kShapeCoordScalar, 0, 0, 0) * u_modelView) * a_normal.w;
v_colorTexCoord = a_colorTexCoord.xy;
float v = mix(a_colorTexCoord.z, a_colorTexCoord.z + kArrowVSize, 0.5 * a_normal.z + 0.5);
v_maskTexCoord = vec2(uOffset * u_trafficParams.z, v) * u_trafficParams.w;
v_maskTexCoord.x *= step(a_colorTexCoord.w, v_maskTexCoord.x);
v_halfLength = a_normal.z;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,36 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec2 v_colorTexCoord;
layout (location = 1) in vec3 v_radius;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
layout (binding = 1) uniform sampler2D u_colorTex;
const float kAntialiasingThreshold = 0.92;
void main()
{
vec4 color = texture(u_colorTex, v_colorTexCoord);
float smallRadius = v_radius.z * kAntialiasingThreshold;
float stepValue = smoothstep(smallRadius * smallRadius, v_radius.z * v_radius.z,
v_radius.x * v_radius.x + v_radius.y * v_radius.y);
color.a = u_opacity * (1.0 - stepValue);
if (color.a < 0.01)
discard;
v_FragColor = color;
}

View file

@ -0,0 +1,41 @@
layout (location = 0) in vec4 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec2 a_colorTexCoord;
layout (location = 0) out vec2 v_colorTexCoord;
layout (location = 1) out vec3 v_radius;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
void main()
{
vec2 normal = a_normal.xy;
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
int index = int(a_position.w);
float leftSize = u_lightArrowColor[index];
float rightSize = u_darkArrowColor[index];
if (dot(normal, normal) != 0.0)
{
// offset by normal = rightVec * (rightSize - leftSize) / 2
vec2 norm = normal * 0.5 * (rightSize - leftSize);
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
}
// radius = (leftSize + rightSize) / 2
v_radius = vec3(a_normal.zw, 1.0) * 0.5 * (leftSize + rightSize);
vec2 finalPos = transformedAxisPos + v_radius.xy;
v_colorTexCoord = a_colorTexCoord;
vec4 pos = vec4(finalPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,24 @@
layout (location = 0) in vec2 v_colorTexCoord;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 color = texture(u_colorTex, v_colorTexCoord);
v_FragColor = vec4(color.rgb, u_opacity);
}

View file

@ -0,0 +1,25 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec2 a_colorTexCoord;
layout (location = 0) out vec2 v_colorTexCoord;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_trafficParams;
vec4 u_outlineColor;
vec4 u_lightArrowColor;
vec4 u_darkArrowColor;
float u_outline;
float u_opacity;
};
void main()
{
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
v_colorTexCoord = a_colorTexCoord;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,8 @@
layout (location = 0) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
void main()
{
v_FragColor = v_color;
}

View file

@ -0,0 +1,30 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_params;
float u_lineHalfWidth;
float u_maxRadius;
};
void main()
{
vec2 normal = a_normal.xy;
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (dot(normal, normal) != 0.0)
{
vec2 norm = normal * u_lineHalfWidth;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
}
v_color = a_color;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
}

View file

@ -0,0 +1,21 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec3 v_radius;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
const float aaPixelsCount = 2.5;
void main()
{
vec4 finalColor = v_color;
float smallRadius = v_radius.z - aaPixelsCount;
float stepValue = smoothstep(smallRadius * smallRadius, v_radius.z * v_radius.z,
dot(v_radius.xy, v_radius.xy));
finalColor.a = finalColor.a * (1.0 - stepValue);
if (finalColor.a < 0.01)
discard;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,33 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec3 v_radius;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_params;
float u_lineHalfWidth;
float u_maxRadius;
};
void main()
{
vec2 normal = a_normal.xy;
vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * u_modelView).xy;
if (dot(normal, normal) != 0.0)
{
vec2 norm = normal * u_lineHalfWidth;
transformedAxisPos = calcLineTransformedAxisPos(transformedAxisPos, a_position.xy + norm,
u_modelView, length(norm));
}
transformedAxisPos += a_normal.zw * u_lineHalfWidth;
vec4 pos = vec4(transformedAxisPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
v_color = a_color;
v_radius = vec3(a_normal.zw, u_maxRadius) * u_lineHalfWidth;
}

View file

@ -0,0 +1,17 @@
layout (location = 0) in vec4 v_offsets;
layout (location = 1) in vec4 v_color;
layout (location = 0) out vec4 v_FragColor;
void main()
{
vec4 finalColor = v_color;
vec2 radius;
radius.x = max(0.0, abs(v_offsets.x) - v_offsets.z);
radius.y = max(0.0, abs(v_offsets.y) - v_offsets.w);
float maxRadius = 1.0;
float aaRadius = 0.9;
float stepValue = smoothstep(aaRadius * aaRadius, maxRadius * maxRadius, dot(radius.xy, radius.xy));
finalColor.a = finalColor.a * (1.0 - stepValue);
v_FragColor = finalColor;
}

View file

@ -0,0 +1,29 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec4 a_normal;
layout (location = 2) in vec4 a_color;
layout (location = 0) out vec4 v_offsets;
layout (location = 1) out vec4 v_color;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec4 u_params;
float u_lineHalfWidth;
float u_maxRadius;
};
void main()
{
vec4 pos = vec4(a_position.xy, 0, 1) * u_modelView;
vec2 normal = vec2(a_normal.x * u_params.x - a_normal.y * u_params.y,
a_normal.x * u_params.y + a_normal.y * u_params.x);
vec2 shiftedPos = normal * u_params.z + pos.xy;
pos = vec4(shiftedPos, a_position.z, 1.0) * u_projection;
gl_Position = applyPivotTransform(pos, u_pivotTransform, 0.0);
vec2 offsets = abs(a_normal.zw);
v_offsets = vec4(a_normal.zw, offsets - 1.0);
v_color = a_color;
}

View file

@ -0,0 +1,32 @@
// Warning! Beware to use this shader. "discard" command may significally reduce performance.
// Unfortunately some CG algorithms cannot be implemented without discarding fragments from depth buffer.
layout (location = 0) in vec4 v_texCoords;
layout (location = 1) in vec4 v_maskColor;
layout (location = 0) out vec4 v_FragColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
layout (binding = 1) uniform sampler2D u_colorTex;
void main()
{
vec4 color = texture(u_colorTex, v_texCoords.xy);
vec4 bgColor = texture(u_colorTex, v_texCoords.zw) * vec4(v_maskColor.xyz, 1.0);
vec4 finalColor = mix(color, mix(bgColor, color, color.a), bgColor.a);
finalColor.a = clamp(color.a + bgColor.a, 0.0, 1.0) * u_opacity * v_maskColor.w;
if (finalColor.a < 0.01)
discard;
v_FragColor = finalColor;
}

View file

@ -0,0 +1,34 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normalAndAnimateOrZ;
layout (location = 2) in vec4 a_texCoords;
layout (location = 3) in vec4 a_color;
layout (location = 0) out vec4 v_texCoords;
layout (location = 1) out vec4 v_maskColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec2 normal = a_normalAndAnimateOrZ.xy;
if (a_normalAndAnimateOrZ.z > 0.0)
normal = u_interpolation * normal;
vec4 p = vec4(a_position, 1.0) * u_modelView;
vec4 pos = vec4(normal, 0.0, 0.0) + p;
vec4 projectedPivot = p * u_projection;
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
float newZ = projectedPivot.y / projectedPivot.w * 0.5 + 0.5;
gl_Position.z = abs(a_normalAndAnimateOrZ.z) * newZ + (1.0 - abs(a_normalAndAnimateOrZ.z)) * gl_Position.z;
v_texCoords = a_texCoords;
v_maskColor = a_color;
}

View file

@ -0,0 +1,34 @@
layout (location = 0) in vec3 a_position;
layout (location = 1) in vec3 a_normalAndAnimateOrZ;
layout (location = 2) in vec4 a_texCoords;
layout (location = 3) in vec4 a_color;
layout (location = 0) out vec4 v_texCoords;
layout (location = 1) out vec4 v_maskColor;
layout (binding = 0) uniform UBO
{
mat4 u_modelView;
mat4 u_projection;
mat4 u_pivotTransform;
vec2 u_contrastGamma;
float u_opacity;
float u_zScale;
float u_interpolation;
float u_isOutlinePass;
};
void main()
{
vec2 normal = a_normalAndAnimateOrZ.xy;
if (a_normalAndAnimateOrZ.z > 0.0)
normal = u_interpolation * normal;
vec4 pivot = vec4(a_position, 1.0) * u_modelView;
vec4 offset = vec4(normal, 0.0, 0.0) * u_projection;
vec4 projectedPivot = pivot * u_projection;
gl_Position = applyBillboardPivotTransform(projectedPivot, u_pivotTransform, 0.0, offset.xy);
float newZ = projectedPivot.y / projectedPivot.w * 0.5 + 0.5;
gl_Position.z = abs(a_normalAndAnimateOrZ.z) * newZ + (1.0 - abs(a_normalAndAnimateOrZ.z)) * gl_Position.z;
v_texCoords = a_texCoords;
v_maskColor = a_color;
}