Skip to content

Commit

Permalink
Merge pull request #7017 from AnalyticalGraphicsInc/hdr
Browse files Browse the repository at this point in the history
HDR Rendering
  • Loading branch information
lilleyse authored Nov 14, 2018
2 parents 97159a4 + ac63b95 commit 63fbb70
Show file tree
Hide file tree
Showing 64 changed files with 1,575 additions and 181 deletions.
24 changes: 14 additions & 10 deletions Apps/Sandcastle/gallery/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,20 @@
}
},
source :
'czm_material czm_getMaterial(czm_materialInput materialInput) {' +
'czm_material material = czm_getDefaultMaterial(materialInput);' +
'float heightValue = texture2D(heightField, materialInput.st).r;' +
'material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);' +
'material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;' +
'material.normal = bumpMap.normal;' +
'material.specular = step(0.1, heightValue);' + // Specular mountain tops
'material.shininess = 8.0;' + // Sharpen highlight
'return material;' +
'}'
'czm_material czm_getMaterial(czm_materialInput materialInput) { \n' +
' czm_material material = czm_getDefaultMaterial(materialInput); \n' +
' vec4 color; \n' +
' float heightValue = texture2D(heightField, materialInput.st).r; \n' +
' color.rgb = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue); \n' +
' color.a = (1.0 - texture2D(image, materialInput.st).r) * 0.7; \n' +
' color = czm_gammaCorrect(color); \n' +
' material.diffuse = color.rgb; \n' +
' material.alpha = color.a; \n' +
' material.normal = bumpMap.normal; \n' +
' material.specular = step(0.1, heightValue); \n' + // Specular mountain tops
' material.shininess = 8.0; \n' + // Sharpen highlight
' return material; \n' +
'} \n'
}
});
}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Change Log
* Added functions to get the most detailed height of 3D Tiles on-screen or off-screen. [#7115](https://github.com/AnalyticalGraphicsInc/cesium/pull/7115)
* Added `Scene.sampleHeightMostDetailed`, an asynchronous version of `Scene.sampleHeight` that uses the maximum level of detail for 3D Tiles.
* Added `Scene.clampToHeightMostDetailed`, an asynchronous version of `Scene.clampToHeight` that uses the maximum level of detail for 3D Tiles.
* 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)
* Added `Scene.invertClassificationSupported` for checking if invert classification is supported.
* Added `computeLineSegmentLineSegmentIntersection` to `Intersections2D`. [#7228](https://github.com/AnalyticalGraphicsInc/Cesium/pull/7228)

Expand Down
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 is used for gamma correction.
*
* @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_VEC3,
getValue: function(uniformState) {
return uniformState.sunColor;
}
})
};

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 Cartesian3();
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 = Cartesian3.clone(frameState.sunColor, this._sunColor);

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

0 comments on commit 63fbb70

Please sign in to comment.