diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2010-11-24 10:43:11 +0100 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2010-11-24 10:43:11 +0100 |
commit | 7c236a2fa591850c03ca39a5f40b10681c094f1d (patch) | |
tree | aa1461d867f0884f5c25acae54742d825692eb8f | |
parent | e186bb978c5999d461b78bdbe64ca6dbb1b331e0 (diff) |
Make shader effects work again.scenegraph
-rw-r--r-- | src/qml/BlurEffect.qml | 20 | ||||
-rw-r--r-- | src/qml/DropShadow.qml | 13 | ||||
-rw-r--r-- | src/qml/HorizontalBlur.qml | 5 | ||||
-rw-r--r-- | src/qml/VerticalBlur.qml | 5 |
4 files changed, 23 insertions, 20 deletions
diff --git a/src/qml/BlurEffect.qml b/src/qml/BlurEffect.qml index cac15e5..89c8635 100644 --- a/src/qml/BlurEffect.qml +++ b/src/qml/BlurEffect.qml @@ -52,17 +52,17 @@ ShaderEffectItem "varying highp vec2 qt_TexCoord6; \n" + "varying highp vec2 qt_TexCoord7; \n" + "varying highp vec2 qt_TexCoord8; \n" + - "uniform sampler2D qt_Texture; \n" + + "uniform sampler2D source; \n" + "void main() { \n" + " gl_FragColor = \n" + - " (4. / 20. * texture2D(qt_Texture, qt_TexCoord) \n" + - " + 3. / 20. * texture2D(qt_Texture, qt_TexCoord2) \n" + - " + 2. / 20. * texture2D(qt_Texture, qt_TexCoord3) \n" + - " + 1. / 20. * texture2D(qt_Texture, qt_TexCoord4) \n" + - " + 4. / 20. * texture2D(qt_Texture, qt_TexCoord5) \n" + - " + 3. / 20. * texture2D(qt_Texture, qt_TexCoord6) \n" + - " + 2. / 20. * texture2D(qt_Texture, qt_TexCoord7) \n" + - " + 1. / 20. * texture2D(qt_Texture, qt_TexCoord8)); \n" + + " (4. / 20. * texture2D(source, qt_TexCoord) \n" + + " + 3. / 20. * texture2D(source, qt_TexCoord2) \n" + + " + 2. / 20. * texture2D(source, qt_TexCoord3) \n" + + " + 1. / 20. * texture2D(source, qt_TexCoord4) \n" + + " + 4. / 20. * texture2D(source, qt_TexCoord5) \n" + + " + 3. / 20. * texture2D(source, qt_TexCoord6) \n" + + " + 2. / 20. * texture2D(source, qt_TexCoord7) \n" + + " + 1. / 20. * texture2D(source, qt_TexCoord8)); \n" + "}" vertexShader: @@ -93,7 +93,7 @@ ShaderEffectItem " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}" - + property variant source property real spread: 1; property real xStep: 0 / width; property real yStep: 1 / height; diff --git a/src/qml/DropShadow.qml b/src/qml/DropShadow.qml index 1d7ef5a..576589e 100644 --- a/src/qml/DropShadow.qml +++ b/src/qml/DropShadow.qml @@ -49,13 +49,13 @@ ShaderEffectItem "varying highp vec2 my_TexCoord2; \n" + "varying highp vec2 my_TexCoord3; \n" + "varying highp vec2 my_TexCoord4; \n" + - "uniform sampler2D qt_Texture; \n" + + "uniform sampler2D source; \n" + "void main() { \n" + - " lowp vec4 pix = texture2D(qt_Texture, qt_TexCoord); \n" + - " lowp float shadow = (texture2D(qt_Texture, my_TexCoord1).w \n" + - " + texture2D(qt_Texture, my_TexCoord2).w \n" + - " + texture2D(qt_Texture, my_TexCoord3).w \n" + - " + texture2D(qt_Texture, my_TexCoord4).w) * 0.1; \n" + + " lowp vec4 pix = texture2D(source, qt_TexCoord); \n" + + " lowp float shadow = (texture2D(source, my_TexCoord1).w \n" + + " + texture2D(source, my_TexCoord2).w \n" + + " + texture2D(source, my_TexCoord3).w \n" + + " + texture2D(source, my_TexCoord4).w) * 0.1; \n" + " gl_FragColor = mix(vec4(0, 0, 0, shadow), pix, pix.w); \n" + "}" @@ -84,6 +84,7 @@ ShaderEffectItem " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}" + property variant source property real xOffset: 0.66 / width; property real yOffset: 0.66 / height; property real xDisplacement: 10 / width; diff --git a/src/qml/HorizontalBlur.qml b/src/qml/HorizontalBlur.qml index 9892ad0..19d1cb7 100644 --- a/src/qml/HorizontalBlur.qml +++ b/src/qml/HorizontalBlur.qml @@ -3,7 +3,7 @@ import QtQuick 2.0 ShaderEffectItem { fragmentShader: "varying mediump vec2 qt_TexCoord; \n" + - "uniform sampler2D qt_Texture; \n" + + "uniform sampler2D source; \n" + "uniform mediump int sampleCount; \n" + "uniform mediump float sampleDistance; \n" + "void main() { \n" + @@ -11,7 +11,7 @@ ShaderEffectItem " mediump vec2 spos = qt_TexCoord; \n" + " for (int i=0; i<sampleCount; ++i) { \n" + " spos.x += sampleDistance; \n" + - " sum += texture2D(qt_Texture, spos); \n" + + " sum += texture2D(source, spos); \n" + " } \n" + " gl_FragColor = sum / float(sampleCount); \n" + "}" @@ -29,6 +29,7 @@ ShaderEffectItem " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}" + property variant source property real sampleDistance: 1 / height property int sampleCount : 4 active: sampleCount > 1 diff --git a/src/qml/VerticalBlur.qml b/src/qml/VerticalBlur.qml index 0ed5d3a..bb41d3f 100644 --- a/src/qml/VerticalBlur.qml +++ b/src/qml/VerticalBlur.qml @@ -4,7 +4,7 @@ ShaderEffectItem { fragmentShader: "varying mediump vec2 qt_TexCoord; \n" + - "uniform sampler2D qt_Texture; \n" + + "uniform sampler2D source; \n" + "uniform mediump int sampleCount; \n" + "uniform mediump float sampleDistance; \n" + "void main() { \n" + @@ -12,7 +12,7 @@ ShaderEffectItem " mediump vec2 spos = qt_TexCoord; \n" + " for (int i=0; i<sampleCount; ++i) { \n" + " spos.y += sampleDistance; \n" + - " sum += texture2D(qt_Texture, spos); \n" + + " sum += texture2D(source, spos); \n" + " } \n" + " gl_FragColor = sum / float(sampleCount); \n" + "}" @@ -31,6 +31,7 @@ ShaderEffectItem " gl_Position = qt_Matrix * qt_VertexPosition ; \n" + "}" + property variant source property real sampleDistance: 1 / height; property int sampleCount : 8; active: sampleCount > 1 |