(ItemView) Store initial value in constraints to apply weight correctly
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / docs / content / texture-compression.js
1
2 /**
3  *
4
5 ## Texture Compression
6
7 Using compressing the textures will:
8
9 - Speed up rendering in time the GPU == less power used due to less texture data being transferred.
10 - Reduce texture memory usage.
11 - Speed up load times. Smaller files mean quicker load times.
12   
13 DALi supports the KTX file format.
14 You just load the compressed texture like you would any other image.
15
16     var image = new dali.ResourceImage({url:"my_compressed_file.ktx"});
17
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
23 <img src="../assets/img/shared/texture-atlas/compression-options.jpg">
24
25 <img src="../assets/img/shared/texture-atlas/compression-example.jpg">
26
27 As shown above the ETC-1 compression format does not support alpha.<br> As a work around the tool will export
28 the alpha as a seperate compressed image.
29 In order to combine both the images you need to use a custom shader.
30 Here is an example shader:
31 ```
32 var fragSource = "  \
33 void main()                                                   \
34 {                                                             \
35     vec4 v4Color  = (texture2D(sTexture, vTexCoord) * uColor); \
36     v4Color.a =  texture2D(sEffect, vTexCoord ).r;             \
37    gl_FragColor = v4Color;                                     \
38 }";
39   
40 var shaderEffect = new dali.ShaderEffect( "", fragSource);
41   
42 var atlasImageRGB = new dali.ResourceImage( { url:"ATLAS_RGB_FILENAME.KTX"} );
43   
44 var atlasImageAlpha = new dali.ResourceImage( { url:"ATLAS_ALPHA_FILENAME.KTX"} );
45   
46 shaderEffect.setEffectImage( atlasImageAlpha );
47   
48 // to create Image Actor
49 ImageActor  imageActor = ImageActor::New( mAtlasImageRGB, GetImagePosition( info) );
50   
51 imageActor.setShaderEffect( shaderEffect );
52   
53 imageActor.setBlendMode( dali.BLENDING_ON );
54 ```
55  @class TextureCompression
56
57
58  */