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

HDR Rendering #7017

Merged
merged 107 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
a5ef38b
HDR WIP. Add Reinhard tonemapping. [ci skip]
bagnell May 19, 2018
f0ddfd8
Output sun texture to floating point texture.
bagnell May 21, 2018
6882ea6
Actually render to float texture. [ci skip]
bagnell May 21, 2018
1698aad
Bloom WIP. [ci skip].
bagnell May 22, 2018
e003b9e
Testing different blur.
bagnell May 22, 2018
0cd0862
Revert shaders. Use another bright pass filter WIP. [ci skip]
bagnell May 23, 2018
adbf667
Add different tonemappers WIP. [ci skip]
bagnell May 25, 2018
095c1af
Merge branch 'master' into hdr
bagnell Jun 7, 2018
7d48a5f
Fix after merge.
bagnell Jun 7, 2018
06d89eb
Merge branch 'master' into hdr
bagnell Jun 22, 2018
4d47dcc
Auto exposure WIP. [ci skip]
bagnell Jun 26, 2018
6496236
Gamma correction.
bagnell Jul 5, 2018
3b1fc7e
Auto exposure WIP. [ci skip]
bagnell Jul 6, 2018
7ebf78c
Auto exposure WIP. [ci skip]
bagnell Jul 9, 2018
2ac1f32
Fix auto exposure flicker. [ci skip]
bagnell Jul 9, 2018
6d59847
Merge branch 'master' into hdr
bagnell Jul 10, 2018
4386f78
Clean up.
bagnell Jul 10, 2018
8cf28a6
Modify tonemapping constants, globe, fog, and atmosphere
ggetz Jul 10, 2018
0b0b5d5
Merge branch 'master' into hdr
bagnell Jul 11, 2018
8aee74a
Tweak fog appearance"
ggetz Jul 13, 2018
c5124fe
Fix auto exposure decimation.
bagnell Jul 13, 2018
bf29856
Fix blend with previous frame luminance.
bagnell Jul 13, 2018
5992e84
Bloom WIP. [ci skip]
bagnell Jul 13, 2018
8c14a73
Correct gamma correction for glTF 2.0 models, billboards, and materia…
bagnell Jul 18, 2018
f815fe9
Fix remaining gamma correction issues.
bagnell Jul 19, 2018
a909eae
Merge branch 'master' into hdr
bagnell Jul 19, 2018
1cc7708
Modify sun lighting. Option to use camera as light source.
bagnell Jul 20, 2018
bfa7ee4
Tweak gamma to neutral and modify ACES values
ggetz Jul 20, 2018
8b1ac52
Better mapping constants, sun color is white-blue
ggetz Jul 23, 2018
4d1188f
Merge branch 'master' into hdr
bagnell Aug 2, 2018
8667a71
Merge branch 'atmosphere' into hdr-atmosphere
bagnell Aug 2, 2018
d851ce5
Fix after merge.
bagnell Aug 3, 2018
95bb621
Merge branch 'atmosphere' into hdr-atmosphere
bagnell Aug 9, 2018
ad648f3
Compute the atmosphere color per-fragment for smoother night-day tran…
bagnell Aug 20, 2018
33a7b40
Merge branch 'master' into hdr
bagnell Aug 20, 2018
5794f95
Merge branch 'atmosphere' into hdr-atmosphere
bagnell Aug 20, 2018
ea441c4
Merge branch 'hdr' into hdr-atmosphere
bagnell Aug 20, 2018
17efa5a
Merge branch 'float-linear' into hdr
bagnell Aug 20, 2018
187e8cb
Merge branch 'hdr' into hdr-atmosphere
bagnell Aug 20, 2018
37a4e00
Merge branch 'master' into hdr
bagnell Aug 29, 2018
97d31b8
Merge branch 'hdr' into hdr-atmosphere
bagnell Aug 29, 2018
e8ffa88
Merge branch 'atmosphere' into hdr-atmosphere
bagnell Aug 29, 2018
09a791b
Merge branch 'float-linear' into hdr
bagnell Aug 29, 2018
da3bce1
Add ability to change the tonemapping operator, but keep it private f…
bagnell Aug 29, 2018
2d888fe
Switch back to using half-floats.
bagnell Aug 29, 2018
129e50e
Clean up auto-exposure usage.
bagnell Aug 29, 2018
1e2bcd3
Revert bloom changes for now. [ci skip]
bagnell Aug 29, 2018
2bb0043
Add doc. [ci skip]
bagnell Aug 30, 2018
6056feb
Merge branch 'remove-deprecated-fxaa' into hdr
bagnell Aug 30, 2018
51e8523
Fix sun extending beyond texture.
bagnell Aug 30, 2018
9353d45
Use half-floats when supported.
bagnell Aug 30, 2018
a6f2e72
Add flag for HDR (need to modify shaders). Clean up phong lighting.
bagnell Aug 30, 2018
84ecd4b
Clean up shaders.
bagnell Aug 31, 2018
1dc42bc
Add HDR derived commands to add an HDR define when supported. Otherwi…
bagnell Aug 31, 2018
9e39ad8
Fix gamma correction when HDR is disabled.
bagnell Sep 5, 2018
b9c9073
Pass globe eye position when HDR enabled.
bagnell Sep 5, 2018
effe4d7
Merge branch 'master' into hdr
bagnell Sep 5, 2018
6a6ca8a
Update CHANGES.md after merge.
bagnell Sep 5, 2018
dd357da
Merge branch 'atmosphere' into hdr
bagnell Sep 5, 2018
132b933
Fix some tests and a copy-paste error.
bagnell Sep 5, 2018
bc0856d
Merge branch 'atmosphere' into hdr
bagnell Sep 6, 2018
bbde12b
Fix after merge.
bagnell Sep 6, 2018
2dbfe37
More fixes after merge.
bagnell Sep 6, 2018
42ad8d9
Updates for derived command from scene re-work.
bagnell Sep 6, 2018
fb5d165
Merge branch 'master' into hdr
bagnell Oct 4, 2018
5a0802f
Fixes after merge.
bagnell Oct 4, 2018
fb950f8
Updates from review.
bagnell Oct 4, 2018
ec4712b
Merge branch 'master' into hdr
bagnell Oct 17, 2018
0fcf8c5
Fix gamma correction for PerInstanceColorAppearance.
bagnell Oct 17, 2018
594a9b4
Fix some issues with gamma correction.
bagnell Oct 17, 2018
998f3e2
Fix glTF 1.0 model gamma correction.
bagnell Oct 18, 2018
209ec90
Fix globe day/night shading.
bagnell Oct 18, 2018
260c0e6
Fix point cloud gamma correction.
bagnell Oct 18, 2018
f72afd3
Update imagery contrast.
bagnell Oct 18, 2018
4d911f8
Fix background color gamma correction.
bagnell Oct 18, 2018
7cada27
Fix shadows and a typo.
bagnell Oct 18, 2018
d4ca95f
Merge branch 'master' into hdr
bagnell Oct 18, 2018
b0541b0
Fix picking and another typo.
bagnell Oct 18, 2018
b8144a9
Fix tests.
bagnell Oct 18, 2018
7b011f1
Fix DOF.
bagnell Oct 19, 2018
faf1904
Update doc.
bagnell Oct 19, 2018
4051515
Merge branch 'master' into hdr
bagnell Oct 19, 2018
15dbe1e
Fix typo after merge.
bagnell Oct 19, 2018
2066481
Merge branch 'master' into hdr
bagnell Oct 22, 2018
0019163
Make czm_sunColor a Cartesian3.
bagnell Oct 22, 2018
bd5cb7f
Add automatic uniforms tests.
bagnell Oct 22, 2018
aeb9abd
Fix toggling HDR.
bagnell Oct 22, 2018
8d0f552
Fix crash when toggling HDR because globe tile resources were destroyed.
bagnell Oct 22, 2018
6dac90e
Add tonemapping tests and an HDR test.
bagnell Oct 23, 2018
2741e35
Merge branch 'master' into hdr
bagnell Oct 24, 2018
55bfbe3
Fix test.
bagnell Oct 24, 2018
44d53e5
Fix failing WebGL stub test.
bagnell Oct 24, 2018
c33ad4b
Merge branch 'master' into hdr
bagnell Oct 24, 2018
fba7324
Fix gamma correct for billboard color.
bagnell Oct 30, 2018
6184f61
Gamma correct 3D Tiles styling color.
bagnell Oct 30, 2018
25efa79
Fix composite material example.
bagnell Oct 30, 2018
fa12020
Merge branch 'master' into hdr
bagnell Nov 2, 2018
f82229a
Update CHANGES.md.
bagnell Nov 2, 2018
3088019
Globe HDR visual tweaks
lilleyse Nov 7, 2018
c6cb009
Merge branch 'master' into hdr
bagnell Nov 7, 2018
a98c9c6
Merge branch 'master' into hdr
lilleyse Nov 8, 2018
4c33a68
Fix gamma correction on some 3D Tiles.
bagnell Nov 8, 2018
6f27325
Fix IE crash by removing const expression.
bagnell Nov 8, 2018
8492d35
Update for models with KHR_techniques_webgl from review.
bagnell Nov 12, 2018
171ccb2
Update from review.
bagnell Nov 13, 2018
7a062bc
Fix issue with cached glTFs.
bagnell Nov 14, 2018
ac63b95
Fix extra gamma correct.
bagnell Nov 14, 2018
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
28 changes: 28 additions & 0 deletions Source/Renderer/AutomaticUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,34 @@ define([
getValue : function(uniformState) {
return uniformState.invertClassificationColor;
}
}),

