Refactor shaders to use GLES3 syntax

Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
renderexpert 2025-01-21 14:39:31 +00:00
parent 10b6597eca
commit e5e9fc69ae
84 changed files with 471 additions and 543 deletions

View file

@ -32,11 +32,6 @@ void SupportManager::Init(ref_ptr<GraphicsContext> context)
m_rendererVersion = context->GetRendererVersion();
LOG(LINFO, ("Renderer =", m_rendererName, "| Api =", context->GetApiVersion(), "| Version =", m_rendererVersion));
m_isSamsungGoogleNexus = (m_rendererName == "PowerVR SGX 540" &&
m_rendererVersion.find("GOOGLENEXUS.ED945322") != std::string::npos);
if (m_isSamsungGoogleNexus)
LOG(LINFO, ("Samsung Google Nexus detected."));
if (m_rendererName.find("Adreno") != std::string::npos)
{
std::array<std::string_view, 5> constexpr models = { "200", "203", "205", "220", "225" };

View file

@ -26,7 +26,6 @@ public:
// reinitialization.
void Init(ref_ptr<GraphicsContext> context);
bool IsSamsungGoogleNexus() const { return m_isSamsungGoogleNexus; }
bool IsAdreno200Device() const { return m_isAdreno200; }
bool IsTegraDevice() const { return m_isTegra; }
bool IsAntialiasingEnabledByDefault() const { return m_isAntialiasingEnabledByDefault; }
@ -50,7 +49,6 @@ private:
std::string m_rendererName;
std::string m_rendererVersion;
bool m_isSamsungGoogleNexus = false;
bool m_isAdreno200 = false;
bool m_isTegra = false;
bool m_isAntialiasingEnabledByDefault = false;

View file

@ -1,5 +1,5 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoords;
in vec3 a_position;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -7,9 +7,9 @@ uniform mat4 u_pivotTransform;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
void main()
@ -17,7 +17,7 @@ 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 = texture2D(u_colorTex, a_colorTexCoords);
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif

View file

@ -1,21 +1,21 @@
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoords;
in vec3 a_position;
in vec3 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;
varying vec2 v_colorTexCoords;
varying float v_intensity;
out vec2 v_colorTexCoords;
out float v_intensity;
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;

View file

@ -1,5 +1,5 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoords;
in vec3 a_position;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,9 +8,9 @@ uniform float u_zScale;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
void main()
@ -25,7 +25,7 @@ void main()
#endif
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif

View file

@ -1,16 +1,13 @@
varying vec3 v_normal;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec3 v_normal;
const vec3 lightDir = vec3(0.316, 0.0, 0.948);
uniform vec4 u_color;
out vec4 v_FragColor;
void main()
{
float phongDiffuse = max(0.0, -dot(lightDir, v_normal));
vec4 resColor = vec4((phongDiffuse * 0.5 + 0.5) * u_color.rgb, u_color.a);
gl_FragColor = samsungGoogleNexusWorkaround(resColor);
v_FragColor = vec4((phongDiffuse * 0.5 + 0.5) * u_color.rgb, u_color.a);
}

View file

@ -1,10 +1,10 @@
attribute vec3 a_pos;
attribute vec3 a_normal;
in vec3 a_pos;
in vec3 a_normal;
uniform mat4 u_transform;
uniform mat4 u_normalTransform;
varying vec3 v_normal;
out vec3 v_normal;
void main()
{

View file

@ -1,13 +1,10 @@
varying float v_intensity;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in float v_intensity;
uniform vec4 u_color;
out vec4 v_FragColor;
void main()
{
vec4 resColor = vec4(u_color.rgb, u_color.a * smoothstep(0.7, 1.0, v_intensity));
gl_FragColor = samsungGoogleNexusWorkaround(resColor);
v_FragColor = vec4(u_color.rgb, u_color.a * smoothstep(0.7, 1.0, v_intensity));
}

View file

@ -1,13 +1,10 @@
varying float v_intensity;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in float v_intensity;
uniform vec4 u_color;
out vec4 v_FragColor;
void main()
{
vec4 resColor = vec4(u_color.rgb, u_color.a * v_intensity);
gl_FragColor = samsungGoogleNexusWorkaround(resColor);
v_FragColor = vec4(u_color.rgb, u_color.a * v_intensity);
}

View file

@ -1,9 +1,9 @@
attribute vec3 a_pos;
attribute vec2 a_texCoords;
in vec3 a_pos;
in vec2 a_texCoords;
uniform mat4 u_transform;
varying float v_intensity;
out float v_intensity;
void main()
{

View file

@ -1,5 +1,5 @@
varying vec3 v_normal;
varying vec2 v_texCoords;
in vec3 v_normal;
in vec2 v_texCoords;
uniform sampler2D u_colorTex;
@ -7,9 +7,11 @@ const vec3 lightDir = vec3(0.316, 0.0, 0.948);
uniform vec4 u_color;
out vec4 v_FragColor;
void main()
{
float phongDiffuse = max(0.0, -dot(lightDir, v_normal));
vec4 color = texture2D(u_colorTex, v_texCoords) * u_color;
gl_FragColor = vec4((phongDiffuse * 0.5 + 0.5) * color.rgb, color.a);
vec4 color = texture(u_colorTex, v_texCoords) * u_color;
v_FragColor = vec4((phongDiffuse * 0.5 + 0.5) * color.rgb, color.a);
}

View file

@ -1,13 +1,13 @@
attribute vec3 a_pos;
attribute vec3 a_normal;
attribute vec2 a_texCoords;
in vec3 a_pos;
in vec3 a_normal;
in vec2 a_texCoords;
uniform mat4 u_transform;
uniform mat4 u_normalTransform;
uniform vec2 u_texCoordFlipping;
varying vec3 v_normal;
varying vec2 v_texCoords;
out vec3 v_normal;
out vec2 v_texCoords;
void main()
{

View file

@ -1,26 +1,28 @@
uniform float u_opacity;
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
#endif
varying vec3 v_radius;
in vec3 v_radius;
const float aaPixelsCount = 2.5;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 finalColor = v_color;
#else
LOW_P vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
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);
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoords;
in vec3 a_position;
in vec3 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,12 +8,12 @@ uniform mat4 u_pivotTransform;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
varying vec3 v_radius;
out vec3 v_radius;
void main()
{
@ -21,7 +21,7 @@ void main()
vec4 pos = vec4(a_normal.xy, 0, 0) + p;
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif

View file

@ -1,22 +1,20 @@
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
uniform float u_opacity;
varying vec3 v_radius;
varying vec4 v_color;
in vec3 v_radius;
in vec4 v_color;
const float kAntialiasingScalar = 0.9;
out vec4 v_FragColor;
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);
gl_FragColor = samsungGoogleNexusWorkaround(finalColor);
v_FragColor = finalColor;
}

View file

@ -1,13 +1,13 @@
attribute vec3 a_normal;
attribute vec3 a_position;
attribute vec4 a_color;
in vec3 a_normal;
in vec3 a_position;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec3 v_radius;
varying vec4 v_color;
out vec3 v_radius;
out vec4 v_color;
void main()
{

View file

@ -1,21 +1,23 @@
uniform float u_opacity;
varying vec4 v_normal;
in vec4 v_normal;
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
#endif
const float aaPixelsCount = 2.5;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoords);
#endif
float r1 = (v_normal.z - aaPixelsCount) * (v_normal.z - aaPixelsCount);
@ -28,5 +30,5 @@ void main()
if (finalColor.a == 0.0)
discard;
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,17 +1,17 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_colorTexCoords;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec4 v_normal;
out vec4 v_normal;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
void main()
@ -21,7 +21,7 @@ void main()
gl_Position = applyPivotTransform(pos * u_projection, u_pivotTransform, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords.xy);
v_color = texture(u_colorTex, a_colorTexCoords.xy);
#else
v_colorTexCoords = a_colorTexCoords.xy;
#endif

View file

@ -1,17 +1,17 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_colorTexCoords;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec4 v_normal;
out vec4 v_normal;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
void main()
@ -21,7 +21,7 @@ void main()
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform, 0.0, offset.xy);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords.xy);
v_color = texture(u_colorTex, a_colorTexCoords.xy);
#else
v_colorTexCoords = a_colorTexCoords.xy;
#endif

