aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/shaders
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2013-10-26 18:48:56 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-31 12:54:28 +0100
commit426f6aa672b94d8324321bc6c6d4f1a358eebedc (patch)
tree8af3e5b0aa2fdcdb7655672669f5ae277151cc3d /src/quick/scenegraph/shaders
parent34c85bb56c92316a6ce1c79d25f9653fec14791c (diff)
Refactor shaders into seprate GLSL source files
The default implementation of QSGShaderMaterial::vertexShader() and fragmentShader() now loads the GLSL source from a list of source files that can be specified via the setShaderSourceFile() or setShaderSourceFiles() functions. Multiple shader source files for each shader stage are supported. Each source file will be read in the order specified and concatenated together before being compiled. The other places where Qt Quick 2 loads shader source code have been adapted to use the new QSGShaderSourceBuilder, which is also used internally by QSGMaterial. This puts Qt Quick 2 into a better state ready to support OpenGL core profile and to load different shaders based upon OpenGL version, profile, GPU vendor, platform, etc. Change-Id: I1a66213c2ce788413168eb48c7bc5317e61988a2 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/quick/scenegraph/shaders')
-rw-r--r--src/quick/scenegraph/shaders/24bittextmask.frag10
-rw-r--r--src/quick/scenegraph/shaders/8bittextmask.frag9
-rw-r--r--src/quick/scenegraph/shaders/distancefieldoutlinetext.frag16
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext.frag17
-rw-r--r--src/quick/scenegraph/shaders/distancefieldshiftedtext.vert17
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext.frag13
-rw-r--r--src/quick/scenegraph/shaders/distancefieldtext.vert13
-rw-r--r--src/quick/scenegraph/shaders/flatcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/flatcolor.vert7
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag58
-rw-r--r--src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert34
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag17
-rw-r--r--src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert27
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture.frag8
-rw-r--r--src/quick/scenegraph/shaders/opaquetexture.vert12
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext.frag21
-rw-r--r--src/quick/scenegraph/shaders/outlinedtext.vert22
-rw-r--r--src/quick/scenegraph/shaders/rendernode.frag8
-rw-r--r--src/quick/scenegraph/shaders/rendernode.vert10
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/smoothcolor.vert45
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture.frag9
-rw-r--r--src/quick/scenegraph/shaders/smoothtexture.vert52
-rw-r--r--src/quick/scenegraph/shaders/stencilclip.frag4
-rw-r--r--src/quick/scenegraph/shaders/stencilclip.vert8
-rw-r--r--src/quick/scenegraph/shaders/styledtext.frag14
-rw-r--r--src/quick/scenegraph/shaders/styledtext.vert16
-rw-r--r--src/quick/scenegraph/shaders/textmask.frag10
-rw-r--r--src/quick/scenegraph/shaders/textmask.vert13
-rw-r--r--src/quick/scenegraph/shaders/texture.frag9
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor.frag6
-rw-r--r--src/quick/scenegraph/shaders/vertexcolor.vert13
32 files changed, 530 insertions, 0 deletions
diff --git a/src/quick/scenegraph/shaders/24bittextmask.frag b/src/quick/scenegraph/shaders/24bittextmask.frag
new file mode 100644
index 0000000000..ac62e7b642
--- /dev/null
+++ b/src/quick/scenegraph/shaders/24bittextmask.frag
@@ -0,0 +1,10 @@
+varying highp vec2 sampleCoord;
+
+uniform lowp sampler2D texture;
+uniform lowp float color; // just the alpha, really...
+
+void main()
+{
+ lowp vec4 glyph = texture2D(texture, sampleCoord);
+ gl_FragColor = vec4(glyph.rgb * color, glyph.a);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/8bittextmask.frag b/src/quick/scenegraph/shaders/8bittextmask.frag
new file mode 100644
index 0000000000..f2f06e8e07
--- /dev/null
+++ b/src/quick/scenegraph/shaders/8bittextmask.frag
@@ -0,0 +1,9 @@
+varying highp vec2 sampleCoord;
+
+uniform lowp sampler2D texture;
+uniform lowp vec4 color;
+
+void main()
+{
+ gl_FragColor = color * texture2D(texture, sampleCoord).a;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag b/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag
new file mode 100644
index 0000000000..250ed322a1
--- /dev/null
+++ b/src/quick/scenegraph/shaders/distancefieldoutlinetext.frag
@@ -0,0 +1,16 @@
+varying highp vec2 sampleCoord;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform lowp vec4 styleColor;
+uniform mediump float alphaMin;
+uniform mediump float alphaMax;
+uniform mediump float outlineAlphaMax0;
+uniform mediump float outlineAlphaMax1;
+
+void main()
+{
+ mediump float d = texture2D(_qt_texture, sampleCoord).a;
+ gl_FragColor = mix(styleColor, color, smoothstep(alphaMin, alphaMax, d))
+ * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag b/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag
new file mode 100644
index 0000000000..60c1c7468b
--- /dev/null
+++ b/src/quick/scenegraph/shaders/distancefieldshiftedtext.frag
@@ -0,0 +1,17 @@
+varying highp vec2 sampleCoord;
+varying highp vec2 shiftedSampleCoord;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform lowp vec4 styleColor;
+uniform mediump float alphaMin;
+uniform mediump float alphaMax;
+
+void main()
+{
+ highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a);
+ highp vec4 shifted = styleColor * smoothstep(alphaMin,
+ alphaMax,
+ texture2D(_qt_texture, shiftedSampleCoord).a);
+ gl_FragColor = mix(shifted, color, a);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert b/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert
new file mode 100644
index 0000000000..800eadc4f1
--- /dev/null
+++ b/src/quick/scenegraph/shaders/distancefieldshiftedtext.vert
@@ -0,0 +1,17 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+uniform highp vec2 shift;
+
+varying highp vec2 sampleCoord;
+varying highp vec2 shiftedSampleCoord;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ shiftedSampleCoord = (tCoord - shift) * textureScale;
+ gl_Position = matrix * vCoord;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext.frag b/src/quick/scenegraph/shaders/distancefieldtext.frag
new file mode 100644
index 0000000000..951fb2a825
--- /dev/null
+++ b/src/quick/scenegraph/shaders/distancefieldtext.frag
@@ -0,0 +1,13 @@
+varying highp vec2 sampleCoord;
+
+uniform mediump sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform mediump float alphaMin;
+uniform mediump float alphaMax;
+
+void main()
+{
+ gl_FragColor = color * smoothstep(alphaMin,
+ alphaMax,
+ texture2D(_qt_texture, sampleCoord).a);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/distancefieldtext.vert b/src/quick/scenegraph/shaders/distancefieldtext.vert
new file mode 100644
index 0000000000..c4963977a5
--- /dev/null
+++ b/src/quick/scenegraph/shaders/distancefieldtext.vert
@@ -0,0 +1,13 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec2 sampleCoord;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ gl_Position = matrix * vCoord;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/flatcolor.frag b/src/quick/scenegraph/shaders/flatcolor.frag
new file mode 100644
index 0000000000..8c225bf5a4
--- /dev/null
+++ b/src/quick/scenegraph/shaders/flatcolor.frag
@@ -0,0 +1,6 @@
+uniform lowp vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/flatcolor.vert b/src/quick/scenegraph/shaders/flatcolor.vert
new file mode 100644
index 0000000000..a61de97f85
--- /dev/null
+++ b/src/quick/scenegraph/shaders/flatcolor.vert
@@ -0,0 +1,7 @@
+attribute highp vec4 vCoord;
+uniform highp mat4 matrix;
+
+void main()
+{
+ gl_Position = matrix * vCoord;
+}
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag
new file mode 100644
index 0000000000..9b65e5f79b
--- /dev/null
+++ b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.frag
@@ -0,0 +1,58 @@
+varying highp vec2 sampleCoord;
+varying highp vec3 sampleFarLeft;
+varying highp vec3 sampleNearLeft;
+varying highp vec3 sampleNearRight;
+varying highp vec3 sampleFarRight;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform mediump float alphaMin;
+uniform mediump float alphaMax;
+
+void main()
+{
+ highp vec4 n;
+ n.x = texture2DProj(_qt_texture, sampleFarLeft).a;
+ n.y = texture2DProj(_qt_texture, sampleNearLeft).a;
+ highp float c = texture2D(_qt_texture, sampleCoord).a;
+ n.z = texture2DProj(_qt_texture, sampleNearRight).a;
+ n.w = texture2DProj(_qt_texture, sampleFarRight).a;
+#if 0
+ // Blurrier, faster.
+ n = smoothstep(alphaMin, alphaMax, n);
+ c = smoothstep(alphaMin, alphaMax, c);
+#else
+ // Sharper, slower.
+ highp vec2 d = min(abs(n.yw - n.xz) * 2., 0.67);
+ highp vec2 lo = mix(vec2(alphaMin), vec2(0.5), d);
+ highp vec2 hi = mix(vec2(alphaMax), vec2(0.5), d);
+ n = smoothstep(lo.xxyy, hi.xxyy, n);
+ c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c);
+#endif
+ gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w;
+}
+
+/*
+#extension GL_OES_standard_derivatives: enable
+
+varying highp vec2 sampleCoord;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform highp float alphaMin;
+uniform highp float alphaMax;
+
+void main()
+{
+ highp vec2 delta = dFdx(sampleCoord);
+ highp vec4 n;
+ n.x = texture2D(_qt_texture, sampleCoord - 0.667 * delta).a;
+ n.y = texture2D(_qt_texture, sampleCoord - 0.333 * delta).a;
+ highp float c = texture2D(_qt_texture, sampleCoord).a;
+ n.z = texture2D(_qt_texture, sampleCoord + 0.333 * delta).a;
+ n.w = texture2D(_qt_texture, sampleCoord + 0.667 * delta).a;
+ n = smoothstep(alphaMin, alphaMax, n);
+ c = smoothstep(alphaMin, alphaMax, c);
+ gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w;
+};
+*/ \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert
new file mode 100644
index 0000000000..62768e88e1
--- /dev/null
+++ b/src/quick/scenegraph/shaders/hiqsubpixeldistancefieldtext.vert
@@ -0,0 +1,34 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+uniform highp float fontScale;
+uniform highp vec4 vecDelta;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec2 sampleCoord;
+varying highp vec3 sampleFarLeft;
+varying highp vec3 sampleNearLeft;
+varying highp vec3 sampleNearRight;
+varying highp vec3 sampleFarRight;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ gl_Position = matrix * vCoord;
+
+ // Calculate neighbor pixel position in item space.
+ highp vec3 wDelta = gl_Position.w * vecDelta.xyw;
+ highp vec3 farLeft = vCoord.xyw - 0.667 * wDelta;
+ highp vec3 nearLeft = vCoord.xyw - 0.333 * wDelta;
+ highp vec3 nearRight = vCoord.xyw + 0.333 * wDelta;
+ highp vec3 farRight = vCoord.xyw + 0.667 * wDelta;
+
+ // Calculate neighbor texture coordinate.
+ highp vec2 scale = textureScale / fontScale;
+ highp vec2 base = sampleCoord - scale * vCoord.xy;
+ sampleFarLeft = vec3(base * farLeft.z + scale * farLeft.xy, farLeft.z);
+ sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
+ sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
+ sampleFarRight = vec3(base * farRight.z + scale * farRight.xy, farRight.z);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag
new file mode 100644
index 0000000000..61b6c8dd9a
--- /dev/null
+++ b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.frag
@@ -0,0 +1,17 @@
+varying highp vec3 sampleNearLeft;
+varying highp vec3 sampleNearRight;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform mediump float alphaMin;
+uniform mediump float alphaMax;
+
+void main()
+{
+ highp vec2 n;
+ n.x = texture2DProj(_qt_texture, sampleNearLeft).a;
+ n.y = texture2DProj(_qt_texture, sampleNearRight).a;
+ n = smoothstep(alphaMin, alphaMax, n);
+ highp float c = 0.5 * (n.x + n.y);
+ gl_FragColor = vec4(n.x, c, n.y, c) * color.w;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert
new file mode 100644
index 0000000000..33cb7efb19
--- /dev/null
+++ b/src/quick/scenegraph/shaders/loqsubpixeldistancefieldtext.vert
@@ -0,0 +1,27 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+uniform highp float fontScale;
+uniform highp vec4 vecDelta;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec3 sampleNearLeft;
+varying highp vec3 sampleNearRight;
+
+void main()
+{
+ highp vec2 sampleCoord = tCoord * textureScale;
+ gl_Position = matrix * vCoord;
+
+ // Calculate neighbor pixel position in item space.
+ highp vec3 wDelta = gl_Position.w * vecDelta.xyw;
+ highp vec3 nearLeft = vCoord.xyw - 0.25 * wDelta;
+ highp vec3 nearRight = vCoord.xyw + 0.25 * wDelta;
+
+ // Calculate neighbor texture coordinate.
+ highp vec2 scale = textureScale / fontScale;
+ highp vec2 base = sampleCoord - scale * vCoord.xy;
+ sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z);
+ sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture.frag b/src/quick/scenegraph/shaders/opaquetexture.frag
new file mode 100644
index 0000000000..b7e07de385
--- /dev/null
+++ b/src/quick/scenegraph/shaders/opaquetexture.frag
@@ -0,0 +1,8 @@
+varying highp vec2 qt_TexCoord;
+
+uniform sampler2D qt_Texture;
+
+void main()
+{
+ gl_FragColor = texture2D(qt_Texture, qt_TexCoord);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/opaquetexture.vert b/src/quick/scenegraph/shaders/opaquetexture.vert
new file mode 100644
index 0000000000..32cf02df25
--- /dev/null
+++ b/src/quick/scenegraph/shaders/opaquetexture.vert
@@ -0,0 +1,12 @@
+uniform highp mat4 qt_Matrix;
+
+attribute highp vec4 qt_VertexPosition;
+attribute highp vec2 qt_VertexTexCoord;
+
+varying highp vec2 qt_TexCoord;
+
+void main()
+{
+ qt_TexCoord = qt_VertexTexCoord;
+ gl_Position = qt_Matrix * qt_VertexPosition;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext.frag b/src/quick/scenegraph/shaders/outlinedtext.frag
new file mode 100644
index 0000000000..b3e5475d5d
--- /dev/null
+++ b/src/quick/scenegraph/shaders/outlinedtext.frag
@@ -0,0 +1,21 @@
+varying highp vec2 sampleCoord;
+varying highp vec2 sCoordUp;
+varying highp vec2 sCoordDown;
+varying highp vec2 sCoordLeft;
+varying highp vec2 sCoordRight;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform lowp vec4 styleColor;
+
+void main()
+{
+ lowp float glyph = texture2D(_qt_texture, sampleCoord).a;
+ lowp float outline = clamp(clamp(texture2D(_qt_texture, sCoordUp).a +
+ texture2D(_qt_texture, sCoordDown).a +
+ texture2D(_qt_texture, sCoordLeft).a +
+ texture2D(_qt_texture, sCoordRight).a,
+ 0.0, 1.0) - glyph,
+ 0.0, 1.0);
+ gl_FragColor = outline * styleColor + glyph * color;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/outlinedtext.vert b/src/quick/scenegraph/shaders/outlinedtext.vert
new file mode 100644
index 0000000000..ced8afd034
--- /dev/null
+++ b/src/quick/scenegraph/shaders/outlinedtext.vert
@@ -0,0 +1,22 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+uniform highp vec2 shift;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec2 sampleCoord;
+varying highp vec2 sCoordUp;
+varying highp vec2 sCoordDown;
+varying highp vec2 sCoordLeft;
+varying highp vec2 sCoordRight;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ sCoordUp = (tCoord - vec2(0.0, -1.0)) * textureScale;
+ sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale;
+ sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale;
+ sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale;
+ gl_Position = matrix * vCoord;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/rendernode.frag b/src/quick/scenegraph/shaders/rendernode.frag
new file mode 100644
index 0000000000..b4e9b0209c
--- /dev/null
+++ b/src/quick/scenegraph/shaders/rendernode.frag
@@ -0,0 +1,8 @@
+uniform lowp sampler2D tex;
+
+varying highp vec2 t;
+
+void main()
+{
+ gl_FragColor = texture2D(tex, t);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/rendernode.vert b/src/quick/scenegraph/shaders/rendernode.vert
new file mode 100644
index 0000000000..fbfe9ef8ae
--- /dev/null
+++ b/src/quick/scenegraph/shaders/rendernode.vert
@@ -0,0 +1,10 @@
+attribute highp vec4 av;
+attribute highp vec2 at;
+
+varying highp vec2 t;
+
+void main()
+{
+ gl_Position = av;
+ t = at;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor.frag b/src/quick/scenegraph/shaders/smoothcolor.frag
new file mode 100644
index 0000000000..71de9dbfc2
--- /dev/null
+++ b/src/quick/scenegraph/shaders/smoothcolor.frag
@@ -0,0 +1,6 @@
+varying lowp vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothcolor.vert b/src/quick/scenegraph/shaders/smoothcolor.vert
new file mode 100644
index 0000000000..df70fea92a
--- /dev/null
+++ b/src/quick/scenegraph/shaders/smoothcolor.vert
@@ -0,0 +1,45 @@
+uniform highp vec2 pixelSize;
+uniform highp mat4 matrix;
+uniform lowp float opacity;
+
+attribute highp vec4 vertex;
+attribute lowp vec4 vertexColor;
+attribute highp vec2 vertexOffset;
+
+varying lowp vec4 color;
+
+void main()
+{
+ highp vec4 pos = matrix * vertex;
+ gl_Position = pos;
+
+ if (vertexOffset.x != 0.) {
+ highp vec4 delta = matrix[0] * vertexOffset.x;
+ highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
+ highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
+ dir -= ndir * delta.w * pos.w;
+ highp float numerator = dot(dir, ndir * pos.w * pos.w);
+ highp float scale = 0.0;
+ if (numerator < 0.0)
+ scale = 1.0;
+ else
+ scale = min(1.0, numerator / dot(dir, dir));
+ gl_Position += scale * delta;
+ }
+
+ if (vertexOffset.y != 0.) {
+ highp vec4 delta = matrix[1] * vertexOffset.y;
+ highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
+ highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
+ dir -= ndir * delta.w * pos.w;
+ highp float numerator = dot(dir, ndir * pos.w * pos.w);
+ highp float scale = 0.0;
+ if (numerator < 0.0)
+ scale = 1.0;
+ else
+ scale = min(1.0, numerator / dot(dir, dir));
+ gl_Position += scale * delta;
+ }
+
+ color = vertexColor * opacity;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture.frag b/src/quick/scenegraph/shaders/smoothtexture.frag
new file mode 100644
index 0000000000..e4f6359f3d
--- /dev/null
+++ b/src/quick/scenegraph/shaders/smoothtexture.frag
@@ -0,0 +1,9 @@
+uniform sampler2D qt_Texture;
+
+varying highp vec2 texCoord;
+varying lowp float vertexOpacity;
+
+void main()
+{
+ gl_FragColor = texture2D(qt_Texture, texCoord) * vertexOpacity;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/smoothtexture.vert b/src/quick/scenegraph/shaders/smoothtexture.vert
new file mode 100644
index 0000000000..1ce824a68f
--- /dev/null
+++ b/src/quick/scenegraph/shaders/smoothtexture.vert
@@ -0,0 +1,52 @@
+uniform highp vec2 pixelSize;
+uniform highp mat4 qt_Matrix;
+uniform lowp float opacity;
+
+attribute highp vec4 vertex;
+attribute highp vec2 multiTexCoord;
+attribute highp vec2 vertexOffset;
+attribute highp vec2 texCoordOffset;
+
+varying highp vec2 texCoord;
+varying lowp float vertexOpacity;
+
+void main()
+{
+ highp vec4 pos = qt_Matrix * vertex;
+ gl_Position = pos;
+ texCoord = multiTexCoord;
+
+ if (vertexOffset.x != 0.) {
+ highp vec4 delta = qt_Matrix[0] * vertexOffset.x;
+ highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
+ highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
+ dir -= ndir * delta.w * pos.w;
+ highp float numerator = dot(dir, ndir * pos.w * pos.w);
+ highp float scale = 0.0;
+ if (numerator < 0.0)
+ scale = 1.0;
+ else
+ scale = min(1.0, numerator / dot(dir, dir));
+ gl_Position += scale * delta;
+ texCoord.x += scale * texCoordOffset.x;
+ }
+
+ if (vertexOffset.y != 0.) {
+ highp vec4 delta = qt_Matrix[1] * vertexOffset.y;
+ highp vec2 dir = delta.xy * pos.w - pos.xy * delta.w;
+ highp vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize);
+ dir -= ndir * delta.w * pos.w;
+ highp float numerator = dot(dir, ndir * pos.w * pos.w);
+ highp float scale = 0.0;
+ if (numerator < 0.0)
+ scale = 1.0;
+ else
+ scale = min(1.0, numerator / dot(dir, dir));
+ gl_Position += scale * delta;
+ texCoord.y += scale * texCoordOffset.y;
+ }
+
+ bool onEdge = any(notEqual(vertexOffset, vec2(0.)));
+ bool outerEdge = all(equal(texCoordOffset, vec2(0.)));
+ vertexOpacity = onEdge && outerEdge ? 0. : opacity;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/stencilclip.frag b/src/quick/scenegraph/shaders/stencilclip.frag
new file mode 100644
index 0000000000..70b7717977
--- /dev/null
+++ b/src/quick/scenegraph/shaders/stencilclip.frag
@@ -0,0 +1,4 @@
+void main()
+{
+ gl_FragColor = vec4(0.81, 0.83, 0.12, 1.0); // Trolltech green ftw!
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/stencilclip.vert b/src/quick/scenegraph/shaders/stencilclip.vert
new file mode 100644
index 0000000000..0e546c8112
--- /dev/null
+++ b/src/quick/scenegraph/shaders/stencilclip.vert
@@ -0,0 +1,8 @@
+attribute highp vec4 vCoord;
+
+uniform highp mat4 matrix;
+
+void main()
+{
+ gl_Position = matrix * vCoord;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/styledtext.frag b/src/quick/scenegraph/shaders/styledtext.frag
new file mode 100644
index 0000000000..662dbef2fc
--- /dev/null
+++ b/src/quick/scenegraph/shaders/styledtext.frag
@@ -0,0 +1,14 @@
+varying highp vec2 sampleCoord;
+varying highp vec2 shiftedSampleCoord;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+uniform lowp vec4 styleColor;
+
+void main()
+{
+ lowp float glyph = texture2D(_qt_texture, sampleCoord).a;
+ lowp float style = clamp(texture2D(_qt_texture, shiftedSampleCoord).a - glyph,
+ 0.0, 1.0);
+ gl_FragColor = style * styleColor + glyph * color;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/styledtext.vert b/src/quick/scenegraph/shaders/styledtext.vert
new file mode 100644
index 0000000000..3ad9497b65
--- /dev/null
+++ b/src/quick/scenegraph/shaders/styledtext.vert
@@ -0,0 +1,16 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+uniform highp vec2 shift;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec2 sampleCoord;
+varying highp vec2 shiftedSampleCoord;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ shiftedSampleCoord = (tCoord - shift) * textureScale;
+ gl_Position = matrix * vCoord;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/textmask.frag b/src/quick/scenegraph/shaders/textmask.frag
new file mode 100644
index 0000000000..7715688ecc
--- /dev/null
+++ b/src/quick/scenegraph/shaders/textmask.frag
@@ -0,0 +1,10 @@
+varying highp vec2 sampleCoord;
+
+uniform sampler2D _qt_texture;
+uniform lowp vec4 color;
+
+void main()
+{
+ lowp vec4 glyph = texture2D(_qt_texture, sampleCoord);
+ gl_FragColor = vec4(glyph.rgb * color.a, glyph.a);
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/textmask.vert b/src/quick/scenegraph/shaders/textmask.vert
new file mode 100644
index 0000000000..1f45e9cf71
--- /dev/null
+++ b/src/quick/scenegraph/shaders/textmask.vert
@@ -0,0 +1,13 @@
+uniform highp mat4 matrix;
+uniform highp vec2 textureScale;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+
+varying highp vec2 sampleCoord;
+
+void main()
+{
+ sampleCoord = tCoord * textureScale;
+ gl_Position = matrix * vCoord;
+}
diff --git a/src/quick/scenegraph/shaders/texture.frag b/src/quick/scenegraph/shaders/texture.frag
new file mode 100644
index 0000000000..2d97f2e66a
--- /dev/null
+++ b/src/quick/scenegraph/shaders/texture.frag
@@ -0,0 +1,9 @@
+varying highp vec2 qt_TexCoord;
+
+uniform sampler2D qt_Texture;
+uniform lowp float opacity;
+
+void main()
+{
+ gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * opacity;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor.frag b/src/quick/scenegraph/shaders/vertexcolor.frag
new file mode 100644
index 0000000000..71de9dbfc2
--- /dev/null
+++ b/src/quick/scenegraph/shaders/vertexcolor.frag
@@ -0,0 +1,6 @@
+varying lowp vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+} \ No newline at end of file
diff --git a/src/quick/scenegraph/shaders/vertexcolor.vert b/src/quick/scenegraph/shaders/vertexcolor.vert
new file mode 100644
index 0000000000..750d520114
--- /dev/null
+++ b/src/quick/scenegraph/shaders/vertexcolor.vert
@@ -0,0 +1,13 @@
+attribute highp vec4 vertexCoord;
+attribute highp vec4 vertexColor;
+
+uniform highp mat4 matrix;
+uniform highp float opacity;
+
+varying lowp vec4 color;
+
+void main()
+{
+ gl_Position = matrix * vertexCoord;
+ color = vertexColor * opacity;
+} \ No newline at end of file