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

Set texture sampler properties of ImageryLayer #5890

Merged
merged 28 commits into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
28d2921
Added properties ImageryLayer.minificationFilter and .magnificationFi…
forman Oct 6, 2017
4aff9c2
Renamed local var as mipmapMinificationFilter
forman Oct 9, 2017
e80ba2b
Merge branch 'master' into new_texture_sampler_prop
forman Oct 9, 2017
c1e0e54
Added some more API doc
forman Oct 9, 2017
daa095f
Made TextureMagnification/MinificationFilter public and added API-docs.
forman Oct 10, 2017
cb90b62
Update wrt public TextureMagnification/MinificationFilter enums
forman Oct 10, 2017
b5fe609
avoid line breaks
forman Oct 12, 2017
2dd4fd3
Use @exports so enum doc appears as its own section in the documentation
forman Oct 12, 2017
b9b8ab7
added @type {Number} and @constant to enum values
forman Oct 12, 2017
722cd71
use upper case Boolean
forman Oct 12, 2017
d5ccbb8
made validate() methods @private
forman Oct 12, 2017
8d27fe1
added defaultMinificationFilter and defaultMagnificationFilter to Ima…
forman Oct 12, 2017
3ec59b0
Updated api docs minification/magnificationFilter props
forman Oct 12, 2017
e5b9b61
fixed order of constants
forman Oct 12, 2017
47f66ba
fixed coding style
forman Oct 12, 2017
88d3458
added new test for default texture filters of ImageryProvider
forman Oct 12, 2017
eb5ec0c
fix: turned context.cache.imageryLayer_<x>Sampler into context.cache.…
forman Oct 12, 2017
924dc1c
reverted experimental change
forman Oct 12, 2017
3d5bfaa
create mipmap textures only for linear mini/magni filters
forman Oct 13, 2017
151f8fe
added texture filter example to Sandcastle
forman Oct 13, 2017
270c805
Merge branch 'master' into new_texture_sampler_prop
forman Oct 13, 2017
dbf8d3a
fixed a harmless typo
forman Oct 13, 2017
3d632cd
be more explicit about checking if something is undefined
forman Oct 19, 2017
2a08e5d
Merge branch 'master' into new_texture_sampler_prop
forman Oct 19, 2017
c826ec9
merged upstream
forman Oct 19, 2017
356f677
Tweak comment wording
lilleyse Oct 19, 2017
d5cf453
added assertions for imagery.texture.sampler
forman Oct 23, 2017
cdc9045
Merge branch 'master' into new_texture_sampler_prop
forman Oct 23, 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
110 changes: 110 additions & 0 deletions Apps/Sandcastle/gallery/Imagery Layers Texture Filters.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Set the texture minification and magnification filters of an imagery layer.">
<meta name="cesium-sandcastle-labels" content="Beginner, Tutorials, Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">

<style>
@import url(../templates/bucket.css);

#slider {
position: absolute;
left: 50%;
top: 0px;
background-color: #D3D3D3;
width: 2px;
height: 100%;
z-index: 9999;
}

#slider:hover {
cursor: ew-resize;
}

</style>

<div id="cesiumContainer" class="fullSize">
<div id="slider"></div>
</div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>

<script id="cesium_sandcastle_script">


function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.camera.flyTo({destination : new Cesium.Rectangle.fromDegrees(-84, 43, -80, 47)});

var layers = viewer.imageryLayers;
layers.removeAll();

var layerLinear = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({
url : require.toUrl('Assets/Textures/NaturalEarthII')
}));

var layerNearest = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({
url : require.toUrl('Assets/Textures/NaturalEarthII')
}));

// Set the texture minification and magnification filters of layerNearest. Default is LINEAR.
layerNearest.minificationFilter = Cesium.TextureMinificationFilter.NEAREST;
layerNearest.magnificationFilter = Cesium.TextureMagnificationFilter.NEAREST;

// The remaining code installs a split layer so the effect of the texture filters becomes apparent.

layerNearest.splitDirection = Cesium.ImagerySplitDirection.RIGHT;

var slider = document.getElementById('slider');
viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth;

var dragStartX = 0;

document.getElementById('slider').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);

function mouseUp() {
window.removeEventListener('mousemove', sliderMove, true);
}

function mouseDown(e) {
var slider = document.getElementById('slider');
dragStartX = e.clientX - slider.offsetLeft;
window.addEventListener('mousemove', sliderMove, true);
}

function sliderMove(e) {
var slider = document.getElementById('slider');
var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
viewer.scene.imagerySplitPosition = splitPosition;
}
//Sandcastle_End

Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>

