Skip to content

Commit 9bcd5c6

Browse files
authoredNov 8, 2017
Merge pull request #5969 from AnalyticalGraphicsInc/imagery-nearest-update
Improve doc and tests for imagery layer texture filtering
2 parents d157ab7 + aac11c0 commit 9bcd5c6

File tree

4 files changed

+57
-16
lines changed

4 files changed

+57
-16
lines changed
 

‎Source/Renderer/TextureMagnificationFilter.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ define([
77
'use strict';
88

99
/**
10-
* Enumerates all possible filters used when magnifying WebGL textures, which takes places when zooming
11-
* into imagery. Provides the possible values for the {@link ImageryLayer#magnificationFilter} property.
10+
* Enumerates all possible filters used when magnifying WebGL textures.
1211
*
1312
* @exports TextureMagnificationFilter
1413
*
1514
* @see TextureMinificationFilter
16-
* @see ImageryLayer#magnificationFilter
1715
*/
1816
var TextureMagnificationFilter = {
1917
/**
20-
* Nearest neighbor sampling of image pixels to texture.
18+
* Samples the texture by returning the closest pixel.
2119
*
2220
* @type {Number}
2321
* @constant
2422
*/
2523
NEAREST : WebGLConstants.NEAREST,
2624
/**
27-
* Bi-linear interpolation of image pixels to texture.
25+
* Samples the texture through bi-linear interpolation of the four nearest pixels. This produces smoother results than <code>NEAREST</code> filtering.
2826
*
2927
* @type {Number}
3028
* @constant

‎Source/Renderer/TextureMinificationFilter.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,68 @@ define([
77
'use strict';
88

99
/**
10-
* Enumerates all possible filters used when minifying WebGL textures, which takes places when zooming
11-
* out of imagery. Provides the possible values for the {@link ImageryLayer#minificationFilter} property.
10+
* Enumerates all possible filters used when minifying WebGL textures.
1211
*
1312
* @exports TextureMinificationFilter
1413
*
1514
* @see TextureMagnificationFilter
16-
* @see ImageryLayer#minificationFilter
1715
*/
1816
var TextureMinificationFilter = {
1917
/**
20-
* Nearest neighbor sampling of image pixels to texture.
18+
* Samples the texture by returning the closest pixel.
2119
*
2220
* @type {Number}
2321
* @constant
2422
*/
2523
NEAREST : WebGLConstants.NEAREST,
2624
/**
27-
* Bi-linear interpolation of image pixels to texture.
25+
* Samples the texture through bi-linear interpolation of the four nearest pixels. This produces smoother results than <code>NEAREST</code> filtering.
2826
*
2927
* @type {Number}
3028
* @constant
3129
*/
3230
LINEAR : WebGLConstants.LINEAR,
3331
/**
34-
* WebGL <code>NEAREST_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
32+
* Selects the nearest mip level and applies nearest sampling within that level.
33+
* <p>
34+
* Requires that the texture has a mipmap. The mip level is chosen by the view angle and screen-space size of the texture.
35+
* </p>
3536
*
3637
* @type {Number}
3738
* @constant
3839
*/
3940
NEAREST_MIPMAP_NEAREST : WebGLConstants.NEAREST_MIPMAP_NEAREST,
4041
/**
41-
* WebGL <code>LINEAR_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
42+
* Selects the nearest mip level and applies linear sampling within that level.
43+
* <p>
44+
* Requires that the texture has a mipmap. The mip level is chosen by the view angle and screen-space size of the texture.
45+
* </p>
4246
*
4347
* @type {Number}
4448
* @constant
4549
*/
4650
LINEAR_MIPMAP_NEAREST : WebGLConstants.LINEAR_MIPMAP_NEAREST,
4751
/**
48-
* WebGL <code>NEAREST_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
52+
* Read texture values with nearest sampling from two adjacent mip levels and linearly interpolate the results.
53+
* <p>
54+
* This option provides a good balance of visual quality and speed when sampling from a mipmapped texture.
55+
* </p>
56+
* <p>
57+
* Requires that the texture has a mipmap. The mip level is chosen by the view angle and screen-space size of the texture.
58+
* </p>
4959
*
5060
* @type {Number}
5161
* @constant
5262
*/
5363
NEAREST_MIPMAP_LINEAR : WebGLConstants.NEAREST_MIPMAP_LINEAR,
5464
/**
55-
* WebGL <code>LINEAR_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
56-
*
65+
* Read texture values with linear sampling from two adjacent mip levels and linearly interpolate the results.
66+
* <p>
67+
* This option provides a good balance of visual quality and speed when sampling from a mipmapped texture.
68+
* </p>
69+
* <p>
70+
* Requires that the texture has a mipmap. The mip level is chosen by the view angle and screen-space size of the texture.
71+
* </p>
5772
* @type {Number}
5873
* @constant
5974
*/

‎Source/Scene/ImageryLayer.js

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ define([
55
'../Core/defined',
66
'../Core/defineProperties',
77
'../Core/destroyObject',
8+
'../Core/DeveloperError',
89
'../Core/FeatureDetection',
910
'../Core/GeographicTilingScheme',
1011
'../Core/IndexDatatype',
@@ -45,6 +46,7 @@ define([
4546
defined,
4647
defineProperties,
4748
destroyObject,
49+
DeveloperError,
4850
FeatureDetection,
4951
GeographicTilingScheme,
5052
IndexDatatype,
@@ -814,6 +816,13 @@ define([
814816
}
815817
}
816818

819+
//>>includeStart('debug', pragmas.debug);
820+
if (this.minificationFilter !== TextureMinificationFilter.NEAREST &&
821+
this.minificationFilter !== TextureMinificationFilter.LINEAR) {
822+
throw new DeveloperError('ImageryLayer minification filter must be NEAREST or LINEAR');
823+
}
824+
//>>includeEnd('debug');
825+
817826
var sampler = new Sampler({
818827
minificationFilter : this.minificationFilter,
819828
magnificationFilter : this.magnificationFilter

‎Specs/Scene/ImageryLayerSpec.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,26 @@ defineSuite([
398398
});
399399
expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST);
400400
expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST);
401-
layer.destroy();
401+
402+
return pollToPromise(function() {
403+
return provider.ready;
404+
}).then(function() {
405+
var imagery = new Imagery(layer, 0, 0, 0);
406+
imagery.addReference();
407+
layer._requestImagery(imagery);
408+
RequestScheduler.update();
409+
410+
return pollToPromise(function() {
411+
return imagery.state === ImageryState.RECEIVED;
412+
}).then(function() {
413+
layer._createTexture(scene.context, imagery);
414+
var sampler = imagery.texture.sampler;
415+
expect(sampler.minificationFilter).toEqual(TextureMinificationFilter.NEAREST);
416+
expect(sampler.magnificationFilter).toEqual(TextureMinificationFilter.NEAREST);
417+
imagery.releaseReference();
418+
layer.destroy();
419+
});
420+
});
402421
});
403422

404423
it('uses default texture filter properties of ImageryProvider', function() {

0 commit comments

Comments
 (0)