forked from qt-creator/qt-creator
Fix timeline shaders for OpenGL ES
In OpenGL ES you have to: * Specify the precision for most values in fragment shaders * Add a special declaration to use fwidth() * Make sure both values passed to max() are of the same type (this may be the case for some Desktop OpenGL implementations, too) Repeating the default precision (highp float) in vertex shaders is useless and might lead to type casting problems, so we drop it. Without this change, the timeline doesn't work on Windows with ANGLE. Change-Id: I69a1976eddb6f4dc6dfe5fe9f270839432088cbb Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
vec4 orange = vec4(1.0, 165.0 / 255.0, 0.0, 1.0);
|
||||
varying float d;
|
||||
lowp vec4 orange = vec4(1.0, 165.0 / 255.0, 0.0, 1.0);
|
||||
varying lowp float d;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -28,17 +28,22 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef GL_OES_standard_derivatives
|
||||
#extension GL_OES_standard_derivatives : enable
|
||||
// else we probably have fwidth() in core
|
||||
#endif
|
||||
|
||||
varying lowp vec3 edgeColor;
|
||||
varying lowp vec3 color;
|
||||
varying lowp vec2 barycentric;
|
||||
|
||||
vec4 zero = vec4(0.0);
|
||||
lowp vec4 zero = vec4(0.0);
|
||||
void main()
|
||||
{
|
||||
vec2 d = fwidth(barycentric) * 5.0;
|
||||
vec4 edge_closeness = smoothstep(zero, vec4(d.x, d.y, d.x, d.y),
|
||||
lowp vec2 d = fwidth(barycentric) * 5.0;
|
||||
lowp vec4 edge_closeness = smoothstep(zero, vec4(d.x, d.y, d.x, d.y),
|
||||
vec4(barycentric.x, barycentric.y, 1.0 - barycentric.x, 1.0 - barycentric.y));
|
||||
float total = min(min(edge_closeness[0], edge_closeness[1]),
|
||||
lowp float total = min(min(edge_closeness[0], edge_closeness[1]),
|
||||
min(edge_closeness[2], edge_closeness[3]));
|
||||
// square to make lines sharper
|
||||
total = total > 0.5 ? (1.0 - (1.0 - total) * (1.0 - total) * 2.0) : total * total * 2.0;
|
||||
|
||||
@@ -47,13 +47,13 @@ void main()
|
||||
gl_Position = matrix * vertexCoord;
|
||||
|
||||
// Make very narrow events somewhat wider so that they don't collapse into 0 pixels
|
||||
highp float scaledWidth = scale.x * rectSize.x;
|
||||
highp float shift = sign(scaledWidth) * max(0, 3.0 - abs(scaledWidth)) * 0.0005;
|
||||
float scaledWidth = scale.x * rectSize.x;
|
||||
float shift = sign(scaledWidth) * max(0.0, 3.0 - abs(scaledWidth)) * 0.0005;
|
||||
gl_Position.x += shift;
|
||||
|
||||
// Ditto for events with very small height
|
||||
highp float scaledHeight = scale.y * rectSize.y;
|
||||
gl_Position.y += float(rectSize.y > 0.0) * max(0, 3.0 - scaledHeight) * 0.003;
|
||||
float scaledHeight = scale.y * rectSize.y;
|
||||
gl_Position.y += float(rectSize.y > 0.0) * max(0.0, 3.0 - scaledHeight) * 0.003;
|
||||
|
||||
barycentric = vec2(rectSize.x > 0.0 ? 1.0 : 0.0, rectSize.y > 0.0 ? 1.0 : 0.0);
|
||||
color = vertexColor.rgb;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
vec4 orange = vec4(1.0, 165.0 / 255.0, 0.0, 1.0);
|
||||
lowp vec4 orange = vec4(1.0, 165.0 / 255.0, 0.0, 1.0);
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = orange;
|
||||
|
||||
Reference in New Issue
Block a user