View file

@ -1,6 +1,6 @@
varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
//varying vec2 v_halfLength;
in vec2 v_colorTexCoord;
in vec2 v_maskTexCoord;
//in vec2 v_halfLength;
uniform sampler2D u_colorTex;
uniform sampler2D u_maskTex;
@ -8,14 +8,12 @@ uniform float u_opacity;
//const float aaPixelsCount = 2.5;
out vec4 v_FragColor;
void main()
{
vec4 color = texture2D(u_colorTex, v_colorTexCoord);
#ifdef GLES3
float mask = texture2D(u_maskTex, v_maskTexCoord).r;
#else
float mask = texture2D(u_maskTex, v_maskTexCoord).a;
#endif
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,
@ -24,5 +22,5 @@ void main()
//float diff = v_halfLength.y - currentW;
//color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0));
gl_FragColor = color;
v_FragColor = color;
}

View file

@ -1,15 +1,15 @@
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoord;
attribute vec4 a_maskTexCoord;
in vec3 a_position;
in vec3 a_normal;
in vec2 a_colorTexCoord;
in vec4 a_maskTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
//varying vec2 v_halfLength;
out vec2 v_colorTexCoord;
out vec2 v_maskTexCoord;
//out vec2 v_halfLength;
void main()
{

View file

@ -1,10 +1,8 @@
uniform vec4 u_color;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
out vec4 v_FragColor;
void main()
{
gl_FragColor = samsungGoogleNexusWorkaround(u_color);
v_FragColor = u_color;
}

View file

@ -1,4 +1,4 @@
attribute vec2 a_position;
in vec2 a_position;
void main()
{

View file

@ -1,24 +1,26 @@
uniform float u_opacity;
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
#endif
uniform sampler2D u_maskTex;
varying vec2 v_maskTexCoords;
in vec2 v_maskTexCoords;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoords);
#endif
color *= texture2D(u_maskTex, v_maskTexCoords);
color *= texture(u_maskTex, v_maskTexCoords);
color.a *= u_opacity;
gl_FragColor = color;
v_FragColor = color;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoords;
attribute vec2 a_maskTexCoords;
in vec3 a_position;
in vec2 a_colorTexCoords;
in vec2 a_maskTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,18 +8,18 @@ uniform mat4 u_pivotTransform;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
#endif
varying vec2 v_maskTexCoords;
out vec2 v_maskTexCoords;
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 = texture2D(u_colorTex, a_colorTexCoords);
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoords = a_colorTexCoords;
#endif

View file

@ -1,10 +1,12 @@
varying vec2 v_texCoords;
varying vec4 v_color;
in vec2 v_texCoords;
in vec4 v_color;
uniform sampler2D u_colorTex;
out vec4 v_FragColor;
void main()
{
LOW_P vec4 color = texture2D(u_colorTex, v_texCoords);
gl_FragColor = color * v_color;
LOW_P vec4 color = texture(u_colorTex, v_texCoords);
v_FragColor = color * v_color;
}

View file

@ -1,9 +1,9 @@
attribute vec2 a_position;
attribute vec2 a_texCoords;
attribute vec4 a_color;
in vec2 a_position;
in vec2 a_texCoords;
in vec4 a_color;
varying vec2 v_texCoords;
varying vec4 v_color;
out vec2 v_texCoords;
out vec4 v_color;
uniform mat4 u_projection;

View file

@ -1,21 +1,23 @@
uniform float u_opacity;
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoord;
in vec2 v_colorTexCoord;
#endif
//varying vec2 v_halfLength;
//in vec2 v_halfLength;
//const float aaPixelsCount = 2.5;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoord);
LOW_P vec4 color = texture(u_colorTex, v_colorTexCoord);
#endif
color.a *= u_opacity;
@ -25,5 +27,5 @@ void main()
//float diff = v_halfLength.y - currentW;
//color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0));
gl_FragColor = color;
v_FragColor = color;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_colorTexCoord;
in vec3 a_position;
in vec3 a_normal;
in vec2 a_colorTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,12 +8,12 @@ uniform mat4 u_pivotTransform;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
//varying vec2 v_halfLength;
//out vec2 v_halfLength;
void main()
{
@ -27,7 +27,7 @@ void main()
}
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoord);
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif

View file

