Skip to content

Commit

Permalink
Merge pull request #4837 from AnalyticalGraphicsInc/3d-tiles-texture-…
Browse files Browse the repository at this point in the history
…compresseion

Add texture compression to 3d-tiles
  • Loading branch information
bagnell authored Jan 10, 2017
2 parents fd76c00 + da8ba03 commit 1223d9c
Show file tree
Hide file tree
Showing 53 changed files with 3,573 additions and 58 deletions.
30 changes: 30 additions & 0 deletions Apps/Sandcastle/gallery/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,29 @@
});
}

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

var compressedImageUrl;
var context = scene.context;
if (context.s3tc) {
compressedImageUrl = '../images/LogoDXT1.ktx';
} else if (context.etc1) {
compressedImageUrl = '../images/LogoETC1.ktx';
} else if (context.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 +333,13 @@
applyImageMaterial(rectangle, scene);
Sandcastle.highlight(applyImageMaterial);
}
}, {
text : 'Compressed Image',
onselect : function() {
toggleRectangleVisibility();
applyCompressedTextureMaterial(rectangle, scene);
Sandcastle.highlight(applyCompressedTextureMaterial);
}
}]);

Sandcastle.addToolbarMenu([{
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.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Change Log
==========

### 1.30 - 2017-02-01

* Deprecated
* The properties `url` and `key` will be removed from `GeocoderViewModel` in 1.31. These properties will be available on geocoder services that support them, like `BingMapsGeocoderService`.
* Added support for custom geocoder services and autocomplete [#4723](https://github.com/AnalyticalGraphicsInc/cesium/pull/4723).
Expand All @@ -14,14 +15,22 @@ Change Log

### TODO

* Added compressed texture support.
* 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.
* Added `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`. [#4758](https://github.com/AnalyticalGraphicsInc/cesium/pull/4758)
* Added `CompressedTextureBuffer`.
* Added support for [3D Tiles](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/README.md) for streaming massive heterogeneous 3D geospatial datasets. The new Cesium APIs are:
* `Cesium3DTileset`
* `Cesium3DTileStyle`, `StyleExpression`, `Expression`, and `ConditionsExpression`
* `Cesium3DTile`
* `Cesium3DTileContent`
* `Cesium3DTileFeature`


### 1.29 - 2017-01-02

* Improved 3D Models
* Added the ability to blend a `Model` with a color/translucency. Added `color`, `colorBlendMode`, and `colorBlendAmount` properties to `Model`, `ModelGraphics`, and CZML. Also added `ColorBlendMode` enum. [#4547](https://github.com/AnalyticalGraphicsInc/cesium/pull/4547)
* Added the ability to render a `Model` with a silhouette. Added `silhouetteColor` and `silhouetteSize` properties to `Model`, `ModelGraphics`, and CZML. [#4314](https://github.com/AnalyticalGraphicsInc/cesium/pull/4314)
Expand Down
79 changes: 79 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,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

0 comments on commit 1223d9c

Please sign in to comment.