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

Texture compression #4758

Merged
merged 34 commits into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4cc7559
Add support for s3tc, pvrtc, and etc1 compressed textures and loading…
bagnell Dec 1, 2016
cd3b02a
Move exported function to the top
pjcozzi Dec 20, 2016
797e43b
Style
pjcozzi Dec 20, 2016
a9fc4f9
Update CHANGES.md
pjcozzi Dec 20, 2016
0235cec
Merge branch 'master' into texture-compression
bagnell Dec 20, 2016
ca72704
Fix failing tests.
bagnell Dec 20, 2016
64dd9b4
Add ktx loading support to materials. Update Sandcastle and tests.
bagnell Dec 21, 2016
da6d1c6
Document type returned from loadKTX and doc unsupported features of t…
bagnell Dec 21, 2016
172cc21
Fix typo.
bagnell Dec 21, 2016
b1876d9
Add missing sampler when loading glTF with comressed texture.
bagnell Dec 21, 2016
1eef793
Merge branch 'master' into texture-compression
bagnell Jan 4, 2017
cb01073
Initial support for transcoding textures from crunch to DXT.
bagnell Jan 5, 2017
c67a2ca
Fix issue with binary glTF compressed textures.
bagnell Jan 5, 2017
bf97394
Merge branch 'texture-compression' into crunch
bagnell Jan 5, 2017
68082c2
Move transcoding CRN to DXT to a web worker.
bagnell Jan 5, 2017
5875390
Add support for embedded crunch textures in binary glTF. Update the doc.
bagnell Jan 5, 2017
ee6856c
Add crunch support to imagery provider and material. Add loadCRN test…
bagnell Jan 5, 2017
252bb8b
Add model tests with crunch compressed textures.
bagnell Jan 5, 2017
f6cf955
Updates from review.
bagnell Jan 9, 2017
73fc589
Update crunch.js and update licenses.
bagnell Jan 9, 2017
304d32a
Merge pull request #4814 from AnalyticalGraphicsInc/crunch
pjcozzi Jan 9, 2017
40f8bcd
Merge branch 'master' into texture-compression
bagnell Jan 26, 2017
ee85f5c
Update parsing glTF compressed textures.
bagnell Jan 26, 2017
d7d82d0
Add getCompressedTextureFormatSupported to Scene.
bagnell Jan 26, 2017
d1270e1
Merge branch 'master' into texture-compression
bagnell Jan 30, 2017
7b9c700
Update test models with compressed textures. Fix binary glTF.
bagnell Jan 30, 2017
3bd7004
Update texture specs after merge.
bagnell Jan 30, 2017
324200c
Fix loading multiple textures.
bagnell Jan 30, 2017
f6ee997
Update ETC1 test.
bagnell Jan 30, 2017
9574914
Fix failing CI tests.
bagnell Jan 30, 2017
4b713b9
Merge branch 'master' into texture-compression
bagnell Feb 1, 2017
697877c
Update CHANGES.md.
bagnell Feb 1, 2017
3938f7b
Merge branch 'master' into texture-compression
bagnell Feb 1, 2017
ffa2554
Tweak CHANGES.md
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
31 changes: 30 additions & 1 deletion Apps/Sandcastle/gallery/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@
});
}

function applyCompressedTextureMaterial(primitive, scene) {
Sandcastle.declare(applyCompressedTextureMaterial); // For highlighting in Sandcastle.

var compressedImageUrl;
if (scene.getCompressedTextureFormatSupported('s3tc')) {
compressedImageUrl = '../images/LogoDXT1.ktx';
} else if (scene.getCompressedTextureFormatSupported('etc1')) {
compressedImageUrl = '../images/LogoETC1.ktx';
} else if (scene.getCompressedTextureFormatSupported('pvrtc')) {
compressedImageUrl = '../images/LogoPVR.ktx';
}

primitive.appearance.material = new Cesium.Material({
fabric : {
type : 'Image',
uniforms : {
image : compressedImageUrl
}
}
});
}

function applyNormalMapMaterial(primitive, scene) {
Sandcastle.declare(applyNormalMapMaterial); // For highlighting in Sandcastle.
primitive.appearance.material = new Cesium.Material({
Expand Down Expand Up @@ -310,6 +332,13 @@
applyImageMaterial(rectangle, scene);
Sandcastle.highlight(applyImageMaterial);
}
}, {
text : 'Compressed Image',
onselect : function() {
toggleRectangleVisibility();
applyCompressedTextureMaterial(rectangle, scene);
Sandcastle.highlight(applyCompressedTextureMaterial);
}
}]);

