Page 3 of 3

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 6:39 pm
by another_commander
Nite Owl wrote: Mon May 16, 2022 6:00 pm
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.
The reason the exposure setting cannot be found is that I have not posted the code changes for this experiment. That is because I have made the realization that the way this is going is not really the way it should go. Instead of adding a bunch of new settings inside .GNUstepDefaults, these new properties should probably be parts of planetinfo.plist. And still, even in this way, it would be messy. It would mean that we would have exposure settings in two shaders (planets and ships) and also one more exposure setting for stars and nebulae in the game code. Hmmm... not very efficient, is it?

I am thinking that the best way to do all this would probably be to implement that holy grail of rendering to texture and be done with the ancient direct rendering to the OpenGL pipeline. This would enable rendering of the entire scene to a floating point framebuffer, and then application of gamma correction, tone mapping and probably some post-processing effects (like bloom for example) on that final scene texture, like 99% of games out there do. Instead of having to worry about tone mapping and exposure in three different places, we would have just one setting at the end of the render pass in a final shader. Performance benefits would also be expected as a nice side effect, I guess.

Having said that, modernizing the renderer is probably more work than I can afford to put in at this time, so for now I'll just post the code changes needed for an exposure setting for sky elements. I don't think I'll check this in to master just yet though. Feel free to play with the code, but I think we're staying with what is there for the time being.

Here is the patch against github revision 64960c5a:

Code: Select all

diff --git a/src/Core/OOSkyDrawable.m b/src/Core/OOSkyDrawable.m
index dabe9d70..c1eb9bc2 100644
--- a/src/Core/OOSkyDrawable.m
+++ b/src/Core/OOSkyDrawable.m
@@ -554,12 +554,15 @@ static OOColor *DebugColor(Vector orientation)
 	GLfloat					r, g, b, x;
 	size_t					posSize, tcSize, colSize;
 	unsigned				count = 0;
-	int					skyColorCorrection = [[NSUserDefaults standardUserDefaults] oo_integerForKey:@"sky-color-correction" defaultValue:0];
+	NSUserDefaults		*defaults = [NSUserDefaults standardUserDefaults];
+	int					skyColorCorrection = [defaults oo_integerForKey:@"sky-color-correction" defaultValue:0];
+	GLfloat				exposure = [defaults oo_floatForKey:@"sky-color-exposure" defaultValue:1.0f];
 	
 // Hejl / Burgess-Dawson filmic tone mapping
 // this algorithm has gamma correction already embedded	
 #define SKYCOLOR_TONEMAP_COMPONENT(skyColorComponent) \
 do { \
+	skyColorComponent *= exposure; \
 	x = max(0.0, skyColorComponent - 0.004); \
 	*col++ = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); \
 } while (0) 
@@ -623,9 +626,9 @@ do { \
 					}
 					else if (skyColorCorrection == 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);
+						*col++ = pow(r * exposure, 1.0/2.2);
+						*col++ = pow(g * exposure, 1.0/2.2);
+						*col++ = pow(b * exposure, 1.0/2.2);
 					}
 					else					// gamma correction + filmic tone mapping
 					{

The way to use the exposure is to set its value in .GNUstepDefaults using the key "sky-color-exposure". A float value is expected and the default is 1.0.

Edit: And here is the related Windows test executable.

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 7:42 pm
by Cody
<grins> I was kinda hoping that edit would appear.

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 9:00 pm
by Cody
I'm probably doing something wrong, as I seem to have lost star colours again.

Image

Using the latest .exe and:

Code: Select all

"sky-color-correction" = 2;
"sky-color-exposure" = 2.3;
Do I need to tinker with my star colours, perhaps?

Re: Sky Colors Gamma Correction

Posted: Mon May 16, 2022 9:25 pm
by Redspear
Cody wrote: Mon May 16, 2022 9:00 pm

Image
Shiny pebble dropped in a starry pond...

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 5:25 am
by another_commander
The loss of star color is expected, because exposure is basically a color multiplier. If you are multiplying each color component by 2.3, then a color triplet of e.g. (0..45, 0.45, 1.0) which is a somewhat mid-range blue becomes (1.035, 1.035, 2.3), which is then tone mapped to something that fits inside the 0.0 - 1.0 range for display ((0.85, 0.85, 0.92) using our Hejl/Burgess-Dawson formula to be exact), but is dangerously close to white. The 2.3 value you are using is very high in my opinion; something like 1.5 should be more than enough for brightening up nebulae without destroying color. You can think of it as if it were a photo - 2.3 is the equivalent of overexposure, which essentially "burns" the film.

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 9:06 am
by Cody
O-kay, I understand it better now - I think! <grins>

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 5:19 pm
by Nite Owl
As another bit of input. The Exposure in my Ooniverse has been lowered to 0.75. This was done to facilitate both the Cargo Spotter and Trails OXZs which were getting somewhat washed out, and difficult for my ancient eyes to easily see, when viewed against the brighter parts of the newly color enhanced Nebular.

Interstellar Space also got a few changes as the standard Nebular look was just too bright in some areas making Thargoid spotting rather tricky. The Nebular count was lowered along with a few other Blur settings. Have only been in Interstellar Space once since the testing began so this may change again as things progress.

Definitely enjoying the enhancements. Thank You another_commander.

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 6:15 pm
by Cody
I nixed the nebulae in IS long ago!

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 7:22 pm
by Cholmondely
Cody wrote: Tue May 17, 2022 6:15 pm
I nixed the nebulae in IS long ago!
Ahah! More proof that the so-called IS is really ghostly greenish glowing witchspace!

Re: Sky Colors Gamma Correction

Posted: Tue May 17, 2022 8:09 pm
by Cody
After much tinkering, I've nixed filmic tonemapping, and like Nite Owl, I've dropped exposure to 0.75 - I like my star colours!
More tinkering to come though, methinks - somewhere out there lies the perfect combination.

As for Cholly's assertion, I refer the commander to my previous response: check F5