@ -2,12 +2,14 @@ uniform sampler2D u_colorTex;
uniform sampler2D u_maskTex;
uniform float u_opacity;
varying vec2 v_colorTexCoords;
varying vec2 v_maskTexCoords;
in vec2 v_colorTexCoords;
in vec2 v_maskTexCoords;
out vec4 v_FragColor;
void main()
{
vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords) * texture2D(u_maskTex, v_maskTexCoords);
vec4 finalColor = texture(u_colorTex, v_colorTexCoords) * texture(u_maskTex, v_maskTexCoords);
finalColor.a *= u_opacity;
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,14 +1,14 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
attribute vec2 a_maskTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
in vec2 a_maskTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoords;
varying vec2 v_maskTexCoords;
out vec2 v_colorTexCoords;
out vec2 v_maskTexCoords;
void main()
{

View file

@ -1,15 +1,15 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
attribute vec2 a_maskTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
in vec2 a_maskTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;
varying vec2 v_colorTexCoords;
varying vec2 v_maskTexCoords;
out vec2 v_colorTexCoords;
out vec2 v_maskTexCoords;
void main()
{

View file

@ -1,5 +1,5 @@
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform vec3 u_position;
uniform float u_azimut;
@ -8,7 +8,7 @@ uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,12 +1,12 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,5 +1,5 @@
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform vec3 u_position;
uniform float u_accuracy;
@ -9,7 +9,7 @@ uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -2,12 +2,8 @@
// Unfortunately some CG algorithms cannot be implemented on OpenGL ES 2.0 without discarding
// fragments from depth buffer.
varying vec3 v_length;
varying vec4 v_color;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec3 v_length;
in vec4 v_color;
uniform vec4 u_color;
uniform vec4 u_outlineColor;
@ -23,6 +19,8 @@ const float kAntialiasingThreshold = 0.92;
const float kOutlineThreshold1 = 0.81;
const float kOutlineThreshold2 = 0.71;
out vec4 v_FragColor;
void main()
{
if (v_length.x < v_length.z)
@ -40,5 +38,5 @@ void main()
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);
gl_FragColor = samsungGoogleNexusWorkaround(color);
v_FragColor = color;
}

View file

@ -1,7 +1,7 @@
attribute vec3 a_position;
attribute vec2 a_normal;
attribute vec3 a_length;
attribute vec4 a_color;
in vec3 a_position;
in vec2 a_normal;
in vec3 a_length;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -9,8 +9,8 @@ uniform mat4 u_pivotTransform;
uniform vec4 u_routeParams;
varying vec3 v_length;
varying vec4 v_color;
out vec3 v_length;
out vec4 v_color;
void main()
{

View file

@ -6,14 +6,16 @@ uniform sampler2D u_colorTex;
uniform float u_opacity;
uniform vec4 u_maskColor;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
out vec4 v_FragColor;
void main()
{
vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
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);
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,6 +1,6 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,7 +8,7 @@ uniform mat4 u_pivotTransform;
uniform float u_arrowHalfWidth;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -2,12 +2,8 @@
// Unfortunately some CG algorithms cannot be implemented on OpenGL ES 2.0 without discarding
// fragments from depth buffer.
varying vec3 v_length;
varying vec4 v_color;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec3 v_length;
in vec4 v_color;
uniform vec4 u_color;
uniform vec2 u_pattern;
@ -25,6 +21,8 @@ float alphaFromPattern(float curLen, float dashLen, float gapLen)
return step(offset, dashLen);
}
out vec4 v_FragColor;
void main()
{
if (v_length.x < v_length.z)
@ -39,5 +37,5 @@ void main()
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);
gl_FragColor = samsungGoogleNexusWorkaround(color);
v_FragColor = color;
}

View file

@ -2,23 +2,21 @@
// Unfortunately some CG algorithms cannot be implemented on OpenGL ES 2.0 without discarding
// fragments from depth buffer.
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
uniform vec4 u_routeParams;
uniform vec4 u_maskColor;
uniform float u_opacity;
varying vec4 v_radius;
varying vec4 v_color;
in vec4 v_radius;
in vec4 v_color;
const float kAntialiasingPixelsCount = 2.5;
out vec4 v_FragColor;
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));
@ -27,5 +25,5 @@ void main()
discard;
finalColor = vec4(mix(finalColor.rgb, u_maskColor.rgb, u_maskColor.a), finalColor.a);
gl_FragColor = samsungGoogleNexusWorkaround(finalColor);
v_FragColor = finalColor;
}

View file

@ -1,6 +1,6 @@
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec4 a_color;
in vec4 a_position;
in vec3 a_normal;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -9,8 +9,8 @@ uniform mat4 u_pivotTransform;
uniform vec2 u_angleCosSin;
uniform vec4 u_routeParams;
varying vec4 v_radius;
varying vec4 v_color;
out vec4 v_radius;
out vec4 v_color;
void main()
{

View file

@ -1,12 +1,12 @@
attribute vec2 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec2 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform vec2 u_position;
uniform float u_length;
uniform mat4 u_projection;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,7 +1,7 @@
attribute vec2 a_pos;
attribute vec2 a_tcoord;
in vec2 a_pos;
in vec2 a_tcoord;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,24 +1,26 @@
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoord;
in vec2 v_colorTexCoord;
#endif
uniform float u_opacity;
varying float v_lengthY;
in float v_lengthY;
const float kAntialiasingThreshold = 0.92;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 color = v_color;
#else
LOW_P vec4 color = texture2D(u_colorTex, v_colorTexCoord);
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)));
gl_FragColor = samsungGoogleNexusWorkaround(color);
v_FragColor = color;
}

View file

@ -1,7 +1,7 @@
attribute vec3 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
attribute vec3 a_length;
in vec3 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
in vec3 a_length;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -11,12 +11,12 @@ uniform vec2 u_lineParams;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying float v_lengthY;
out float v_lengthY;
void main()
{
@ -32,7 +32,7 @@ void main()
}
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoords);
v_color = texture(u_colorTex, a_colorTexCoords);
#else
v_colorTexCoord = a_colorTexCoords;
#endif

View file

