X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=docs%2Fcontent%2Fprogramming-guide%2Fshader-intro.h;h=69e0b11dec249a1605cc48c8b67fe24a28c19d13;hb=d905c34da8009d5da7772461ce3c73cf49d043a5;hp=d8115943190277c4f3d6573c2e467799edb1103b;hpb=da0b26956ee6258765ff541e1b8057557a37144b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git
diff --git a/docs/content/programming-guide/shader-intro.h b/docs/content/programming-guide/shader-intro.h
index d811594..69e0b11 100644
--- a/docs/content/programming-guide/shader-intro.h
+++ b/docs/content/programming-guide/shader-intro.h
@@ -1,73 +1,86 @@
/*! \page shader-intro Shader Effects
*
-
-
Introduction
-
-The shader effects allow the developer to apply visual deformations on the actors.
-They can affect the geometry, the colors and textures of the actor.
-
-There are some utility functions in Dali::Toolkit to create some useful shader effects:
-@code
-//Bendy effect bends the geometry around a point, useful to do a page turn effect
-Dali::ShaderEffect bendyEffect = Dali::Toolkit::CreateBendyEffect();
-
-//Dissolve effect does a dissolve effect on the actor texture
-Dali::ShaderEffect dissolveEffect = Dali::Toolkit::CreateDissolveEffect();
-
-//Ripple effect does a concentric wave effect on the actor texture
-Dali::ShaderEffect rippleEffect = Dali::Toolkit::CreateRippleEffect();
-
-@endcode
-
-@image html shader-effect-ripple.png "Ripple Effect"
-
-
-
-Example and Usage
-Here is an example on how to use a shader effect, using the RippleEffect.
-
-First create the shader effect.
-@code
-Dali::ShaderEffect effect = Dali::Toolkit::CreateRippleEffect();
-@endcode
-
-Then set the values of the uniforms.
-@code
-// Set the amplitude
-effect.SetUniform("uAmplitude", 45.0f );
-// Set the center
-effect.SetUniform("uCenter", Vector2() );
-@endcode
-
-Finally apply the shader effect to an actor:
-@code
-actor.SetShaderEffect( effect );
-@endcode
-
-
-
-
-Custom Shader Effects
-The \ref Dali::ShaderEffect "ShaderEffect" lets the developers create their own shader effects by specifying the vertex and pixel shaders.
-
-A custom shader effect can be created like this:
-@code
-String myVertexShader; // This variable would contain the code for a vertex shader.
-Dali::ShaderEffect myEffect = Dali::ShaderEffect::New( myVertexShader,
- "" // use default pixel shader
- );
-@endcode
-
-The value of a uniform can be set like this:
-@code
-// if the uniform was declared like this in the shader: uniform float myUniform;
-myEffect.SetUniform( "myUniform", 0.5f );
-@endcode
-
-The custom shader effect can be applied to an actor like any other shader:
-@code
-actor.SetShaderEffect( myEffect );
-@endcode
-
+ *
+ * Introduction
+ *
+ * The shader effects allow the developer to apply visual deformations on Image Views.
+ * They can affect the geometry, the colors and textures of the Image View.
+ *
+ *
+ *
+ * Custom Shader Effects
+ * The custom shader lets the developers create their own shader effects by specifying the vertex and pixel shaders.
+ *
+ * To set a custom shader to ImageVisual you have to pass it through as a Property::Map
+ * @code
+ * //an example vertex shader
+ * const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
+ * attribute mediump vec2 aPosition;\n
+ * varying mediump vec2 vTexCoord;\n
+ * uniform mediump mat4 uMvpMatrix;\n
+ * uniform mediump vec3 uSize;\n
+ * \n
+ * void main()\n
+ * {\n
+ * mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
+ * vertexPosition.xyz *= uSize;\n
+ * vertexPosition = uMvpMatrix * vertexPosition;\n
+ * \n
+ * vTexCoord = aPosition + vec2(0.5);\n
+ * gl_Position = vertexPosition;\n
+ * }\n
+ * );
+ *
+ * //an example fragment shader
+ * const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
+ * varying mediump vec2 vTexCoord;\n
+ * uniform sampler2D sTexture;\n
+ * uniform lowp vec4 uColor;\n
+ * \n
+ * void main()\n
+ * {\n
+ * gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
+ * }\n
+ * );
+ *
+ * Property::Map customShader;
+ *
+ * customShader.Insert(âvertexShaderâ, VERTEX_SHADER); //if this is not set then the default ImageView vertex shader will be used
+ * customShader.Insert(âfragmentShaderâ, FRAGMENT_SHADER); //if this is not set then the default ImageView fragment shader will be used
+ *
+ * Property::Map map;
+ * map.Insert(âshaderâ, customShader);
+ *
+ * ImageView imageView = ImageView::New("image-url.png")
+ * imageView.SetProperty(ImageView::Property::IMAGE, map);
+ * @endcode
+ *
+ * Optionally, you can subdivide the grid horizontally or vertically before you add it to the map but you should not do this if a quad is used.
+ * @code
+ * int X_SUB_DIVISIONS = 20;
+ * int Y_SUB_DIVISIONS = 20;
+ * customShader.Insert(âsubdivideGridXâ, X_SUB_DIVISIONS); //optional number of times to subdivide the grid horizontally, donât add if you just want to use a quad
+ * customShader.Insert(âsubdivideGridYâ, Y_SUB_DIVISIONS); //optional number of times to subdivide the grid vertically, donât add if you just want to use a quad
+ *
+ * //shader hints can be an array or a string
+ * optional array of shader hints
+ *
+ * Property::Array shaderHints;
+ * shaderHints.PushBack(ârequiresSelfDepthTestâ);
+ * shaderHints.PushBack(âoutputIsTransparentâ);
+ * shaderHints.PushBack(âoutputIsOpaqueâ);
+ * shaderHints.PushBack(âmodifiesGeometryâ);
+ * customShader.Insert(âhintsâ, shaderHints);
+ *
+ * //or optional single shader hint as a string
+ * //customShader.Insert(âhintsâ, âoutputIsTransparentâ);
+ * @endcode
+ *
+ * The value of a uniform can be set on the imageView
+ * @code
+ * // if the uniform was declared like this in the shader: uniform float myUniform;
+ * imageView.RegisterProperty( "myUniform", 0.5f );
+ * @endcode
+ *
*
*/