X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=docs%2Fcontent%2Fshared-javascript-and-cpp-documentation%2Ftexture-compression.md;h=a89212eed9fbb2b504138028530b27b4a68134c7;hp=a9910d5624cfe35ddd8bdd0da2c40cb0f032984f;hb=9f9bd6287b64fab61422e8b4a0d61a379c47176c;hpb=46516d3e1711bd272cc00002876cf207465fa8ce diff --git a/docs/content/shared-javascript-and-cpp-documentation/texture-compression.md b/docs/content/shared-javascript-and-cpp-documentation/texture-compression.md index a9910d5..a89212e 100644 --- a/docs/content/shared-javascript-and-cpp-documentation/texture-compression.md +++ b/docs/content/shared-javascript-and-cpp-documentation/texture-compression.md @@ -1,18 +1,20 @@ -/** - * + # Texture Compression {#texturecompression} Using compressing the textures will: -- Speed up rendering in time the GPU == less power used due to less texture data being transferred. +- Reduce memory bandwidth in rendering due to less texture data being transferred per frame. + - Reduces power consumption. + - Speeds up rendering. - Reduce texture memory usage. -- Speed up load times. Smaller files mean quicker load times. - +- Speed up load times. There is no CPU decoding step in loading: the file data can be copied directly to GPU memory. + DALi supports the KTX file format. - -You just load the compressed texture like you would any other image. + +You load the compressed texture just like you would any other image. ~~~{.cpp} // C++ @@ -23,27 +25,27 @@ ResourceImage image = ResourceImage::New("my_compressed_file.ktx"); var image = new dali.ResourceImage( { url:"my_compressed_file.ktx"}); ~~~ - + ### ARMS texture compression tool http://malideveloper.arm.com/develop-for-mali/tools/asset-creation/mali-gpu-texture-compression-tool/ - + Here is an example of using the ARM compression tool. - + ![ ](../assets/img/texture-atlas/compression-options.jpg) ![ ](compression-options.jpg) - + ![ ](../assets/img/texture-atlas/compression-example.jpg) ![ ](compression-example.jpg) - + As shown above the ETC-1 compression format does not support alpha. - -As a work around the tool will export the alpha as a seperate compressed image. + +As a work around the tool will export the alpha as a separate compressed image. In order to combine both the images you need to use a custom shader. Here is an example shader: - + ~~~{.cpp} // C++ Code const char* const COMPRESSED_RGB_PLUS_SEPARATE_ALPHA_FRAGMENT_SOURCE = @@ -73,7 +75,7 @@ Here is an example shader: imageActor.SetBlendMode(BlendingMode::ON); ~~~ - + ~~~{.js} // JavaScript code var fragSource = " \ @@ -83,20 +85,20 @@ void main() \ v4Color.a = texture2D(sEffect, vTexCoord ).r; \ gl_FragColor = v4Color; \ }"; - + var shaderEffect = new dali.ShaderEffect( "", fragSource); - + var atlasImageRGB = new dali.ResourceImage( { url:"ATLAS_RGB_FILENAME.KTX"} ); - + var atlasImageAlpha = new dali.ResourceImage( { url:"ATLAS_ALPHA_FILENAME.KTX"} ); - + shaderEffect.setEffectImage( atlasImageAlpha ); - + // to create Image Actor ImageActor imageActor = ImageActor::New( mAtlasImageRGB, GetImagePosition( info) ); - + imageActor.setShaderEffect( shaderEffect ); - + imageActor.setBlendMode( dali.BLENDING_ON ); ~~~ @@ -104,5 +106,3 @@ imageActor.setBlendMode( dali.BLENDING_ON ); */ - -