Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress textures stage #204

Merged
merged 28 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8b215bd
Added compressTextures stage
lilleyse Dec 23, 2016
82b35ed
Merge branch 'master' into compress-textures
lilleyse Jan 4, 2017
dca8fd4
Clarify alphaBit
lilleyse Jan 4, 2017
9506993
Fix glTypeSize from crunch
lilleyse Jan 4, 2017
c8b6eca
astc to ktx
lilleyse Jan 4, 2017
6e0044f
astc flipy and cleanup
lilleyse Jan 5, 2017
90f52f1
Make mac/linux binaries executable
lilleyse Jan 5, 2017
21d43bd
License, readme, warnings, cleanup
lilleyse Jan 6, 2017
49c2896
Small fix
lilleyse Jan 6, 2017
5ae8ba4
Statically link windows binaries
lilleyse Jan 10, 2017
d839f2b
Merge branch 'master' into compress-textures
lilleyse Jan 10, 2017
dbc3378
Merge branch 'master' into compress-textures
lilleyse Jan 10, 2017
8d1db3b
Remove support for crunch-dxt3 and log warning if format is crunch-dx…
lilleyse Jan 11, 2017
bda15a7
Exlude compressed textures spec for Travis
lilleyse Jan 11, 2017
10a6827
Support loading ktx and crn from binary gltf
lilleyse Jan 16, 2017
4ae95b1
Merge branch 'master' into compress-textures
lilleyse Jan 16, 2017
3b201ac
Added stage to generate multiple compressed textures
lilleyse Jan 19, 2017
ab00ca5
Merge branch 'master' into compress-textures
lilleyse Jan 20, 2017
c407c71
Exclude new spec
lilleyse Jan 20, 2017
da6bf07
Add comments
lilleyse Jan 20, 2017
b8fcbc6
Travis fix
lilleyse Jan 20, 2017
0e59dca
Save compressed textures as extras in the image
lilleyse Jan 30, 2017
eb0b3d5
Fix
lilleyse Jan 30, 2017
05fdbb9
More flexible CLI for compressing textures
lilleyse Jan 30, 2017
68a99a4
Merge branch 'master' into compress-textures
lilleyse Jan 30, 2017
d7e4e97
Renaming
lilleyse Jan 30, 2017
07669b9
Treat crunch as a separate format from s3tc in compressedImage3DTiles
lilleyse Jan 30, 2017
41aed06
Merge branch 'master' into compress-textures
pjcozzi Feb 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Change Log
==========

### Next release
* Added `compressTextures` stage to compress input textures to a variety of compressed texture formats.

### 0.1.0-alpha9 - 2017-01-03
* Fixed issue with embedding base64 encoded shader strings for assets using the KHR_materials_common extension

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ node ./bin/gltf-pipeline.js -i ./specs/data/boxTexturedUnoptimized/CesiumTexture
|`--output`, `-o`|output=PATH, Write optimized glTF to the specified file.|No|
|`--binary`, `-b`|Write binary glTF file using KHR_binary_glTF extension.|No, default `false`|
|`--separate`, `-s`|Write separate geometry/animation data files, shader files, and textures instead of embedding them in the glTF asset.|No, default `false`|
|`--separateTexture`, `-t`|Write out separate textures, but embeds geometry/animation data files and shader files in the glTF asset.|No, default `false`|
|`--separateImage`, `-t`|Write out separate textures, but embeds geometry/animation data files and shader files in the glTF asset.|No, default `false`|
|`--quantize`, `-q`|Quantize the attributes of this glTF asset using the WEB3D_quantized_attributes extension.|No, default `false`|
|`--encodeNormals`, `-n`|Oct-encode the normals of this glTF asset.|No, default `false`|
|`--compressTextureCoordinates`, `-c`|Compress the testure coordinates of this glTF asset.|No, default `false`|
|`--removeNormals`, `-r`|Strips off existing normals, allowing them to be regenerated.|No, default `false`|
|`--faceNormals`, `-f`|If normals are missing, they should be generated using the face normal.|No, default `false`|
|`--cesium`, `-c`|Optimize the glTF for Cesium by using the sun as a default light source.|No, default `false`|
|`--cesium`|Optimize the glTF for Cesium by using the sun as a default light source.|No, default `false`|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why did you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -c flag belongs to compressTextureCoordinates, I don't think this one ever had a short flag.

|`--kmc.enable`|Materials should be expressed using the KHR_materials_common extension. If other `kmc` flags are enabled, this is implicitly true.|No, default `false`|
|`--kmc.doubleSided`|Declares whether backface culling should be disabled.|No, default `false`|
|`--kmc.technique`|The lighting model to use.|No, default `PHONG`|
Expand All @@ -50,6 +50,12 @@ node ./bin/gltf-pipeline.js -i ./specs/data/boxTexturedUnoptimized/CesiumTexture
|`--ao.groundPlane`|Simulate a groundplane at the lowest point of the model when baking AO.|No, default `false`|
|`--ao.ambientShadowContribution`|Amount of AO to show when blending between shader computed lighting and AO. 1.0 is full AO, 0.5 is a 50/50 blend.|No, default `0.5`|
|`--ao.quality`|Quality to use when baking AO. Valid settings are high, medium, and low.|No, default `low`|
|`--texcomp.enable`|Compress textures.|No, default `false`|
|`--texcomp.format`|The compressed texture format.|No, unless `texcomp.enable` is defined.|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the valid values?

