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 adjustment shader. #5399
Comments
Here's an example of what it could be. I'm not sure it makes sense to add something like this to the engine, rather than (optionally) properly handling SRGB and linear colorspaces. # A persistent variable that stores the result of the gamma adjustment.
default persistent.gamma_adjust = 1.0
# This shader performs gamma correction.
init python:
renpy.register_shader("gamma", variables="""
uniform float u_inv_gamma;
""", fragment_900="""
gl_FragColor = pow(gl_FragColor, vec4(u_inv_gamma));
""")
# Create a Transform that performs gamma correction, and is replaced
# at every interaction and interaction restart.
init python:
def GammaAdjust(d):
gamma_adjust = max(persistent.gamma_adjust, 0.1)
return Transform(d, shader="gamma", u_inv_gamma=1.0/gamma_adjust)
# Replace the default transform with the gamma correction transform.
define config.layer_transforms[None] = [ GammaAdjust ]
# Beneath this point is a simple test game, to demonstrate gamma correction
# in action.
define _confirm_quit = False
label main_menu:
return
screen gamma_slider:
vbox:
label _("Gamma Correction")
bar value FieldValue(persistent, "gamma_adjust", range=3.0) xmaximum 300
text "[persistent.gamma_adjust:.2f]"
label start:
scene bg washington
show eileen happy
call screen gamma_slider
"..."
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: