Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamma applied twice in "sdlayer2.c" #21

Closed
ilyakurdyukov opened this issue Apr 12, 2023 · 1 comment
Closed

Gamma applied twice in "sdlayer2.c" #21

ilyakurdyukov opened this issue Apr 12, 2023 · 1 comment

Comments

@ilyakurdyukov
Copy link

This is first done with curpalettefaded where the gamma is applied by the tables. Also called SDL_SetWindowBrightness with the same gamma.

I would prefer to use the original tables, because in windowed mode SDL changes the brightness for all windows, not just the game window.

jonof added a commit that referenced this issue Jul 9, 2023
sdlayer2 behaved the opposite to winlayer and has been incorrect all
this time.

Expose the option to use system gamma ramp adjustment or not via a
'usegammabrightness' extern/osdvar.

TODO: write 'usegammabrightness' to config
TODO: do gamma in GL shader, paying attention to all the caveats
WIP: needs to reset/apply the gamma curve when toggling the osdvar

fixes #21
jonof added a commit that referenced this issue Feb 17, 2024
sdlayer2 behaved the opposite to winlayer and has been incorrect all
this time. The engine now exposes the option to use gamma adjustment or
the palette for brightness via a 'usegammabrightness' extern/osdvar.
 * 0 means use palette shade offset brightness like DOS did
 * 1 means apply a brightness curve in OpenGL fragment shaders
 * 2 means change the system gamma ramp
The default is shader-based brightness.

Recognised imperfection: setgamma() is almost identical in the two
sdl/winlayer.c files, but because of the 8bit GL gubbins being the
responsibility of the -layers to manage, putting the common gamma-set
logic into engine.c would mean defining another cross-module interface
just to poke gamma across the boundary.

Note also, setbrightness() can take a null palette if nothing should
change about the current palette except brightness.

Refs #21
jonof added a commit that referenced this issue Feb 19, 2024
sdlayer2 behaved the opposite to winlayer and has been incorrect all
this time. The engine now exposes the option to use gamma adjustment or
the palette for brightness via a 'usegammabrightness' extern/osdvar.
 * 0 means use palette shade offset brightness like DOS did
 * 1 means apply a brightness curve in OpenGL fragment shaders
 * 2 means change the system gamma ramp
The default is shader-based brightness, failing back to system gamma
and then palette.

Note also, setbrightness() can take a null palette if nothing should
change about the current palette except brightness.

Refs #21
@jonof
Copy link
Owner

jonof commented Feb 20, 2024

You've now got a couple of options: OpenGL shader-based which is the new default, and palette-based as requested and is the last-ditch method. You can switch by opening the console/onscreen-display and typing usegammabrightness x where x is 0 (palette), 1 (shader gamma), or 2 (system gamma).

@jonof jonof closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants