Page 2 of 3

Re: Sky Colors Gamma Correction

Posted: Wed May 11, 2022 11:07 pm
by Nite Owl
Here is a quick sampling of the kinds of stuff that Mr. Latest Log is being flooded with.

Code: Select all

13:31:13.851 [oxp-standards.error]: OXP ../AddOns/adcks Navy Destroyer V1.0.oxp has no manifest.plist
13:31:20.983 [oxp-standards.deprecated]: Old style sub-entity declarations are deprecated in stealth_base
13:31:35.271 [oxp-standards.deprecated]: The conditions key is deprecated for equipment Hyper-Cargo System Illicit Hack
13:31:35.277 [oxp-standards.deprecated]: Script ../AddOns/LinkG7 v0.1.oxp/Scripts/linkG7_autoJumper.js does not "use strict";
None of this ever appeared in my logs prior to using the patch .exe. Since a lot of older OXP's/OXZ's are in use my guess is that the Developer Version checks for such things while the Release Version does not. Have tried TWEAKING both logcontrol.plist and verifyOXP.plist but have had no luck. Still getting a very large amount of messages similar to the above with the patch .exe. It can be lived with until a patch .exe is created off of the Release Version but any help that can be given to suppress the mess until then would be much appreciated.

Re: Sky Colors Gamma Correction

Posted: Wed May 11, 2022 11:14 pm
by Cody
Nite Owl wrote: Wed May 11, 2022 11:07 pm
... any help that can be given to suppress the mess until then would be much appreciated.
Would this help? It cleared my log out nicely.

Re: Sky Colors Gamma Correction

Posted: Wed May 11, 2022 11:32 pm
by Nite Owl
Thank You Cody, that fixed the problem completely. Much Appreciated.

Re: Sky Colors Gamma Correction

Posted: Thu May 12, 2022 5:49 am
by another_commander
For the Linux and Mac users who do not have access to a test binary, here is the source code patch used for the Windows test executable. You can try building from source if you want to give this a go. The patch refers to github revision ca776c1.

Code: Select all

diff --git a/src/Core/OOSkyDrawable.m b/src/Core/OOSkyDrawable.m
index ea3b0c0a..03f66a6a 100644
--- a/src/Core/OOSkyDrawable.m
+++ b/src/Core/OOSkyDrawable.m
@@ -553,6 +553,7 @@ static OOColor *DebugColor(Vector orientation)
 	GLfloat					r, g, b;
 	size_t					posSize, tcSize, colSize;
 	unsigned				count = 0;
+	BOOL					skyColorGammaCorrect = [[NSUserDefaults standardUserDefaults] boolForKey:@"skycolor-gamma-correct"];
 	
 	self = [super init];
 	if (self == nil)  OK = NO;
@@ -605,9 +606,18 @@ static OOColor *DebugColor(Vector orientation)
 					*pos++ = array[i].corners[j].z;
 					
 					// Colour is the same for each vertex
-					*col++ = r;
-					*col++ = g;
-					*col++ = b;
+					if (!skyColorGammaCorrect)
+					{
+						*col++ = r;
+						*col++ = g;
+						*col++ = b;
+					}
+					else
+					{
+						*col++ = pow(r, 1.0/2.2);
+						*col++ = pow(g, 1.0/2.2);
+						*col++ = pow(b, 1.0/2.2);
+					}
 					*col++ = 1.0f;	// Alpha is unused but needs to be there
 				}
 				 

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 1:37 pm
by another_commander
So, I played a bit more with the sky colors and I present you with a brand new test executable which not only gamma corrects, but it also performs filming tonemapping on the sky colors. Filmic tonemapping is what we use for ships and planets in 1.90 and generates vivid colors, at the same time providing as good detail as possible both in dark and brightly lit areas. The tonemapping algorithm we use is the same one used in our shaders and was originally implemented by Jim Hejl and Richard Burgess-Dawson.

Comparison between gamma correction only (top) with gamma correction + tonemapping (bottom) follows for a few examples. The differences are subtle but believe me, they are there and you will notice immediately in-game.

Image
Image

Image
Image

Image
Image

The test executable can do both simple gamma correction and gamma correction + tonemapping. Use the same .GNUstepDefaults key as before, but this time instead of a YES / NO value set it as follows:
  • 0 for no gamma correction (i.e. what we have in 1.90)
  • 1 for gamma correction only
  • Any other value for gamma correction + filmic tonemapping
So using for example
"skycolor-gamma-correct" = 2;
will fully activate the new feature.


Download the new test exe from here.


For Linux and Mac users building from source, this is the patch against revision f162e9c:

Code: Select all

diff --git a/src/Core/OOSkyDrawable.m b/src/Core/OOSkyDrawable.m
index 03f66a6a..b17dd668 100644
--- a/src/Core/OOSkyDrawable.m
+++ b/src/Core/OOSkyDrawable.m
@@ -35,12 +35,19 @@ SOFTWARE.
 #import "Universe.h"
 #import "OOMacroOpenGL.h"
 #import "NSObjectOOExtensions.h"