|`--texcomp.quality`|The compressed texture quality from 0 to 10.|No, default `5`|
|`--texcomp.bitrate`|The bitrate when using the pvrtc or astc formats|No, default `2.0`|
|`--texcomp.blockSize`|The block size for astc compression. Smaller block sizes result in higher bitrates. This value is ignored if options.bitrate is also set.|No, default `8x8`|
|`--texcomp.alphaBit`|Store a single bit for alpha. Only supported for etc2.|No, default `false`|

## Build Instructions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include a section on where the binaries for the texture compressions came from and how to build any that you built yourself (links to build instructions elsewhere is OK).


Expand Down Expand Up @@ -94,6 +100,10 @@ The documentation will be placed in the `doc` folder.

Pull requests are appreciated! Please use the same [Contributor License Agreement (CLA)](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md) and [Coding Guide](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/CodingGuide/README.md) used for [Cesium](http://cesiumjs.org/).

## Attribution

This product includes components of the PowerVR Tools Software from Imagination Technologies Limited.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include a link to the directory or LICENSE.md file.


---

<p align="center">
Expand Down
Binary file added bin/darwin/EtcTool
Binary file not shown.
Binary file added bin/darwin/PVRTexToolCLI
Binary file not shown.
Binary file added bin/darwin/astcenc
Binary file not shown.
Binary file added bin/darwin/crunch
Binary file not shown.
Binary file added bin/linux/EtcTool
Binary file not shown.
Binary file added bin/linux/PVRTexToolCLI
Binary file not shown.
Binary file added bin/linux/astcenc
Binary file not shown.
Binary file added bin/linux/crunch
Binary file not shown.
Binary file added bin/win32/EtcTool.exe
Binary file not shown.
Binary file added bin/win32/PVRTexToolCLI.exe
Binary file not shown.
Binary file added bin/win32/astcenc.exe
Binary file not shown.
Binary file added bin/win32/crunch.exe
Binary file not shown.
12 changes: 10 additions & 2 deletions lib/Pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var bakeAmbientOcclusion = require('./bakeAmbientOcclusion');
var combineMeshes = require('./combineMeshes');
var combineNodes = require('./combineNodes');
var compressIntegerAccessors = require('./compressIntegerAccessors');
var compressTextures = require('./compressTextures');
var compressTextureCoordinates = require('./compressTextureCoordinates');
var combinePrimitives = require('./combinePrimitives');
var convertDagToTree = require('./convertDagToTree');
Expand Down Expand Up @@ -76,7 +77,9 @@ Pipeline.processJSON = function(gltf, options) {
* @param {Object} [options.aoOptions=undefined] Options to pass to the bakeAmbientOcclusion stage, if undefined, stage is not run.
* @param {Object} [options.encodeNormals=false] Flag to run octEncodeNormals stage.
* @param {Object} [options.compressTextureCoordinates=false] Flag to run compressTextureCoordinates stage.
* @param {Object} [options.kmcOptions=undefined] Options to pass to the generateModelMaterialsCommon stage, if undefined, stage is not run.
* @param {Object} [options.quantize] Flag to run quantizeAttributes stage.
* @param {Object} [options.textureCompressionOptions=undefined] Options to pass to the compressTextures stage, if undefined, stage is not run.
* @returns {Promise} A promise that resolves to the processed glTF asset.
*/
Pipeline.processJSONWithExtras = function(gltfWithExtras, options) {
Expand Down Expand Up @@ -107,7 +110,7 @@ Pipeline.processJSONWithExtras = function(gltfWithExtras, options) {

// run AO after optimizeForVertexCache since AO adds new attributes.
var aoOptions = options.aoOptions;
if (defined(aoOptions) && aoOptions.enabled) {
if (defined(aoOptions) && aoOptions.enable) {
bakeAmbientOcclusion(gltfWithExtras, aoOptions);
}

Expand Down Expand Up @@ -136,7 +139,12 @@ Pipeline.processJSONWithExtras = function(gltfWithExtras, options) {
}
quantizeAttributes(gltfWithExtras, quantizedOptions);
}
return encodeImages(gltfWithExtras);
var textureCompressionOptions = options.textureCompressionOptions;
if (defined(textureCompressionOptions) && textureCompressionOptions.enable) {
return compressTextures(gltfWithExtras, textureCompressionOptions);
} else {
return encodeImages(gltfWithExtras);
}
})
.then(function() {
var kmcOptions = options.kmcOptions;
Expand Down
Loading