From e6d6aa8ea9c19f792e4694acfd179de54b815574 Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Fri, 27 May 2016 14:52:13 -0400 Subject: [PATCH 1/6] Added HSB color shifting to the atmosphere and a demo in sandbox. Updated CHANGES.md --- .../gallery/Atmosphere HSB Color.html | 108 ++++++++++++++++++ .../gallery/Atmosphere HSB Color.jpg | Bin 0 -> 9202 bytes CHANGES.md | 1 + Source/Scene/SkyAtmosphere.js | 31 +++++ Source/Shaders/SkyAtmosphereFS.glsl | 35 +++++- 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 Apps/Sandcastle/gallery/Atmosphere HSB Color.html create mode 100644 Apps/Sandcastle/gallery/Atmosphere HSB Color.jpg diff --git a/Apps/Sandcastle/gallery/Atmosphere HSB Color.html b/Apps/Sandcastle/gallery/Atmosphere HSB Color.html new file mode 100644 index 000000000000..38667ba8183d --- /dev/null +++ b/Apps/Sandcastle/gallery/Atmosphere HSB Color.html @@ -0,0 +1,108 @@ + + + + + + + + + Cesium Demo + + + + + + +
+

Loading...

+
+ + + + + + + + + + + + + +
hueShift + + +
saturationShift + + +
brightnessShift + + +
+
+
+ + + diff --git a/Apps/Sandcastle/gallery/Atmosphere HSB Color.jpg b/Apps/Sandcastle/gallery/Atmosphere HSB Color.jpg new file mode 100644 index 0000000000000000000000000000000000000000..81efb03aaf2aa8014edd33df69691b0b18d4c7f3 GIT binary patch literal 9202 zcmb7p1yodDxA+~HfuV;+M7kNITUwBi4rzuCX;Df9hVD*9T3Q-GK}tGgL^`BXQbbC4 zgMPp7egE~|dTagnIkWdYdCxs(&#rSlb-f6{R1}pJ0T2iT#G?~%JqySKm>3v084X}` zhCm?@Fc^Z1jg1Ax$Hm9T!^OiRAS8hi5E2vO;lU_i#H3{8STCuufyC?-SOi(0~cfYuhVU|ey zRA{9Pe*xJTM=-rWQ6QuX+>UK*z-*Kxch^@ZS`_;~UE`01kF9tZ$f zn79bO82s7g)FB9*S_VVNuDIO(W*CAmu-yu7l7}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Mh$87Wd|6ncGziW^kZHw%R5=U#uSh740sJyjlDhERTs`;4 zFO41d7-^eXdH0>Pa`n0#g%0f9XDb}Y3YFtcSE&h~E*>bHJUiCO^Pt{=VUST_9AF)t zwZI$kPs1AA-Kwcm=o`a%ohE{~HzW810bM}LF~2^OZ+T4BE6d=+tUH})OtDd(2CIc= zOo9G*QRnQPeGy(nXFHUWS2M!4Y|0v>ic$7;W;eFL7z9n!0ffx4y74~CsOXJ1R%HMz zJW@`BJ=*p74(tPj`FPdkE#s!NL<(|z3L^dQU#uEnnPCj#Dt)Nu=X`g|jjw)XRn_2W z43vVuG6%~de^J$q7F<<&f)Hh>>Bd-q12p=AKCcBL85;;nK4 z-+2T216z*GKn{~=xJVeHkr*4-3>4NPK)8yvcXC#5_Wtoqv3H1`ak}$0@GK?N+~N5l zv9SwXCiqMLE5`U*9@JM6-ElfOn;P5z%O(?oy+@NeJnE9p)AHD$eywn v3HNZ5eL|Ior+y<3RF?xDBcu`yY^zGI0iq0Cp*Y7mcU{DAR!Xq+_4I!M`RIT% literal 0 HcmV?d00001 diff --git a/CHANGES.md b/CHANGES.md index 8913bcf7cd08..22d772ef9f72 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ Change Log * Added `Scene.nearToFarDistance2D` that determines the size of each frustum of the multifrustum in 2D. * Added support for rendering models in 2D and Columbus view. * Fixed a bug that was causing the atmosphere to disappear when only atmosphere is visible. [#3347](https://github.com/AnalyticalGraphicsInc/cesium/issues/3347) +* Added support for hue, saturation, and brightness color shifts in the atmosphere in `SkyAtmosphere` [3439](https://github.com/AnalyticalGraphicsInc/cesium/issues/3439) ### 1.21 - 2016-05-02 diff --git a/Source/Scene/SkyAtmosphere.js b/Source/Scene/SkyAtmosphere.js index 6c28879bd86d..10e503f40e38 100644 --- a/Source/Scene/SkyAtmosphere.js +++ b/Source/Scene/SkyAtmosphere.js @@ -80,6 +80,31 @@ define([ }); this._spSkyFromSpace = undefined; this._spSkyFromAtmosphere = undefined; + + // hue, saturation, and brightness shift values for color adjustment + /** + * The hue shift to apply to the atmosphere. Defaults to 0.0 (no shift). + * @type {Number} + * @default 0.0 + */ + this.hueShift = 0.0; + + /** + * The saturation shift to apply to the atmosphere. Defaults to 0.0 (no shift). + * @type {Number} + * @default 0.0 + */ + this.saturationShift = 0.0; + + /** + * The brightness shift to apply to the atmosphere. Defaults to 0.0 (no shift). + * @type {Number} + * @default 0.0 + */ + this.brightnessShift = 0.0; + + var hsbScratch = new Cartesian3(this.hueShift, this.saturationShift, this.brightnessShift); + this._hsbScratch = hsbScratch; // camera height, outer radius, inner radius, dynamic atmosphere color flag var cameraAndRadiiAndDynamicAtmosphereColor = new Cartesian4(); @@ -96,6 +121,12 @@ define([ this._command.uniformMap = { cameraAndRadiiAndDynamicAtmosphereColor : function() { return that._cameraAndRadiiAndDynamicAtmosphereColor; + }, + u_hsvShift : function() { + hsbScratch.x = that.hueShift; + hsbScratch.y = that.saturationShift; + hsbScratch.z = that.brightnessShift; + return that._hsbScratch; } }; } diff --git a/Source/Shaders/SkyAtmosphereFS.glsl b/Source/Shaders/SkyAtmosphereFS.glsl index 5e9b75eab92c..9fbc3dab360b 100644 --- a/Source/Shaders/SkyAtmosphereFS.glsl +++ b/Source/Shaders/SkyAtmosphereFS.glsl @@ -32,15 +32,38 @@ // Code: http://sponeil.net/ // GPU Gems 2 Article: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html - + // HSV <-> RGB conversion with minimal branching: http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl + +uniform vec3 u_hsvShift; // hue, saturation, value + const float g = -0.95; const float g2 = g * g; +const float epsilon = 1.0e-10; +const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); +const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + varying vec3 v_rayleighColor; varying vec3 v_mieColor; varying vec3 v_toCamera; varying vec3 v_positionEC; +vec3 rgb2hsb(vec3 rgbColor) +{ + vec4 p = mix(vec4(rgbColor.bg, K_RGB2HSB.wz), vec4(rgbColor.gb, K_RGB2HSB.xy), step(rgbColor.b, rgbColor.g)); + vec4 q = mix(vec4(p.xyw, rgbColor.r), vec4(rgbColor.r, p.yzx), step(p.x, rgbColor.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +vec3 hsb2rgb(vec3 hsbColor) +{ + vec3 p = abs(fract(hsbColor.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www); + return hsbColor.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsbColor.y); +} + void main (void) { // Extra normalize added for Android @@ -52,6 +75,16 @@ void main (void) vec3 rgb = rayleighPhase * v_rayleighColor + miePhase * v_mieColor; rgb = vec3(1.0) - exp(-exposure * rgb); + + // convert rgb color to hsv + vec3 hsv = rgb2hsb(rgb); + // perform hsv shift + hsv.x += u_hsvShift.x; // hue + hsv.y = clamp(hsv.y + u_hsvShift.y, 0.0, 1.0); // saturation + hsv.z += u_hsvShift.z; // brightness + // convert shifted hsv back to rgb + rgb = hsb2rgb(hsv); + float l = czm_luminance(rgb); gl_FragColor = vec4(rgb, min(smoothstep(0.0, 0.1, l), 1.0) * smoothstep(0.0, 1.0, czm_morphTime)); } From 8d6d235a1ec863b0e7a3bae809e3f4e48791c44d Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Fri, 27 May 2016 15:23:24 -0400 Subject: [PATCH 2/6] Moved luminance calculation to prevent weird night skies with brightness shift. --- Source/Shaders/SkyAtmosphereFS.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Shaders/SkyAtmosphereFS.glsl b/Source/Shaders/SkyAtmosphereFS.glsl index 9fbc3dab360b..52b1f1fdddcc 100644 --- a/Source/Shaders/SkyAtmosphereFS.glsl +++ b/Source/Shaders/SkyAtmosphereFS.glsl @@ -75,16 +75,17 @@ void main (void) vec3 rgb = rayleighPhase * v_rayleighColor + miePhase * v_mieColor; rgb = vec3(1.0) - exp(-exposure * rgb); + // compute luminance before color correction to avoid strangely gray night skies + float l = czm_luminance(rgb); // convert rgb color to hsv vec3 hsv = rgb2hsb(rgb); // perform hsv shift hsv.x += u_hsvShift.x; // hue hsv.y = clamp(hsv.y + u_hsvShift.y, 0.0, 1.0); // saturation - hsv.z += u_hsvShift.z; // brightness + hsv.z = hsv.z > epsilon ? hsv.z + u_hsvShift.z : 0.0; // brightness // convert shifted hsv back to rgb rgb = hsb2rgb(hsv); - float l = czm_luminance(rgb); gl_FragColor = vec4(rgb, min(smoothstep(0.0, 0.1, l), 1.0) * smoothstep(0.0, 1.0, czm_morphTime)); } From 078a0b594a02955e96ab63e7353a6fa0bb5a2046 Mon Sep 17 00:00:00 2001 From: Kangning Li Date: Sat, 28 May 2016 03:09:28 -0400 Subject: [PATCH 3/6] Addressed some pull request items: changed some names, updated some documentation, added some shader defines, added a test case --- ...e HSB Color.html => Atmosphere Color.html} | 29 ++++++++-- Apps/Sandcastle/gallery/Atmosphere Color.jpg | Bin 0 -> 9151 bytes .../gallery/Atmosphere HSB Color.jpg | Bin 9202 -> 0 bytes CHANGES.md | 2 +- Source/Scene/SkyAtmosphere.js | 51 ++++++++++++++---- Source/Shaders/SkyAtmosphereFS.glsl | 33 +++++++----- Specs/Scene/SkyAtmosphereSpec.js | 34 ++++++++++++ 7 files changed, 120 insertions(+), 29 deletions(-) rename Apps/Sandcastle/gallery/{Atmosphere HSB Color.html => Atmosphere Color.html} (78%) create mode 100644 Apps/Sandcastle/gallery/Atmosphere Color.jpg delete mode 100644 Apps/Sandcastle/gallery/Atmosphere HSB Color.jpg diff --git a/Apps/Sandcastle/gallery/Atmosphere HSB Color.html b/Apps/Sandcastle/gallery/Atmosphere Color.html similarity index 78% rename from Apps/Sandcastle/gallery/Atmosphere HSB Color.html rename to Apps/Sandcastle/gallery/Atmosphere Color.html index 38667ba8183d..bbe7db3c4e0b 100644 --- a/Apps/Sandcastle/gallery/Atmosphere HSB Color.html +++ b/Apps/Sandcastle/gallery/Atmosphere Color.html @@ -4,7 +4,7 @@ - + Cesium Demo @@ -56,14 +56,17 @@ +
+