</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Change Log
==========

### 1.39 - 2017-11-01

* Added the ability to load Cesium's assets from the local file system if security permissions allow it. [#5830](https://github.com/AnalyticalGraphicsInc/cesium/issues/5830)
* Added function that inserts missing namespace declarations into KML files. [#5860](https://github.com/AnalyticalGraphicsInc/cesium/pull/5860)
* Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets.
* Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914)
* Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846)
* The enums `TextureMinificationFilter` and `TextureMagnificationFilter` have been made public to support the new texture filter properties mentioned above.
* KML files load when a Network Link fails [#5871](https://github.com/AnalyticalGraphicsInc/cesium/pull/5871)
* Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified by a `ClassificationPrimitive` or `GroundPrimitive` will have its color multiplied by `invertClassificationColor`. [#5836](https://github.com/AnalyticalGraphicsInc/cesium/pull/5836)
* Added `eyeSeparation` and `focalLength` properties to `Scene` to configure VR settings. [#5917](https://github.com/AnalyticalGraphicsInc/cesium/pull/5917)
Expand Down
28 changes: 27 additions & 1 deletion Source/Renderer/TextureMagnificationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,38 @@ define([
'use strict';

/**
* @private
* Enumerates all possible filters used when magnifying WebGL textures, which takes places when zooming
* into imagery. Provides the possible values for the {@link ImageryLayer#magnificationFilter} property.
*
* @exports TextureMagnificationFilter
*
* @see TextureMinificationFilter
* @see ImageryLayer#magnificationFilter
Copy link
Contributor

Choose a reason for hiding this comment

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

@lilleyse this @see - and the one in TextureMinificationFilter.js - is not needed and not customary. Can you please remove in master?

*/
var TextureMagnificationFilter = {
/**
* Nearest neighbor sampling of image pixels to texture.
Copy link
Contributor

Choose a reason for hiding this comment

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

In this file and below, try to avoid providing reference doc that is just a repeat of the enum. @lilleyse could you add a tad more description and trade offs, e.g., visual quality vs speed?

*
* @type {Number}
* @constant
*/
NEAREST : WebGLConstants.NEAREST,
/**
* Bi-linear interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
LINEAR : WebGLConstants.LINEAR,

/**
* Validates the given <code>textureMinificationFilter</code> with respect to the possible enum values.
*
* @private
*
* @param textureMagnificationFilter
* @returns {Boolean} <code>true</code> if <code>textureMagnificationFilter</code> is valid.
*/
validate : function(textureMagnificationFilter) {
return ((textureMagnificationFilter === TextureMagnificationFilter.NEAREST) ||
(textureMagnificationFilter === TextureMagnificationFilter.LINEAR));
Expand Down
52 changes: 51 additions & 1 deletion Source/Renderer/TextureMinificationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,66 @@ define([
'use strict';

/**
* @private
* Enumerates all possible filters used when minifying WebGL textures, which takes places when zooming
* out of imagery. Provides the possible values for the {@link ImageryLayer#minificationFilter} property.
*
* @exports TextureMinificationFilter
*
* @see TextureMagnificationFilter
* @see ImageryLayer#minificationFilter
*/
var TextureMinificationFilter = {
/**
* Nearest neighbor sampling of image pixels to texture.
*
* @type {Number}
* @constant
*/
NEAREST : WebGLConstants.NEAREST,
/**
* Bi-linear interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
LINEAR : WebGLConstants.LINEAR,
/**
* WebGL <code>NEAREST_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
NEAREST_MIPMAP_NEAREST : WebGLConstants.NEAREST_MIPMAP_NEAREST,
/**
* WebGL <code>LINEAR_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
LINEAR_MIPMAP_NEAREST : WebGLConstants.LINEAR_MIPMAP_NEAREST,
/**
* WebGL <code>NEAREST_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
NEAREST_MIPMAP_LINEAR : WebGLConstants.NEAREST_MIPMAP_LINEAR,
/**
* WebGL <code>LINEAR_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
*
* @type {Number}
* @constant
*/
LINEAR_MIPMAP_LINEAR : WebGLConstants.LINEAR_MIPMAP_LINEAR,

/**
* Validates the given <code>textureMinificationFilter</code> with respect to the possible enum values.
*
* @private
*
* @param textureMinificationFilter
* @returns {Boolean} <code>true</code> if <code>textureMinificationFilter</code> is valid.
*/
validate : function(textureMinificationFilter) {
return ((textureMinificationFilter === TextureMinificationFilter.NEAREST) ||
(textureMinificationFilter === TextureMinificationFilter.LINEAR) ||
Expand Down
Loading