- const char* vertexSource = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- attribute mediump vec2 aPosition;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform vec3 uSize;\n
- uniform float uTextureWidth;\n
- varying vec2 vTexCoord;\n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);\n
- gl_Position = uMvpMatrix * vertexPosition;\n
- vTexCoord = aPosition + vec2(0.5);\n
- vTexCoord.x /= uTextureWidth;
- }\n);
-
- // the simplified version of the fragment shader of page turn effect
- const char* fragmentSource = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- uniform vec3 uSize;\n
- uniform vec2 uSpineShadowParameter;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
-
- void main()\n
- {\n
- if( gl_FrontFacing )\n // display front side
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
- }\n
- else\n // display back side, flip the image horizontally by changing the x component of the texture coordinate
- {\n
- gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;\n
- }\n
- // display book spine, a stripe of shadowed texture
- float pixelPos = vTexCoord.x * uSize.x;\n
- if( pixelPos < uSpineShadowParameter.x )\n
- {\n
- float x = pixelPos - uSpineShadowParameter.x;\n
- float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n
- vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));\n
- gl_FragColor.rgb *= spineNormal.y; \n
- }\n
- } );
-