From: Xiangyin Ma Date: Wed, 9 Dec 2015 17:49:13 +0000 (+0000) Subject: Update the custom shader effects to resize the geometry X-Git-Tag: dali_1.1.15~8^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=40e6eada47390ac9be4db5fbe210cc5d23c8ebcd;hp=-c;ds=sidebyside Update the custom shader effects to resize the geometry Change-Id: Ice71ffe5b084286625772743201cc72810c9591e --- 40e6eada47390ac9be4db5fbe210cc5d23c8ebcd diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index 653325c..deb3727 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp @@ -948,7 +948,7 @@ int UtcDaliBuilderShaderEffectP(void) " \"vertexPrefix\": \"\",\n" " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n" " \"fragmentPrefix\": \"\",\n" - " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" + " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" " \"geometryHints\": \"HINT_NONE\",\n" @@ -1058,7 +1058,7 @@ int UtcDaliBuilderShaderEffect2P(void) " \"vertexPrefix\": \"\",\n" " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n" " \"fragmentPrefix\": \"\",\n" - " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" + " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" " \"geometryHints\": \"HINT_NONE\",\n" @@ -1241,7 +1241,7 @@ int UtcDaliBuilderFrameBufferP(void) " \"vertexPrefix\": \"\",\n" " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n" " \"fragmentPrefix\": \"\",\n" - " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" + " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" " \"geometryHints\": \"HINT_NONE\",\n" @@ -1412,7 +1412,7 @@ int UtcDaliBuilderPathConstraintsP(void) " \"vertexPrefix\": \"\",\n" " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n" " \"fragmentPrefix\": \"\",\n" - " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" + " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = uTextureRect.zw - uTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n" " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n" " },\n" " \"geometryHints\": \"HINT_NONE\",\n" diff --git a/dali-toolkit/devel-api/shader-effects/bendy-effect.h b/dali-toolkit/devel-api/shader-effects/bendy-effect.h index 71ed07c..9f9deb5 100644 --- a/dali-toolkit/devel-api/shader-effects/bendy-effect.h +++ b/dali-toolkit/devel-api/shader-effects/bendy-effect.h @@ -52,7 +52,7 @@ inline ShaderEffect CreateBendyEffect() "void main()\n" "{\n" " mediump float lighting = 0.25;\n" - " mediump vec4 position = uModelView * vec4(aPosition,1.0);\n" + " mediump vec4 position = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n" "\n" " mediump vec2 d = position.xy - uCenter;\n" " mediump float dist = max( 0.0, dot(d,uDirection) );\n" @@ -70,7 +70,7 @@ inline ShaderEffect CreateBendyEffect() "\n" "vShade = 1.0 - abs(sn) * lighting;\n" "\n" - "vTexCoord = aTexCoord;\n" + "vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n" "}" ); std::string fragmentShader( diff --git a/dali-toolkit/devel-api/shader-effects/carousel-effect.h b/dali-toolkit/devel-api/shader-effects/carousel-effect.h index dfe7018..67180bd 100644 --- a/dali-toolkit/devel-api/shader-effects/carousel-effect.h +++ b/dali-toolkit/devel-api/shader-effects/carousel-effect.h @@ -63,14 +63,14 @@ inline ShaderEffect CreateCarouselEffect() "\n" "void main()\n" "{\n" - " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n" + " mediump vec4 world = uModelView * vec4(aPosition*uSize.xy, 0.0, 1.0);\n" " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n" " mediump float a = length(d);\n" " mediump float cs = cos(radians(a));\n" " world.z -= cs * uRadius;\n" " gl_Position = uProjection * world;\n" " \n" - " vTexCoord = aTexCoord;\n" + " vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n" "}\n"); ShaderEffect shaderEffect = ShaderEffect::New( diff --git a/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h b/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h index 3a244fc..c91abdc 100644 --- a/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h +++ b/dali-toolkit/devel-api/shader-effects/dissolve-local-effect.h @@ -54,7 +54,7 @@ inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples ) "varying float vPercentage;\n" "void main()\n" "{\n" - " vec4 position = uModelView * vec4( aPosition, 1.0 );\n" + " vec4 position = uModelView * vec4( aPosition*uSize.xy, 0.0, 1.0 );\n" " float percentage = 0.0;\n" " for( int i=0; i= uRadius)\n" diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h b/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h index 3f6727f..532f553 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h @@ -51,14 +51,6 @@ namespace Internal **/ inline ShaderEffect CreatePageTurnBookSpineEffect() { - std::string vertexSource = DALI_COMPOSE_SHADER( - precision mediump float;\n - void main()\n - {\n - gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n - vTexCoord = aTexCoord;\n - }\n); - // the simplified version of the fragment shader of page turn effect std::string fragmentSource = DALI_COMPOSE_SHADER( precision mediump float;\n @@ -69,11 +61,11 @@ inline ShaderEffect CreatePageTurnBookSpineEffect() {\n // flip the image horizontally by changing the x component of the texture coordinate if( uIsBackImageVisible == 1.0 )\n - gl_FragColor = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) ) * uColor; \n + gl_FragColor = texture2D( sTexture, vec2( uTextureRect.p+uTextureRect.s-vTexCoord.x, vTexCoord.y ) ) * uColor; \n else\n gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n // display book spine, a stripe of shadowed texture - float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageWidth; \n + float pixelPos = (vTexCoord.x-uTextureRect.s)*uPageWidth; \n if(pixelPos < uSpineShadowParameter.x) \n {\n float x = pixelPos - uSpineShadowParameter.x;\n @@ -85,7 +77,7 @@ inline ShaderEffect CreatePageTurnBookSpineEffect() const Vector2 DEFAULT_SPINE_SHADOW_PARAMETER(50.0f, 20.0f); - ShaderEffect shaderEffect = ShaderEffect::New( vertexSource, fragmentSource ); + ShaderEffect shaderEffect = ShaderEffect::New( "", fragmentSource ); shaderEffect.SetUniform( "uIsBackImageVisible", -1.f ); shaderEffect.SetUniform( "uSpineShadowParameter", DEFAULT_SPINE_SHADOW_PARAMETER ); diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp b/dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp index 3684e70..233a3a1 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-effect.cpp @@ -127,7 +127,7 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect() \n void main()\n {\n - vec4 position = vec4( aPosition.xy, 0.0, 1.0);\n + vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);\n vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n vec3 normal = vec3(0.0,0.0,1.0);\n @@ -246,10 +246,9 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect() // change the coordinate origin from the top-left of the page to its center position.xy -= uPageSize * 0.5; \n }\n - position.z += aPosition.z;\n gl_Position = uMvpMatrix * position;\n // varying parameters for fragment shader - vTexCoord = aTexCoord; + vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n; vNormal = uNormalMatrix*normal;\n vPosition = uModelView * position;\n }\n @@ -271,11 +270,11 @@ ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect() float spineShadowCoef = 1.0; \n // display page content // display back image of the page, flip the texture - if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n + if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( uTextureRect.p+uTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n // display front image of the page else texel = texture2D( sTexture, vTexCoord );\n // display book spine, a stripe of shadowed texture - float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageSize.x; \n + float pixelPos = (vTexCoord.x-uTextureRect.s)*uPageSize.x; \n if(pixelPos < uSpineShadowParameter.x) \n {\n float x = pixelPos - uSpineShadowParameter.x;\n