Skip to content

Commit

Permalink
various doc updates, shader adjustments and specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjspace committed Aug 30, 2024
1 parent ebc84ee commit 0382d10
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 133 deletions.
1 change: 0 additions & 1 deletion Apps/Sandcastle/gallery/High Dynamic Range.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
Cesium.knockout
.getObservable(viewModel, "exposure")
.subscribe(function (newValue) {
console.log(newValue);
viewer.scene.postProcessStages.exposure = Number.parseFloat(
newValue
);
Expand Down
11 changes: 9 additions & 2 deletions packages/engine/Source/Scene/PostProcessStageCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,12 @@ Object.defineProperties(PostProcessStageCollection.prototype, {
},

/**
* Specifies the tonemapping algorithm used when rendering with high dynamic range. Defaults to `Tonemapper.PBR_NEUTRAL`
* Specifies the tonemapping algorithm used when rendering with high dynamic range.
* {@link https://sandcastle.cesium.com/?src=High%20Dynamic%20Range.html|Sandcastle Demo}
*
* @example viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.PBR_NEUTRAL;
*
* @default Tonemapper.PBR_NEUTRAL
* @memberof PostProcessStageCollection.prototype
* @type {Tonemapper}
*/
Expand Down Expand Up @@ -391,8 +395,11 @@ Object.defineProperties(PostProcessStageCollection.prototype, {
},

/**
* Control the exposure when HDR is on. Defaults to 1.
* Control the exposure when HDR is on. Less than 1.0 makes the tonemapping darker while greater than 1.0 makes it brighter.
*
* @example viewer.scene.postProcessStages.exposure = 1.0
*
* @default 1.0
* @memberof PostProcessStageCollection.prototype
* @type {number}
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/engine/Source/Scene/PostProcessStageLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ PostProcessStageLibrary.createAcesTonemappingStage = function (
fragmentShader: fs,
uniforms: {
autoExposure: undefined,
exposure: 1,
exposure: 1.0,
},
});
};
Expand All @@ -691,7 +691,7 @@ PostProcessStageLibrary.createFilmicTonemappingStage = function (
fragmentShader: fs,
uniforms: {
autoExposure: undefined,
exposure: 1,
exposure: 1.0,
},
});
};
Expand All @@ -712,7 +712,7 @@ PostProcessStageLibrary.createPbrNeutralTonemappingStage = function (
fragmentShader: fs,
uniforms: {
autoExposure: undefined,
exposure: 1,
exposure: 1.0,
},
});
};
Expand All @@ -733,7 +733,7 @@ PostProcessStageLibrary.createReinhardTonemappingStage = function (
fragmentShader: fs,
uniforms: {
autoExposure: undefined,
exposure: 1,
exposure: 1.0,
},
});
};
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/Scene/Tonemapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Tonemapper = {
ACES: "ACES",

/**
* Use the PbrNeutral tonemapping from Khronos.
* Use the PBR Neutral tonemapping {@link https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral|from Khronos}.
*
* @type {string}
* @constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// Input color is non-negative and resides in the Linear Rec. 709 color space.
// Output color is also Linear Rec. 709, but in the [0, 1] range.

vec3 czm_pbrNeutralTonemapping( vec3 color ) {
vec3 czm_pbrNeutralTonemapping(vec3 color) {
const float startCompression = 0.8 - 0.04;
const float desaturation = 0.15;

float x = min(color.r, min(color.g, color.b));
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04);
color -= offset;

float peak = max(color.r, max(color.g, color.b));
Expand All @@ -19,5 +19,5 @@ vec3 czm_pbrNeutralTonemapping( vec3 color ) {
color *= newPeak / peak;

float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
return mix(color, newPeak * vec3(1, 1, 1), g);
return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ in vec2 v_textureCoordinates;

#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
#else
uniform float exposure;
#endif

void main()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ in vec2 v_textureCoordinates;

#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
#else
uniform float exposure;
#endif

// See slides 142 and 143:
// http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ in vec2 v_textureCoordinates;

#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
#else
uniform float exposure;
#endif

// See equation 4:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ in vec2 v_textureCoordinates;

#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
#else
uniform float exposure;
#endif

void main()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ in vec2 v_textureCoordinates;

#ifdef AUTO_EXPOSURE
uniform sampler2D autoExposure;
#endif
#else
uniform float exposure;
#endif

// See equation 3:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
Expand Down
Loading

0 comments on commit 0382d10

Please sign in to comment.