Skip to content

Commit 63fbb70

Browse files
authored
Merge pull request #7017 from AnalyticalGraphicsInc/hdr
HDR Rendering
2 parents 97159a4 + ac63b95 commit 63fbb70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1575
-181
lines changed

Apps/Sandcastle/gallery/Materials.html

+14-10
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,20 @@
107107
}
108108
},
109109
source :
110-
'czm_material czm_getMaterial(czm_materialInput materialInput) {' +
111-
'czm_material material = czm_getDefaultMaterial(materialInput);' +
112-
'float heightValue = texture2D(heightField, materialInput.st).r;' +
113-
'material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);' +
114-
'material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;' +
115-
'material.normal = bumpMap.normal;' +
116-
'material.specular = step(0.1, heightValue);' + // Specular mountain tops
117-
'material.shininess = 8.0;' + // Sharpen highlight
118-
'return material;' +
119-
'}'
110+
'czm_material czm_getMaterial(czm_materialInput materialInput) { \n' +
111+
' czm_material material = czm_getDefaultMaterial(materialInput); \n' +
112+
' vec4 color; \n' +
113+
' float heightValue = texture2D(heightField, materialInput.st).r; \n' +
114+
' color.rgb = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue); \n' +
115+
' color.a = (1.0 - texture2D(image, materialInput.st).r) * 0.7; \n' +
116+
' color = czm_gammaCorrect(color); \n' +
117+
' material.diffuse = color.rgb; \n' +
118+
' material.alpha = color.a; \n' +
119+
' material.normal = bumpMap.normal; \n' +
120+
' material.specular = step(0.1, heightValue); \n' + // Specular mountain tops
121+
' material.shininess = 8.0; \n' + // Sharpen highlight
122+
' return material; \n' +
123+
'} \n'
120124
}
121125
});
122126
}

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Change Log
77
* Added functions to get the most detailed height of 3D Tiles on-screen or off-screen. [#7115](https://github.com/AnalyticalGraphicsInc/cesium/pull/7115)
88
* Added `Scene.sampleHeightMostDetailed`, an asynchronous version of `Scene.sampleHeight` that uses the maximum level of detail for 3D Tiles.
99
* Added `Scene.clampToHeightMostDetailed`, an asynchronous version of `Scene.clampToHeight` that uses the maximum level of detail for 3D Tiles.
10+
* Added support for high dynamic range rendering. It is enabled by default when supported, but can be disabled with `Scene.highDynamicRange`. [#7017](https://github.com/AnalyticalGraphicsInc/cesium/pull/7017)
1011
* Added `Scene.invertClassificationSupported` for checking if invert classification is supported.
1112
* Added `computeLineSegmentLineSegmentIntersection` to `Intersections2D`. [#7228](https://github.com/AnalyticalGraphicsInc/Cesium/pull/7228)
1213

Source/Renderer/AutomaticUniforms.js

+28
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,34 @@ define([
16861686
getValue : function(uniformState) {
16871687
return uniformState.invertClassificationColor;
16881688
}
1689+
}),
1690+
1691+
/**
1692+
* An automatic GLSL uniform that is used for gamma correction.
1693+
*
1694+
* @alias czm_gamma
1695+
* @glslUniform
1696+
*/
1697+
czm_gamma : new AutomaticUniform({
1698+
size : 1,
1699+
datatype : WebGLConstants.FLOAT,
1700+
getValue : function(uniformState) {
1701+
return uniformState.gamma;
1702+
}
1703+
}),
1704+
1705+
/**
1706+
* An automatic GLSL uniform that defines the color of light emitted by the sun.
1707+
*
1708+
* @alias czm_sunColor
1709+
* @glslUniform
1710+
*/
1711+
czm_sunColor: new AutomaticUniform({
1712+
size: 1,
1713+
datatype: WebGLConstants.FLOAT_VEC3,
1714+
getValue: function(uniformState) {
1715+
return uniformState.sunColor;
1716+
}
16891717
})
16901718
};
16911719

Source/Renderer/UniformState.js

+17
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ define([
4646
* @type {Texture}
4747
*/
4848
this.globeDepthTexture = undefined;
49+
/**
50+
* @type {Number}
51+
*/
52+
this.gamma = undefined;
4953

5054
this._viewport = new BoundingRectangle();
5155
this._viewportCartesian4 = new Cartesian4();
@@ -143,6 +147,7 @@ define([
143147
this._sunPositionColumbusView = new Cartesian3();
144148
this._sunDirectionWC = new Cartesian3();
145149
this._sunDirectionEC = new Cartesian3();
150+
this._sunColor = new Cartesian3();
146151
this._moonDirectionEC = new Cartesian3();
147152

148153
this._pass = undefined;
@@ -737,6 +742,17 @@ define([
737742
}
738743
},
739744

745+
/**
746+
* The color of the light emitted by the sun.
747+
* @memberof UniformState.prototype
748+
* @type {Color}
749+
*/
750+
sunColor: {
751+
get: function() {
752+
return this._sunColor;
753+
}
754+
},
755+
740756
/**
741757
* A normalized vector to the moon in eye coordinates at the current scene time. In 3D mode, this
742758
* returns the actual vector from the camera position to the moon position. In 2D and Columbus View, it returns
@@ -1069,6 +1085,7 @@ define([
10691085
}
10701086

10711087
setSunAndMoonDirections(this, frameState);
1088+
this._sunColor = Cartesian3.clone(frameState.sunColor, this._sunColor);
10721089

10731090
var brdfLutGenerator = frameState.brdfLutGenerator;
10741091
var brdfLut = defined(brdfLutGenerator) ? brdfLutGenerator.colorTexture : undefined;

0 commit comments

Comments
 (0)