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?Nite Owl wrote: ↑Mon May 16, 2022 6:00 pmWhere 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.In any case the exact location of the Exposure setting would be most appreciated so the experimentation can continue.Code: Select all
#define NULTIPLIER_EXPOSURE 1.0 // Misspelling of NULTIPLIER ?? Should it be MULTIPLIER ??
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
{
"sky-color-exposure"
. A float value is expected and the default is 1.0.Edit: And here is the related Windows test executable.