+#import "OOCollectionExtractors.h"
 
 
 #define SKY_ELEMENT_SCALE_FACTOR		(BILLBOARD_DEPTH / 500.0f)
 #define NEBULA_SHUFFLE_FACTOR			0.005f
 #define DEBUG_COLORS					0	// If set, rgb = xyz (offset to range from 0.1 to 1.0).
 
+#define SKYCOLOR_TONEMAP(skyColorComponent) \
+do { \
+	x = max(0.0, skyColorComponent - 0.004); \
+	*col++ = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); \
+} while (0)
+
 
 /*	Min and max coords are 0 and 1 normally, but the default
 	sky-render-inset-coords can be used to modify them slightly as an attempted
@@ -550,10 +557,10 @@ static OOColor *DebugColor(Vector orientation)
 	GLfloat					*pos;
 	GLfloat					*tc;
 	GLfloat					*col;
-	GLfloat					r, g, b;
+	GLfloat					r, g, b, x;
 	size_t					posSize, tcSize, colSize;
 	unsigned				count = 0;
-	BOOL					skyColorGammaCorrect = [[NSUserDefaults standardUserDefaults] boolForKey:@"skycolor-gamma-correct"];
+	int					skyColorGammaCorrect = [[NSUserDefaults standardUserDefaults] oo_integerForKey:@"skycolor-gamma-correct" defaultValue:0];
 	
 	self = [super init];
 	if (self == nil)  OK = NO;
@@ -606,18 +613,24 @@ static OOColor *DebugColor(Vector orientation)
 					*pos++ = array[i].corners[j].z;
 					
 					// Colour is the same for each vertex
-					if (!skyColorGammaCorrect)
+					if (skyColorGammaCorrect == 0)	// no gamma correction
 					{
 						*col++ = r;
 						*col++ = g;
 						*col++ = b;
 					}
-					else
+					else if (skyColorGammaCorrect == 1)	// gamma correction only
 					{
 						*col++ = pow(r, 1.0/2.2);
 						*col++ = pow(g, 1.0/2.2);
 						*col++ = pow(b, 1.0/2.2);
 					}
+					else							// gamma correctioin + filmic tonemapping
+					{
+						SKYCOLOR_TONEMAP(r);
+						SKYCOLOR_TONEMAP(g);
+						SKYCOLOR_TONEMAP(b);
+					}
 					*col++ = 1.0f;	// Alpha is unused but needs to be there
 				}
 				

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 4:08 pm
by Cody
Is there any reason why filmic tonemapping might affect star colours?
I'm just back from the opticians, and only had a quick look.

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 4:14 pm
by another_commander
@Cody: I wouldn't think so, at least not to the extent that it would be immediately noticeable. If anything, it should probably make star colors slightly more vibrant, like everything else

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 4:18 pm
by Cody
<nods> I can't do a proper comparison 'til my eyes have adjusted to the new prescription. Tomorrow, after I've slept.

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 6:12 pm
by Nite Owl
Since running these executable tests the following keeps popping up in my .GNUstepDefaults.

Code: Select all

"debug-settings-override" = { };
My guess is that it has something to do with the developer version of the executable but no documentation on what it does or what parameters might be associated with it can be found. Please advise.

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 6:34 pm
by another_commander
Nite Owl wrote: Sat May 14, 2022 6:12 pm
Since running these executable tests the following keeps popping up in my .GNUstepDefaults.

Code: Select all

"debug-settings-override" = { };
My guess is that it has something to do with the developer version of the executable but no documentation on what it does or what parameters might be associated with it can be found. Please advise.
This is indeed related to the test release executable and it just stores settings for the debug console. Safe to ignore.

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 7:33 pm
by Redspear
Not sure if it's the tonemapping addition or just having had more time to think about it generally, but having been on the fence about this I think I'm moving steadily towards the 'pro' camp now.

Great work a_c 8)

Re: Sky Colors Gamma Correction

Posted: Sat May 14, 2022 8:26 pm
by DGill
I like it - very colourful!

Image

Re: Sky Colors Gamma Correction

Posted: Sun May 15, 2022 5:14 pm
by another_commander
The feature has hit the master branch on github but is currently dormant. Please refer to the comments of commit 64960c5 for information on how to enable it.

Note that the .GNUstepDefaults key controlling the type of color correction to be applied has now been changed to "sky-color-correction".

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 6:44 am
by another_commander
For fun: Fooling around with exposure for stars and nebulae:

Exposure 0.6:
Image

Exposure 1.0 (default):
Image

Exposure 1.38:
Image

Exposure 2.38:
Image

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 6:00 pm
by Nite Owl
Where is the Exposure setting found? Checked out the commit and it is not there. The only similar thing to be found was in the oolite-default-planet.fragment shader.

Code: Select all

#define NULTIPLIER_EXPOSURE			1.0  // Misspelling of NULTIPLIER ?? Should it be MULTIPLIER ??
In any case the exact location of the Exposure setting would be most appreciated so the experimentation can continue.