@ -47,15 +47,3 @@ vec2 calcLineTransformedAxisPos(vec2 originalAxisPos, vec2 shiftedPos, mat4 mode
}
// FS (DO NOT modify this comment, it marks up block of fragment shader functions).
// Because of a bug in OpenGL driver on Samsung Google Nexus this workaround is here.
// It must be used in shaders which do not have any sampler2D usage.
vec4 samsungGoogleNexusWorkaround(vec4 color)
{
#ifdef SAMSUNG_GOOGLE_NEXUS
const float kFakeColorScalar = 0.0;
return color + texture2D(u_colorTex, vec2(0.0, 0.0)) * kFakeColorScalar;
#else
return color;
#endif
}

View file

@ -6,32 +6,22 @@ uniform sampler2D u_smaaSearch;
uniform vec4 u_framebufferMetrics;
varying vec4 v_coords;
varying vec4 v_offset0;
varying vec4 v_offset1;
varying vec4 v_offset2;
in vec4 v_coords;
in vec4 v_offset0;
in vec4 v_offset1;
in vec4 v_offset2;
#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))
#ifdef GLES3
#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)
#else
#define SMAA_MAX_SEARCH_STEPS 8
#define SMAALoopBegin(condition) for (int i = 0; i < SMAA_MAX_SEARCH_STEPS; i++) { if (!(condition)) break;
#define SMAALoopEnd }
#define SMAASampleLevelZero(tex, coord) texture2D(tex, coord)
#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + vec2(offset) * u_framebufferMetrics.xy)
#define SMAARound(v) floor((v) + 0.5)
#define SMAAOffset(x,y) vec2(x,y)
#endif
#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;
@ -53,11 +43,7 @@ float SMAASearchLength(vec2 e, float offset)
bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
// Lookup the search texture.
#ifdef GLES3
return SMAASampleLevelZero(u_smaaSearch, scale * e + bias).r;
#else
return SMAASampleLevelZero(u_smaaSearch, scale * e + bias).a;
#endif
}
float SMAASearchXLeft(vec2 texcoord, float end)
@ -115,10 +101,12 @@ vec2 SMAAArea(vec2 dist, float e1, float e2)
return SMAASampleLevelZero(u_smaaArea, texcoord).rg;
}
out vec4 v_FragColor;
void main()
{
vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);
vec2 e = texture2D(u_colorTex, v_coords.xy).rg;
vec2 e = texture(u_colorTex, v_coords.xy).rg;
if (e.g > 0.0) // Edge at north
{
@ -187,5 +175,5 @@ void main()
weights.ba = SMAAArea(sqrt_d, e1, e2);
}
gl_FragColor = weights;
v_FragColor = weights;
}

View file

@ -1,14 +1,14 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
attribute vec2 a_pos;
attribute vec2 a_tcoord;
in vec2 a_pos;
in vec2 a_tcoord;
uniform vec4 u_framebufferMetrics;
varying vec4 v_coords;
varying vec4 v_offset0;
varying vec4 v_offset1;
varying vec4 v_offset2;
out vec4 v_coords;
out vec4 v_offset0;
out vec4 v_offset1;
out vec4 v_offset2;
// SMAA_MAX_SEARCH_STEPS specifies the maximum steps performed in the
// horizontal/vertical pattern searches, at each side of the pixel.

View file

@ -2,10 +2,10 @@
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
varying vec4 v_offset0;
varying vec4 v_offset1;
varying vec4 v_offset2;
in vec2 v_colorTexCoords;
in vec4 v_offset0;
in vec4 v_offset1;
in vec4 v_offset2;
// SMAA_THRESHOLD specifies the threshold or sensitivity to edges.
// Lowering this value you will be able to detect more edges at the expense of
@ -27,12 +27,14 @@ const vec2 kThreshold = vec2(SMAA_THRESHOLD, SMAA_THRESHOLD);
// https://en.wikipedia.org/wiki/Relative_luminance
const vec3 kWeights = vec3(0.2126, 0.7152, 0.0722);
out vec4 v_FragColor;
void main()
{
// Calculate lumas.
float L = dot(texture2D(u_colorTex, v_colorTexCoords).rgb, kWeights);
float Lleft = dot(texture2D(u_colorTex, v_offset0.xy).rgb, kWeights);
float Ltop = dot(texture2D(u_colorTex, v_offset0.zw).rgb, kWeights);
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;
@ -42,16 +44,16 @@ void main()
discard;
// Calculate right and bottom deltas.
float Lright = dot(texture2D(u_colorTex, v_offset1.xy).rgb, kWeights);
float Lbottom = dot(texture2D(u_colorTex, v_offset1.zw).rgb, kWeights);
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(texture2D(u_colorTex, v_offset2.xy).rgb, kWeights);
float Ltoptop = dot(texture2D(u_colorTex, v_offset2.zw).rgb, kWeights);
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.
@ -61,5 +63,5 @@ void main()
// Local contrast adaptation
edges *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
gl_FragColor = vec4(edges, 0.0, 1.0);
v_FragColor = vec4(edges, 0.0, 1.0);
}

View file

@ -1,14 +1,14 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
attribute vec2 a_pos;
attribute vec2 a_tcoord;
in vec2 a_pos;
in vec2 a_tcoord;
uniform vec4 u_framebufferMetrics;
varying vec2 v_colorTexCoords;
varying vec4 v_offset0;
varying vec4 v_offset1;
varying vec4 v_offset2;
out vec2 v_colorTexCoords;
out vec4 v_offset0;
out vec4 v_offset1;
out vec4 v_offset2;
void main()
{

View file

@ -5,27 +5,25 @@ uniform sampler2D u_blendingWeightTex;
uniform vec4 u_framebufferMetrics;
varying vec2 v_colorTexCoords;
varying vec4 v_offset;
in vec2 v_colorTexCoords;
in vec4 v_offset;
#ifdef GLES3
#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
#else
#define SMAASampleLevelZero(tex, coord) texture2D(tex, coord)
#endif
#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
out vec4 v_FragColor;
void main()
{
// Fetch the blending weights for current pixel.
vec4 a;
a.x = texture2D(u_blendingWeightTex, v_offset.xy).a; // Right
a.y = texture2D(u_blendingWeightTex, v_offset.zw).g; // Top
a.wz = texture2D(u_blendingWeightTex, v_colorTexCoords).xz; // Bottom / Left
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)
{
gl_FragColor = texture2D(u_colorTex, v_colorTexCoords);
v_FragColor = texture(u_colorTex, v_colorTexCoords);
}
else
{
@ -46,6 +44,6 @@ void main()
// 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);
gl_FragColor = color;
v_FragColor = color;
}
}