Sandcastle.addToolbarMenu([{
Expand Down Expand Up @@ -443,7 +472,7 @@
Sandcastle.highlight(applyPolylineOutlineMaterial);
}
}]);

document.getElementById('toolbar').style.width = '10%';
}

Expand Down
Binary file added Apps/Sandcastle/images/LogoDXT1.ktx
Binary file not shown.
Binary file added Apps/Sandcastle/images/LogoETC1.ktx
Binary file not shown.
Binary file added Apps/Sandcastle/images/LogoPVR.ktx
Binary file not shown.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Change Log
### 1.31 - 2017-03-01

* Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles.
* Added compressed texture support. [#4758](https://github.com/AnalyticalGraphicsInc/cesium/pull/4758)
* glTF models and imagery layers can now reference [KTX](https://www.khronos.org/opengles/sdk/tools/KTX/) textures and textures compressed with [crunch](https://github.com/BinomialLLC/crunch).
* Added `loadKTX`, to load KTX textures, and `loadCRN` to load crunch compressed textures.
* Added new `PixelFormat` and `WebGLConstants` enums from WebGL extensions `WEBGL_compressed_s3tc`, `WEBGL_compressed_texture_pvrtc`, and `WEBGL_compressed_texture_etc1`.
* Added `CompressedTextureBuffer`.

### 1.30 - 2017-02-01

Expand Down
79 changes: 79 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,85 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

### crunch

https://github.com/BinomialLLC/crunch

>crunch/crnlib uses the ZLIB license:
>http://opensource.org/licenses/Zlib
>
>Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC
>
>This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
>
>Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
>
>1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
>
>2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
>
>3. This notice may not be removed or altered from any source distribution.

### crunch_lib.cpp

https://github.com/Apress/html5-game-dev-insights/blob/master/jones_ch21/crunch_webgl/crunch_js/crunch_lib.cpp

>Copyright (c) 2013, Evan Parker, Brandon Jones. All rights reserved.
>
>Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
> * Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
>
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

### texture-tester

https://github.com/toji/texture-tester

>Copyright (c) 2014, Brandon Jones. All rights reserved.
>
>Redistribution and use in source and binary forms, with or without modification,
>are permitted provided that the following conditions are met:
>
>* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
>* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
>
>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Tests
=====

Expand Down
93 changes: 93 additions & 0 deletions Source/Core/CompressedTextureBuffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*global define*/
define([
'./defined',
'./defineProperties'
], function(
defined,
defineProperties
) {
'use strict';

/**
* Describes a compressed texture and contains a compressed texture buffer.
*
* @param {PixelFormat} internalFormat The pixel format of the compressed texture.
* @param {Number} width The width of the texture.
* @param {Number} height The height of the texture.
* @param {Uint8Array} buffer The compressed texture buffer.
*/
function CompressedTextureBuffer(internalFormat, width, height, buffer) {
this._format = internalFormat;
this._width = width;
this._height = height;
this._buffer = buffer;
}

defineProperties(CompressedTextureBuffer.prototype, {
/**
* The format of the compressed texture.
* @type PixelFormat
* @readonly
*/
internalFormat : {
get : function() {
return this._format;
}
},
/**
* The width of the texture.
* @type Number
* @readonly
*/
width : {
get : function() {
return this._width;
}
},
/**
* The height of the texture.
* @type Number
* @readonly
*/
height : {
get : function() {
return this._height;
}
},
/**
* The compressed texture buffer.
* @type Uint8Array
* @readonly
*/
bufferView : {
get : function() {
return this._buffer;
}
}
});

/**
* Creates a shallow clone of a compressed texture buffer.
*
* @param {CompressedTextureBuffer} object The compressed texture buffer to be cloned.
* @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.
*/
CompressedTextureBuffer.clone = function(object) {
if (!defined(object)) {
return undefined;
}

return new CompressedTextureBuffer(object._format, object._width, object._height, object._buffer);
};

/**
* Creates a shallow clone of this compressed texture buffer.
*
* @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.
*/
CompressedTextureBuffer.prototype.clone = function() {
return CompressedTextureBuffer.clone(this);
};

return CompressedTextureBuffer;
});
Loading