[dali_1.0.10] Merge branch 'tizen'
[platform/core/uifw/dali-toolkit.git] / docs / content / programming-guide / texture-compression.h
1
2 /*! \page Texture_Compression Texture Compression
3
4
5 Using compressing the textures will:
6 <ul>
7 <li> Speed up rendering in time the GPU == less power used due to less texture data being transferred.
8 <li> Reduce texture memory usage.
9 <li> Speed up load times. Smaller files mean quicker load times.
10 </ul>
11 <br><br>
12 DALi supports the KTX file format.
13 You just load the compressed texture like you would any other image.
14 \code
15 Image::New("my_compressed_file.ktx");
16 \endcode
17 <br>
18 ARMS texture compression tool<br>
19 http://malideveloper.arm.com/develop-for-mali/tools/asset-creation/mali-gpu-texture-compression-tool/  <br>
20
21 Here is an example of using the ARM compression tool.
22 \image html compression-options.jpg
23
24 <br><br>
25
26 \image html compression-example.jpg
27 <br>
28 <br>
29 As shown above the ETC-1 compression format does not support alpha.<br> As a work around the tool will export
30 the alpha as a seperate compressed image.<br>
31 In order to combine both the images you need to use a custom shader.<br>
32 Here is an example shader:<br>
33 \code
34   const char* const COMPRESSED_RGB_PLUS_SEPARATE_ALPHA_FRAGMENT_SOURCE =
35     "\n"
36     "void main()\n"
37     "{\n"
38     "    vec4 v4Color  = (texture2D(sTexture, vTexCoord) * uColor);\n"
39     "    v4Color.a =  texture2D(sEffect, vTexCoord ).r;\n"
40     "   gl_FragColor = v4Color;"
41     "}\n";
42
43
44   mShaderEffect = ShaderEffect::New( "", COMPRESSED_RGB_PLUS_SEPARATE_ALPHA_FRAGMENT_SOURCE);
45
46   mAtlasImageRGB = Image::New( ATLAS_RGB_FILENAME.KTX);
47
48   mAtlasImageAlpha = Image::New( ATLAS_ALPHA_FILENAME.KTX );
49
50   mShaderEffect.SetEffectImage( mAtlasImageAlpha );
51
52
53
54   // to create Image Actor
55   ImageActor  imageActor = ImageActor::New( mAtlasImageRGB, GetImagePosition( info) );
56
57   imageActor.SetShaderEffect( mShaderEffect );
58
59   imageActor.SetBlendMode(BlendingMode::ON);
60
61 \endcode
62
63
64  */