View file

@ -1,12 +1,12 @@
// Implementation of Subpixel Morphological Antialiasing (SMAA) is based on https://github.com/iryoku/smaa
attribute vec2 a_pos;
attribute vec2 a_tcoord;
in vec2 a_pos;
in vec2 a_tcoord;
uniform vec4 u_framebufferMetrics;
varying vec2 v_colorTexCoords;
varying vec4 v_offset;
out vec2 v_colorTexCoords;
out vec4 v_offset;
void main()
{

View file

@ -1,20 +1,22 @@
uniform float u_opacity;
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
uniform sampler2D u_colorTex;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
#endif
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 finalColor = v_color;
#else
LOW_P vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
LOW_P vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
#endif
finalColor.a *= u_opacity;
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,29 +1,27 @@
#ifdef ENABLE_VTF
varying LOW_P vec4 v_color;
in LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
in vec2 v_colorTexCoord;
uniform sampler2D u_colorTex;
#endif
varying vec2 v_maskTexCoord;
in vec2 v_maskTexCoord;
uniform sampler2D u_maskTex;
uniform float u_opacity;
uniform vec2 u_contrastGamma;
out vec4 v_FragColor;
void main()
{
#ifdef ENABLE_VTF
LOW_P vec4 glyphColor = v_color;
#else
LOW_P vec4 glyphColor = texture2D(u_colorTex, v_colorTexCoord);
#endif
#ifdef GLES3
float dist = texture2D(u_maskTex, v_maskTexCoord).r;
#else
float dist = texture2D(u_maskTex, v_maskTexCoord).a;
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;
gl_FragColor = glyphColor;
v_FragColor = glyphColor;
}

View file

@ -1,7 +1,7 @@
attribute vec2 a_colorTexCoord;
attribute vec2 a_maskTexCoord;
attribute vec4 a_position;
attribute vec2 a_normal;
in vec2 a_colorTexCoord;
in vec2 a_maskTexCoord;
in vec4 a_position;
in vec2 a_normal;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -9,21 +9,21 @@ uniform mat4 u_pivotTransform;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying vec2 v_maskTexCoord;
out vec2 v_maskTexCoord;
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 = texture2D(u_colorTex, a_colorTexCoord);
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif

View file

@ -1,7 +1,7 @@
attribute vec2 a_colorTexCoord;
attribute vec2 a_maskTexCoord;
attribute vec4 a_position;
attribute vec2 a_normal;
in vec2 a_colorTexCoord;
in vec2 a_maskTexCoord;
in vec4 a_position;
in vec2 a_normal;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -11,12 +11,12 @@ uniform float u_zScale;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying vec2 v_maskTexCoord;
out vec2 v_maskTexCoord;
void main()
{
@ -25,7 +25,7 @@ void main()
gl_Position = applyBillboardPivotTransform(pivot * u_projection, u_pivotTransform,
a_position.w * u_zScale, offset.xy);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoord);
v_color = texture(u_colorTex, a_colorTexCoord);
#else
v_colorTexCoord = a_colorTexCoord;
#endif

View file

@ -1,8 +1,8 @@
attribute vec2 a_colorTexCoord;
attribute vec2 a_outlineColorTexCoord;
attribute vec2 a_maskTexCoord;
attribute vec4 a_position;
attribute vec2 a_normal;
in vec2 a_colorTexCoord;
in vec2 a_outlineColorTexCoord;
in vec2 a_maskTexCoord;
in vec4 a_position;
in vec2 a_normal;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -11,12 +11,12 @@ uniform float u_isOutlinePass;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying vec2 v_maskTexCoord;
out vec2 v_maskTexCoord;
const float BaseDepthShift = -10.0;
@ -31,7 +31,7 @@ void main()
gl_Position = applyPivotTransform(shiftedPos * u_projection, u_pivotTransform, 0.0);
vec2 colorTexCoord = a_colorTexCoord * notOutline + a_outlineColorTexCoord * isOutline;
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, colorTexCoord);
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif

View file

@ -1,8 +1,8 @@
attribute vec2 a_colorTexCoord;
attribute vec2 a_outlineColorTexCoord;
attribute vec2 a_maskTexCoord;
attribute vec4 a_position;
attribute vec2 a_normal;
in vec2 a_colorTexCoord;
in vec2 a_outlineColorTexCoord;
in vec2 a_maskTexCoord;
in vec4 a_position;
in vec2 a_normal;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -12,12 +12,12 @@ uniform float u_zScale;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying vec2 v_maskTexCoord;
out vec2 v_maskTexCoord;
const float kBaseDepthShift = -10.0;
@ -25,7 +25,7 @@ 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,
@ -33,7 +33,7 @@ void main()
vec2 colorTexCoord = mix(a_colorTexCoord, a_outlineColorTexCoord, isOutline);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, colorTexCoord);
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif

View file

@ -1,8 +1,8 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoord;
attribute vec2 a_outlineColorTexCoord;
attribute vec2 a_normal;
attribute vec2 a_maskTexCoord;
in vec3 a_position;
in vec2 a_colorTexCoord;
in vec2 a_outlineColorTexCoord;
in vec2 a_normal;
in vec2 a_maskTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -10,12 +10,12 @@ uniform float u_isOutlinePass;
#ifdef ENABLE_VTF
uniform sampler2D u_colorTex;
varying LOW_P vec4 v_color;
out LOW_P vec4 v_color;
#else
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
#endif
varying vec2 v_maskTexCoord;
out vec2 v_maskTexCoord;
const float kBaseDepthShift = -10.0;
@ -23,7 +23,7 @@ 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;
@ -33,7 +33,7 @@ void main()
#endif
vec2 colorTexCoord = mix(a_colorTexCoord, a_outlineColorTexCoord, isOutline);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, colorTexCoord);
v_color = texture(u_colorTex, colorTexCoord);
#else
v_colorTexCoord = colorTexCoord;
#endif

View file

