- Notifications
You must be signed in to change notification settings - Fork120
License
google/etc2comp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repo is no longer maintained.
Etc2Comp is a command line tool that converts textures (e.g. bitmaps)into theETC2format. The tool is built with a focus on encoding performanceto reduce the amount of time required to compile asset heavy applications aswell as reduce overall application size.
This repo provides source code that can be compiled into a binary. Thebinary can then be used to convert textures to the ETC2 format.
Important: This is not an official Google product. It is an experimentallibrary published as-is. Please see the CONTRIBUTORS.md file for informationabout questions or issues.
This project usesCMake to generate platform-specificbuild files:
- Linux: make files
- OS X: Xcode workspace files
- Microsoft Windows: Visual Studio solution files
- Note: CMake supports other formats, but this doc only provides steps forone of each platform for brevity.
Refer to each platform's setup section to setup your environment and buildan Etc2Comp binary. Then skip to the usage section of this page for examplesof how to use the library.
build tested on this config:OS X 10.9.5 i7 16GB RAMXcode 5.1.1cmake 3.2.3
Start by downloading and installing the following components if they are notalready installed on your development machine.
- Xcode version 5.1.1, or greater
- CMake version 3.2.3, or greater
To build the Etc2Comp binary:
- Open aTerminal window and navigate to the project directory.
- Run
mkdir build_xcode
- Run
cd build_xcode
- Run
cmake -G Xcode ../
- OpenXcode and import the
build_xcode/EtcTest.xcodeproj
file. - Open the Product menu and choose Build For -> Running.
- Once the build succeeds the binary located at
build_xcode/EtcTool/Debug/EtcTool
can be executed.
OptionalXcode EtcTool ‘Run’ preferencesnote: if the build_xcode/EtcTest.xcodeproj is manually deleted then some Xcode preferenceswill need to be set by hand after cmake is run (these prefs are retained acrosscmake updates if the .xcodeproj is not deleted/removed)
- Set the active scheme to ‘EtcTool’
- Edit the scheme
- Select option ‘Run EtcTool’, then tab ‘Arguments’.Add this launch argument: ‘-argfile ../../EtcTool/args.txt’
- Select tab ‘Options’ and set a custom working directory to: ‘$(SRCROOT)/Build_Xcode/EtcTool’
- Open aTerminal window and navigate to the project directory.
- Run
mkdir build_vs
- Run
cd build_vs
- Run CMAKE, noting what build version you need, and pointing to the parent directory as the source root;For VS 2013 :
cmake -G "Visual Studio 12 2013 Win64" ../
For VS 2015 :cmake -G "Visual Studio 14 2015 Win64" ../
NOTE: To see what supported Visual Studio outputs there are, runcmake -G
- open the 'EtcTest' solution
- make the 'EtcTool' project the start up project
- (optional) in the project properties, under 'Debugging ->command arguments'add the argfile textfile thats included in the EtcTool directory.example: -argfile C:\etc2\EtcTool\Args.txt
The Linux build was tested on this config:Ubuntu desktop 14.04gcc/g++ 4.8cmake 2.8.12.2
- Verify linux has cmake and C++-11 capable g++ installed
- Open shell
- Run
mkdir build_linux
- Run
cd build_linux
- Run
cmake ../
- Run
make
- navigate to the newly created EtcTool directory
cd EtcTool
- run the executable:
./EtcTool -argfile ../../EtcTool/args.txt
Skip to theUsage section for more information about using thetool.
EtcTool can be run from the command line with the following usage:etctool.exe source_image [options ...] -output encoded_image
The encoder will use an array of RGBA floats read from the source_image to createan ETC1 or ETC2 encoded image in encoded_image. The RGBA floats should be in therange [0:1].
Options:
-analyze <analysis_folder>-argfile <arg_file> additional command line arguments read from a file-blockAtHV <H V> encodes a single block that contains the pixel specified by the H V coordinates-compare <comparison_image> compares source_image to comparison_image-effort <amount> number between 0 and 100 to specify the encoding quality (100 is the highest quality)-errormetric <error_metric> specify the error metric, the options are rgba, rgbx, rec709, numeric and normalxyz-format <etc_format> ETC1, RGB8, SRGB8, RGBA8, SRGB8, RGB8A1, SRGB8A1 or R11-help prints this message-jobs or -j <thread_count> specifies the number of threads (default=1)-normalizexyz normalize RGB to have a length of 1-verbose or -v shows status information during the encoding process-mipmaps or -m <mip_count> sets the maximum number of mipaps to generate (default=1)-mipwrap or -w <x|y|xy> sets the mipmap filter wrap mode (default=clamp)
-analyze will run an analysis of the encoding and place it in folder"analysis_folder" (e.g. ../analysis/kodim05). within the analysis_folder, a folderwill be created with a name of the current date/time (e.g. 20151204_153306). thisdate/time folder is used to compare encodings of the same texture over time.
within the date/time folder is a text file with several encoding stats and a 2x pngimage showing the encoding mode for each 4x4 block.-argfile allows additional command line arguments to be placed in a text file
-blockAtHV selects the 4x4 pixel subset of the source image at position (H,V).
This is mainly used for debugging-compare compares the source image to the created encoded image. The encodingwill dictate what error analysis is used in the comparison.
-effort uses an "amount" between 0 and 100 to determine how much additional effortto apply during the encoding.
-errormetric selects the fitting algorithm used by the encoder. "rgba" calculatesRMS error using RGB components that are weighted by A. "rgbx" calculates RMS errorusing RGBA components, where A is treated as an additional data channel, instead ofas alpha. "rec709" is similar to "rgba", except the RGB components are also weightedaccording to Rec709. "numeric" calculates RMS error using unweighted RGBA components.
"normalize" calculates error based on dot product and vector length for RGB and RMSerror for A.-help prints out the usage message
-jobs enables multi-threading to speed up image encoding
-normalizexyz normalizes the source RGB to have a length of 1.
-verbose shows information on the current encoding process. It will then display thePSNR and time time it took to encode the image.
-mipmaps takes an argument that specifies how many mipmaps to generate from thesource image. The mipmaps are generated with a lanczos3 filter using edge clamping.If the mipmaps option is not specified no mipmaps are created.
-mipwrap takes an argument that specifies the mipmap filter wrap mode. The optionsare "x", "y" and "xy" which specify wrapping in x only, y only or x and y respectively.The default options are clamping in both x and y.
Note: Path names can use slashes or backslashes. The tool will convert theslashes to the appropriate polarity for the current platform.
The library supports two different APIs - a C-like API that is not heavilyclass-based and a class-based API.
main() in EtcTool.cpp contains an example of both APIs.
The Encode() method now returns an EncodingStatus that contains bit flags forreporting various warnings and flags encountered when encoding.
Copyright 2015 Etc2Comp Authors.
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.