/**
* An automatic GLSL uniform that will be used for gamma correction.
Copy link
Contributor

Choose a reason for hiding this comment

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

"will be" is awkward, right? "is?"

*
* @alias czm_gamma
* @glslUniform
*/
czm_gamma : new AutomaticUniform({
size : 1,
datatype : WebGLConstants.FLOAT,
getValue : function(uniformState) {
return uniformState.gamma;
}
}),

/**
* An automatic GLSL uniform that defines the color of light emitted by the sun.
*
* @alias czm_sunColor
* @glslUniform
*/
czm_sunColor: new AutomaticUniform({
size: 1,
datatype: WebGLConstants.FLOAT_VEC4,
Copy link
Contributor

Choose a reason for hiding this comment

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

What is alpha used for?

Copy link
Contributor

Choose a reason for hiding this comment

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

I put this in to pack an additional intensity above 1. We should probably expose this at the scene level API as a separate property for clarity.

getValue: function(uniformState) {
return uniformState.sunColor;
}
})
};

Expand Down
45 changes: 41 additions & 4 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,15 @@ define([
this._blendMinmax = !!getExtension(gl, ['EXT_blend_minmax']);
this._elementIndexUint = !!getExtension(gl, ['OES_element_index_uint']);
this._depthTexture = !!getExtension(gl, ['WEBGL_depth_texture', 'WEBKIT_WEBGL_depth_texture']);
this._textureFloat = !!getExtension(gl, ['OES_texture_float']);
this._textureHalfFloat = !!getExtension(gl, ['OES_texture_half_float']);
this._fragDepth = !!getExtension(gl, ['EXT_frag_depth']);
this._debugShaders = getExtension(gl, ['WEBGL_debug_shaders']);

this._textureFloat = !!getExtension(gl, ['OES_texture_float']);
this._textureHalfFloat = !!getExtension(gl, ['OES_texture_half_float']);

this._textureFloatLinear = !!getExtension(gl, ['OES_texture_float_linear']);
this._textureHalfFloatLinear = !!getExtension(gl, ['OES_texture_half_float_linear']);

this._colorBufferFloat = !!getExtension(gl, ['EXT_color_buffer_float', 'WEBGL_color_buffer_float']);
this._colorBufferHalfFloat = !!getExtension(gl, ['EXT_color_buffer_half_float']);

Expand Down Expand Up @@ -564,7 +568,7 @@ define([
},

/**
* <code>true</code> if OES_texture_float is supported. This extension provides
* <code>true</code> if OES_texture_float is supported. This extension provides
* access to floating point textures that, for example, can be attached to framebuffers for high dynamic range.
* @memberof Context.prototype
* @type {Boolean}
Expand All @@ -577,7 +581,7 @@ define([
},

/**
* <code>true</code> if OES_texture_half_float is supported. This extension provides
* <code>true</code> if OES_texture_half_float is supported. This extension provides
* access to floating point textures that, for example, can be attached to framebuffers for high dynamic range.
* @memberof Context.prototype
* @type {Boolean}
Expand All @@ -589,6 +593,39 @@ define([
}
},

/**
* <code>true</code> if OES_texture_float_linear is supported. This extension provides
* access to linear sampling methods for minification and magnification filters of floating-point textures.
* @memberof Context.prototype
* @type {Boolean}
* @see {@link https://www.khronos.org/registry/webgl/extensions/OES_texture_float_linear/}
*/
textureFloatLinear : {
get : function() {
return this._textureFloatLinear;
}
},

/**
* <code>true</code> if OES_texture_half_float_linear is supported. This extension provides
* access to linear sampling methods for minification and magnification filters of half floating-point textures.
* @memberof Context.prototype
* @type {Boolean}
* @see {@link https://www.khronos.org/registry/webgl/extensions/OES_texture_half_float_linear/}
*/
textureHalfFloatLinear : {
get : function() {
return this._textureHalfFloatLinear;
}
},

/**
* <code>true</code> if EXT_texture_filter_anisotropic is supported. This extension provides
* access to anisotropic filtering for textured surfaces at an oblique angle from the viewer.
* @memberof Context.prototype
* @type {Boolean}
* @see {@link https://www.khronos.org/registry/webgl/extensions/EXT_texture_filter_anisotropic/}
*/
textureFilterAnisotropic : {
get : function() {
return !!this._textureFilterAnisotropic;
Expand Down
15 changes: 9 additions & 6 deletions Source/Renderer/CubeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ define([
}
gl.bindTexture(textureTarget, null);

this._gl = gl;
this._context = context;
this._textureFilterAnisotropic = context._textureFilterAnisotropic;
this._textureTarget = textureTarget;
this._texture = texture;
Expand Down Expand Up @@ -231,13 +231,16 @@ define([
(minificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_NEAREST) ||
(minificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_LINEAR);

// float textures only support nearest filtering, so override the sampler's settings
if (this._pixelDatatype === PixelDatatype.FLOAT || this._pixelDatatype === PixelDatatype.HALF_FLOAT) {
var context = this._context;
var pixelDatatype = this._pixelDatatype;

// float textures only support nearest filtering unless the linear extensions are supported, so override the sampler's settings
if ((pixelDatatype === PixelDatatype.FLOAT && !context.textureFloatLinear) || (pixelDatatype === PixelDatatype.HALF_FLOAT && !context.textureHalfFloatLinear)) {
minificationFilter = mipmap ? TextureMinificationFilter.NEAREST_MIPMAP_NEAREST : TextureMinificationFilter.NEAREST;
magnificationFilter = TextureMagnificationFilter.NEAREST;
}

var gl = this._gl;
var gl = context._gl;
var target = this._textureTarget;

gl.activeTexture(gl.TEXTURE0);
Expand Down Expand Up @@ -332,7 +335,7 @@ define([

this._hasMipmap = true;

var gl = this._gl;
var gl = this._context._gl;
var target = this._textureTarget;
gl.hint(gl.GENERATE_MIPMAP_HINT, hint);
gl.activeTexture(gl.TEXTURE0);
Expand All @@ -346,7 +349,7 @@ define([
};

CubeMap.prototype.destroy = function() {
this._gl.deleteTexture(this._texture);
this._context._gl.deleteTexture(this._texture);
this._positiveX = destroyObject(this._positiveX);
this._negativeX = destroyObject(this._negativeX);
this._positiveY = destroyObject(this._positiveY);
Expand Down
9 changes: 6 additions & 3 deletions Source/Renderer/Texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,16 @@ define([
(minificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_NEAREST) ||
(minificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_LINEAR);

// float textures only support nearest filtering, so override the sampler's settings
if (this._pixelDatatype === PixelDatatype.FLOAT || this._pixelDatatype === PixelDatatype.HALF_FLOAT) {
var context = this._context;
var pixelDatatype = this._pixelDatatype;

// float textures only support nearest filtering unless the linear extensions are supported, so override the sampler's settings
if ((pixelDatatype === PixelDatatype.FLOAT && !context.textureFloatLinear) || (pixelDatatype === PixelDatatype.HALF_FLOAT && !context.textureHalfFloatLinear)) {
minificationFilter = mipmap ? TextureMinificationFilter.NEAREST_MIPMAP_NEAREST : TextureMinificationFilter.NEAREST;
magnificationFilter = TextureMagnificationFilter.NEAREST;
}

var gl = this._context._gl;
var gl = context._gl;
var target = this._textureTarget;

gl.activeTexture(gl.TEXTURE0);
Expand Down
17 changes: 17 additions & 0 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ define([
* @type {Texture}
*/
this.globeDepthTexture = undefined;
/**
* @type {Number}
*/
this.gamma = undefined;

this._viewport = new BoundingRectangle();
this._viewportCartesian4 = new Cartesian4();
Expand Down Expand Up @@ -143,6 +147,7 @@ define([
this._sunPositionColumbusView = new Cartesian3();
this._sunDirectionWC = new Cartesian3();
this._sunDirectionEC = new Cartesian3();
this._sunColor = new Color();
this._moonDirectionEC = new Cartesian3();

this._pass = undefined;
Expand Down Expand Up @@ -737,6 +742,17 @@ define([
}
},

/**
* The color of the light emitted by the sun.
* @memberof UniformState.prototype
* @type {Color}
*/
sunColor: {
get: function() {
return this._sunColor;
}
},

/**
* A normalized vector to the moon in eye coordinates at the current scene time. In 3D mode, this
* returns the actual vector from the camera position to the moon position. In 2D and Columbus View, it returns
Expand Down Expand Up @@ -1069,6 +1085,7 @@ define([
}

setSunAndMoonDirections(this, frameState);
this._sunColor = Color.clone(frameState.sunColor, this._sunColor);

var brdfLutGenerator = frameState.brdfLutGenerator;
var brdfLut = defined(brdfLutGenerator) ? brdfLutGenerator.colorTexture : undefined;
Expand Down
Loading