@ -1,11 +1,13 @@
uniform sampler2D u_colorTex;
uniform float u_opacity;
varying vec2 v_colorTexCoords;
in vec2 v_colorTexCoords;
out vec4 v_FragColor;
void main()
{
vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords);
vec4 finalColor = texture(u_colorTex, v_colorTexCoords);
finalColor.a *= u_opacity;
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,12 +1,12 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,11 +1,13 @@
uniform sampler2D u_colorTex;
uniform float u_opacity;
varying vec2 v_colorTexCoords;
varying float v_intensity;
in vec2 v_colorTexCoords;
in float v_intensity;
out vec4 v_FragColor;
void main()
{
vec4 finalColor = vec4(texture2D(u_colorTex, v_colorTexCoords).rgb, u_opacity);
gl_FragColor = vec4((v_intensity * 0.2 + 0.8) * finalColor.rgb, finalColor.a);
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

@ -1,13 +1,13 @@
attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
in vec4 a_position;
in vec2 a_normal;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_zScale;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,10 +1,10 @@
attribute vec2 a_position;
attribute vec2 a_colorTexCoords;
in vec2 a_position;
in vec2 a_colorTexCoords;
uniform mat4 u_modelView;
uniform mat4 u_projection;
varying vec2 v_colorTexCoords;
out vec2 v_colorTexCoords;
void main()
{

View file

@ -1,6 +1,6 @@
varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
varying float v_halfLength;
in vec2 v_colorTexCoord;
in vec2 v_maskTexCoord;
in float v_halfLength;
uniform sampler2D u_colorTex;
uniform sampler2D u_maskTex;
@ -18,11 +18,13 @@ const float kOutlineThreshold2 = 0.5;
const float kMaskOpacity = 0.7;
out vec4 v_FragColor;
void main()
{
vec4 color = texture2D(u_colorTex, v_colorTexCoord);
vec4 color = texture(u_colorTex, v_colorTexCoord);
float alphaCode = color.a;
vec4 mask = texture2D(u_maskTex, v_maskTexCoord);
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, u_darkArrowColor, step(alphaCode, 0.6)), mask.a * kMaskOpacity);
if (u_outline > 0.0)
@ -30,5 +32,5 @@ void main()
color.rgb = mix(color.rgb, u_outlineColor, step(kOutlineThreshold1, abs(v_halfLength)));
color.rgb = mix(color.rgb, u_outlineColor, smoothstep(kOutlineThreshold2, kOutlineThreshold1, abs(v_halfLength)));
}
gl_FragColor = color;
v_FragColor = color;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_colorTexCoord;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_colorTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,9 +8,9 @@ uniform mat4 u_pivotTransform;
uniform vec4 u_trafficParams;
varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
varying float v_halfLength;
out vec2 v_colorTexCoord;
out vec2 v_maskTexCoord;
out float v_halfLength;
const float kArrowVSize = 0.25;

View file

@ -2,22 +2,24 @@
// Unfortunately some CG algorithms cannot be implemented on OpenGL ES 2.0 without discarding
// fragments from depth buffer.
varying vec2 v_colorTexCoord;
varying vec3 v_radius;
in vec2 v_colorTexCoord;
in vec3 v_radius;
uniform sampler2D u_colorTex;
uniform float u_opacity;
const float kAntialiasingThreshold = 0.92;
out vec4 v_FragColor;
void main()
{
vec4 color = texture2D(u_colorTex, v_colorTexCoord);
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;
gl_FragColor = color;
v_FragColor = color;
}

View file

