X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Fmirror-effect.h;h=a4f8dad27a9d51e4ba0503522aefdfe96b05a660;hp=1eafac1ee82f3bd07117bfc1b117aafd85f39e0a;hb=2795ebddeae62aa7a17c44d3b9448281e5992401;hpb=f58b8383147de70affa1e3949cf1c6757d705d3c diff --git a/dali-toolkit/devel-api/shader-effects/mirror-effect.h b/dali-toolkit/devel-api/shader-effects/mirror-effect.h index 1eafac1..a4f8dad 100644 --- a/dali-toolkit/devel-api/shader-effects/mirror-effect.h +++ b/dali-toolkit/devel-api/shader-effects/mirror-effect.h @@ -28,60 +28,63 @@ namespace Toolkit { /** + * @brief Creates a new MirrorEffect + * * MirrorEffect is a custom shader effect to achieve square effects in Image actors + * + * Animatable/Constrainable uniforms: + * "uDepth" - The depth of the mirror effect. Default value 0.5 + * "uAlpha" - The alpha of the mirror effect. Default value 1.0 + * + * @return A handle to a newly allocated ShaderEffect */ -class DALI_IMPORT_API MirrorEffect : public ShaderEffect +inline ShaderEffect CreateMirrorEffect() { -public: - - /** - * Create an uninitialized MirrorEffect; this can be initialized with MirrorEffect::New() - * Calling member functions with an uninitialized Dali::Object is not allowed. - */ - MirrorEffect(); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~MirrorEffect(); - - /** - * Create an initialized MirrorEffect. - * @return A handle to a newly allocated Dali resource. - */ - static MirrorEffect New(); - - /** - * Set the depth of the mirror effect. - * @param [in] depth The new mirror depth value. - */ - void SetDepth(float depth); - - /** - * Set the alpha of the mirror effect. - * @param [in] alpha The new mirror alpha value. - */ - void SetAlpha(float alpha); - - /** - * Get the name for the depth property - * which can be used in Animation API's - * @return A std::string containing the property name - */ - const std::string& GetDepthPropertyName() const; - - /** - * Get the name for the alpha property - * which can be used in Animation API's - * @return A std::string containing the property name - */ - const std::string& GetAlphaPropertyName() const; + std::string vertexShader( + "void main() \n" + "{ \n" + " mediump vec3 pos = aPosition; \n" + " pos.y = pos.y * 3.0; \n" + " mediump vec4 world = uModelView * vec4(pos,1.0); \n" + " gl_Position = uProjection * world; \n" + " vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord ); \n" + "} \n" ); + + std::string fragmentShader( + "uniform mediump float uDepth; \n" + "uniform mediump float uAlpha; \n" + "void main() \n" + "{ \n" + " if(vTexCoord.y < 1.0 / 3.0) \n" + " { \n" + " gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" + " } \n" + " else if(vTexCoord.y < 2.0 / 3.0) \n" + " { \n" + " gl_FragColor = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y * 3.0 - 1.0)) * uColor; \n" + " gl_FragColor.a *= uAlpha; \n" + " } \n" + " else \n" + " { \n" + " highp float darkness = 3.0 - vTexCoord.y * 3.0; \n" + " darkness = (1.0 - 1.0 / uDepth + darkness * 1.0/ uDepth) * 0.65; \n" + " highp vec4 color = texture2D(sTexture, vec2(vTexCoord.x, -vTexCoord.y *3.0 + 3.0)) * uColor; \n" + " color.a *= uAlpha; \n" + " gl_FragColor = color * vec4(darkness, darkness, darkness, darkness); \n" + " } \n" + "} \n" ); + + Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( + vertexShader, + fragmentShader, + ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING )); + + shaderEffect.SetUniform("uAlpha", 1.0f); + shaderEffect.SetUniform("uDepth", 0.5f); + + return shaderEffect; +} -private: // Not intended for application developers - DALI_INTERNAL MirrorEffect(ShaderEffect handle); -}; } // namespace Toolkit