@ -1,6 +1,6 @@
attribute vec4 a_position;
attribute vec4 a_normal;
attribute vec2 a_colorTexCoord;
in vec4 a_position;
in vec4 a_normal;
in vec2 a_colorTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -9,8 +9,8 @@ uniform mat4 u_pivotTransform;
uniform vec3 u_lightArrowColor; // Here we store left sizes by road classes.
uniform vec3 u_darkArrowColor; // Here we store right sizes by road classes.
varying vec2 v_colorTexCoord;
varying vec3 v_radius;
out vec2 v_colorTexCoord;
out vec3 v_radius;
void main()
{

View file

@ -1,10 +1,12 @@
uniform sampler2D u_colorTex;
uniform float u_opacity;
varying vec2 v_colorTexCoord;
in vec2 v_colorTexCoord;
out vec4 v_FragColor;
void main()
{
vec4 color = texture2D(u_colorTex, v_colorTexCoord);
gl_FragColor = vec4(color.rgb, u_opacity);
vec4 color = texture(u_colorTex, v_colorTexCoord);
v_FragColor = vec4(color.rgb, u_opacity);
}

View file

@ -1,11 +1,11 @@
attribute vec3 a_position;
attribute vec2 a_colorTexCoord;
in vec3 a_position;
in vec2 a_colorTexCoord;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
varying vec2 v_colorTexCoord;
out vec2 v_colorTexCoord;
void main()
{

View file

@ -1,10 +1,8 @@
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec4 v_color;
varying vec4 v_color;
out vec4 v_FragColor;
void main()
{
gl_FragColor = samsungGoogleNexusWorkaround(v_color);
v_FragColor = v_color;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_color;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,7 +8,7 @@ uniform mat4 u_pivotTransform;
uniform float u_lineHalfWidth;
varying vec4 v_color;
out vec4 v_color;
void main()
{

View file

@ -2,15 +2,13 @@
// Unfortunately some CG algorithms cannot be implemented on OpenGL ES 2.0 without discarding
// fragments from depth buffer.
varying vec3 v_radius;
varying vec4 v_color;
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec3 v_radius;
in vec4 v_color;
const float aaPixelsCount = 2.5;
out vec4 v_FragColor;
void main()
{
vec4 finalColor = v_color;
@ -21,5 +19,5 @@ void main()
finalColor.a = finalColor.a * (1.0 - stepValue);
if (finalColor.a < 0.01)
discard;
gl_FragColor = samsungGoogleNexusWorkaround(finalColor);
v_FragColor = finalColor;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_color;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -9,8 +9,8 @@ uniform mat4 u_pivotTransform;
uniform float u_lineHalfWidth;
uniform float u_maxRadius;
varying vec3 v_radius;
varying vec4 v_color;
out vec3 v_radius;
out vec4 v_color;
void main()
{

View file

@ -1,9 +1,7 @@
#ifdef SAMSUNG_GOOGLE_NEXUS
uniform sampler2D u_colorTex;
#endif
in vec4 v_offsets;
in vec4 v_color;
varying vec4 v_offsets;
varying vec4 v_color;
out vec4 v_FragColor;
void main()
{
@ -17,5 +15,5 @@ void main()
float stepValue = smoothstep(aaRadius * aaRadius, maxRadius * maxRadius, dot(radius.xy, radius.xy));
finalColor.a = finalColor.a * (1.0 - stepValue);
gl_FragColor = samsungGoogleNexusWorkaround(finalColor);
v_FragColor = finalColor;
}

View file

@ -1,6 +1,6 @@
attribute vec3 a_position;
attribute vec4 a_normal;
attribute vec4 a_color;
in vec3 a_position;
in vec4 a_normal;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
@ -8,8 +8,8 @@ uniform mat4 u_pivotTransform;
uniform vec3 u_params;
varying vec4 v_offsets;
varying vec4 v_color;
out vec4 v_offsets;
out vec4 v_color;
void main()
{

View file

@ -5,16 +5,18 @@
uniform sampler2D u_colorTex;
uniform float u_opacity;
varying vec4 v_texCoords;
varying vec4 v_maskColor;
in vec4 v_texCoords;
in vec4 v_maskColor;
out vec4 v_FragColor;
void main()
{
vec4 color = texture2D(u_colorTex, v_texCoords.xy);
vec4 bgColor = texture2D(u_colorTex, v_texCoords.zw) * vec4(v_maskColor.xyz, 1.0);
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;
gl_FragColor = finalColor;
v_FragColor = finalColor;
}

View file

@ -1,15 +1,15 @@
attribute vec3 a_position;
attribute vec3 a_normalAndAnimateOrZ;
attribute vec4 a_texCoords;
attribute vec4 a_color;
in vec3 a_position;
in vec3 a_normalAndAnimateOrZ;
in vec4 a_texCoords;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_interpolation;
varying vec4 v_texCoords;
varying vec4 v_maskColor;
out vec4 v_texCoords;
out vec4 v_maskColor;
void main()
{

View file

@ -1,15 +1,15 @@
attribute vec3 a_position;
attribute vec3 a_normalAndAnimateOrZ;
attribute vec4 a_texCoords;
attribute vec4 a_color;
in vec3 a_position;
in vec3 a_normalAndAnimateOrZ;
in vec4 a_texCoords;
in vec4 a_color;
uniform mat4 u_modelView;
uniform mat4 u_projection;
uniform mat4 u_pivotTransform;
uniform float u_interpolation;
varying vec4 v_texCoords;
varying vec4 v_maskColor;
out vec4 v_texCoords;
out vec4 v_maskColor;
void main()
{

View file

@ -15,7 +15,7 @@ GLProgramPool::GLProgramPool(dp::ApiVersion apiVersion)
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
{
#if defined(OMIM_OS_DESKTOP) && !defined(OMIM_OS_LINUX)
m_baseDefines = std::string(GL3_SHADER_VERSION) + "#define GLES3\n";
m_baseDefines = std::string(GL3_SHADER_VERSION);
#else
m_baseDefines = std::string(GLES3_SHADER_VERSION);
#endif

View file

@ -10,8 +10,6 @@ MEDIUMP_SEARCH = "mediump"
HIGHP_SEARCH = "highp"
VERTEX_SHADER_EXT = ".vsh.glsl"
FRAG_SHADER_EXT = ".fsh.glsl"
GLES3_PREFIX = "GLES3_"
GLES3_SHADER_PREFIX = "gles3_"
SHADERS_LIB_COMMON_PATTERN = "// Common"
SHADERS_LIB_VS_PATTERN = "// VS"
@ -164,7 +162,7 @@ def get_shaders_lib_content(shader_file, shaders_library):
return lib_content
def write_shader_line(output_file, line, convert_to_gles3, is_fragment_shader):
def write_shader_line(output_file, line):
if line.lstrip().startswith("//") or line == '\n' or len(line) == 0:
return
@ -179,54 +177,34 @@ def write_shader_line(output_file, line, convert_to_gles3, is_fragment_shader):
exit(2)
output_line = line.rstrip()
if convert_to_gles3:
output_line = output_line.replace("attribute", "in")
if is_fragment_shader:
output_line = output_line.replace("varying", "in")
else:
output_line = output_line.replace("varying", "out")
output_line = output_line.replace("texture2D", "texture")
output_line = output_line.replace("gl_FragColor", "v_FragColor")
output_file.write(" %s \\n\\\n" % output_line)
def write_shader_body(output_file, shader_file, shader_dir, shaders_library, convert_to_gles3):
is_fragment_shader = shader_file.find(FRAG_SHADER_EXT) >= 0
def write_shader_body(output_file, shader_file, shader_dir, shaders_library):
lib_content = get_shaders_lib_content(shader_file, shaders_library)
for line in open(os.path.join(shader_dir, shader_file)):
if line.lstrip().startswith("void main"):
for lib_line in lib_content.splitlines():
write_shader_line(output_file, lib_line, convert_to_gles3, is_fragment_shader)
if convert_to_gles3 and is_fragment_shader:
output_file.write(" out vec4 v_FragColor; \\n\\\n")
write_shader_line(output_file, line, convert_to_gles3, is_fragment_shader)
write_shader_line(output_file, lib_line)
write_shader_line(output_file, line)
output_file.write("\";\n\n")
def write_shader(output_file, shader_file, shader_dir, shaders_library):
output_file.write("char const %s[] = \" \\\n" % (format_shader_source_name(shader_file)))
output_file.write("char const %s[] = \" \\\n" % format_shader_source_name(shader_file))
write_shader_gles_header(output_file)
write_shader_body(output_file, shader_file, shader_dir, shaders_library, False)
write_shader_body(output_file, shader_file, shader_dir, shaders_library)
def write_gles3_shader(output_file, shader_file, shader_dir, shaders_library):
output_file.write("char const %s[] = \" \\\n" % (GLES3_PREFIX + format_shader_source_name(shader_file)))
write_shader_gles_header(output_file)
if os.path.exists(os.path.join(shader_dir, GLES3_SHADER_PREFIX + shader_file)):
write_shader_body(output_file, GLES3_SHADER_PREFIX + shader_file, shader_dir, shaders_library, False)
else:
write_shader_body(output_file, shader_file, shader_dir, shaders_library, True)
def write_gpu_programs_map(file, programs_def, source_prefix):
def write_gpu_programs_map(file, programs_def):
for program in programs_def.keys():
vertex_shader = programs_def[program][0]
vertex_source_name = source_prefix + format_shader_source_name(vertex_shader)
vertex_source_name = format_shader_source_name(vertex_shader)
fragment_shader = programs_def[program][1]
fragment_source_name = source_prefix + format_shader_source_name(fragment_shader)
fragment_source_name = format_shader_source_name(fragment_shader)
file.write(" GLProgramInfo(\"%s\", \"%s\", %s, %s),\n" % (
file.write(" GLProgramInfo(\"%s\", \"%s\", %s, %s),\n" % (
vertex_source_name, fragment_source_name, vertex_source_name, fragment_source_name))
@ -243,25 +221,19 @@ def write_implementation_file(programs_def, shader_index, shader_dir, impl_file,
file.write("namespace gpu\n")
file.write("{\n")
# TODO: Drop this GL3_SHADER_VERSION once MacOS code has been migrated to Metal
file.write("char const * GL3_SHADER_VERSION = \"#version 150 core \\n\";\n")
file.write("char const * GLES3_SHADER_VERSION = \"#version 300 es \\n\";\n\n")
for shader in shader_index.keys():
write_shader(file, shader, shader_dir, shaders_library)
write_gles3_shader(file, shader, shader_dir, shaders_library)
file.write("GLProgramInfo GetProgramInfo(dp::ApiVersion apiVersion, Program program)\n")
file.write("{\n")
file.write(" if (apiVersion == dp::ApiVersion::OpenGLES3)\n") # TODO: remove
file.write(" {\n")
file.write(" static std::array<GLProgramInfo, static_cast<size_t>(Program::ProgramsCount)> gpuIndex = {{\n")
write_gpu_programs_map(file, programs_def, GLES3_PREFIX)
file.write(" }};\n")
file.write(" return gpuIndex[static_cast<size_t>(program)];\n")
file.write(" }\n")
file.write(" CHECK(false, (\"Unsupported API version.\"));\n")
file.write(" return {};\n")
file.write(" CHECK_EQUAL(apiVersion, dp::ApiVersion::OpenGLES3, ());\n")
file.write(" static std::array<GLProgramInfo, static_cast<size_t>(Program::ProgramsCount)> gpuIndex = {{\n")
write_gpu_programs_map(file, programs_def)
file.write(" }};\n")
file.write(" return gpuIndex[static_cast<size_t>(program)];\n")
file.write("}\n")
file.write("} // namespace gpu\n")

View file

@ -69,13 +69,7 @@ void ProgramManager::InitForOpenGL(ref_ptr<dp::GraphicsContext> context)
}
#endif
if (dp::SupportManager::Instance().IsSamsungGoogleNexus())
globalDefines.append("#define SAMSUNG_GOOGLE_NEXUS\n");
auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES3)
globalDefines.append("#define GLES3\n");
m_pool = make_unique_dp<GLProgramPool>(apiVersion);
ref_ptr<GLProgramPool> pool = make_ref(m_pool);
pool->SetDefines(globalDefines);

View file

@ -150,14 +150,12 @@ void CompileShaders(CompilerData const & compiler, std::string const & additiona
args << fileName;
};
std::string const defines = compiler.m_apiVersion == dp::ApiVersion::OpenGLES3 ?
"#define GLES3\n" + additionalDefines : additionalDefines;
TestShaders(compiler.m_apiVersion, defines, ".vert", GetVertexShaders(compiler.m_apiVersion),
TestShaders(compiler.m_apiVersion, additionalDefines, ".vert", GetVertexShaders(compiler.m_apiVersion),
compilerPath, [](QProcess const &) {}, argsPrepareFn, successChecker, ss);
TestShaders(compiler.m_apiVersion, defines, ".frag", GetFragmentShaders(compiler.m_apiVersion),
TestShaders(compiler.m_apiVersion, additionalDefines, ".frag", GetFragmentShaders(compiler.m_apiVersion),
compilerPath, [](QProcess const &) {}, argsPrepareFn, successChecker, ss);
TEST_EQUAL(errorLog.isEmpty(), true, ("Defines:", defines, additionalDefines, "\n", errorLog));
TEST_EQUAL(errorLog.isEmpty(), true, ("Defines:", additionalDefines, "\n", errorLog));
}
UNIT_TEST(MobileCompileShaders_Test)
@ -173,11 +171,6 @@ UNIT_TEST(MobileCompileShaders_Test)
"#define ENABLE_VTF\n");
});
workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)},
"#define SAMSUNG_GOOGLE_NEXUS\n");
});
workerThread.Shutdown(base::DelayedThreadPool::Exit::ExecPending);
}
@ -223,19 +216,16 @@ void MaliCompileShaders(MaliCompilerData const & compiler, MaliDriverSet const &
<< "-r" << version.m_version << "-c" << version.m_series << "-d" << driverSet.m_driverName
<< fileName;
};
std::string const defines =
compiler.m_apiVersion == dp::ApiVersion::OpenGLES3 ? "#define GLES3\n" : "";
QString const compilerPath = QString::fromStdString(compiler.m_compilerPath);
TestShaders(compiler.m_apiVersion, defines, {}, GetVertexShaders(compiler.m_apiVersion),
TestShaders(compiler.m_apiVersion, "", {}, GetVertexShaders(compiler.m_apiVersion),
compilerPath, procPrepare, argForming, successChecker, ss);
shaderType = "-f";
TestShaders(compiler.m_apiVersion, defines, {}, GetFragmentShaders(compiler.m_apiVersion),
TestShaders(compiler.m_apiVersion, "", {}, GetFragmentShaders(compiler.m_apiVersion),
compilerPath, procPrepare, argForming, successChecker, ss);
TEST(errorLog.isEmpty(),
(shaderType, version.m_series, version.m_version, driverSet.m_driverName, defines, errorLog));
(shaderType, version.m_series, version.m_version, driverSet.m_driverName, "", errorLog));
// MALI GPUs do not support ENABLE_VTF. Do not test it here.
// SAMSUNG_GOOGLE_NEXUS doesn't use Mali GPU. Do not test it here.
}
UNIT_TEST(MALI_MobileCompileShaders_Test)