diff --git a/engine/art/fx/fxGamma.fs b/engine/art/fx/fxGamma.fs index 3ad1a29..b4e1c1f 100644 --- a/engine/art/fx/fxGamma.fs +++ b/engine/art/fx/fxGamma.fs @@ -1,8 +1,8 @@ -uniform float gamma; /// set:2.2 +uniform float u_gamma; out vec4 color; void main(void) { vec2 uv = TEXCOORD.st; vec4 src = texture2D(iChannel0, uv); - color = vec4( pow(src.xyz, vec3(1.0 / gamma)), src.a); // gamma correction + color = vec4( pow(src.xyz, vec3(u_gamma)), src.a); // gamma correction } diff --git a/engine/art/shaders/fs_24_4_sprite.glsl b/engine/art/shaders/fs_24_4_sprite.glsl index 6a99df2..011e111 100644 --- a/engine/art/shaders/fs_24_4_sprite.glsl +++ b/engine/art/shaders/fs_24_4_sprite.glsl @@ -1,5 +1,5 @@ uniform sampler2D u_texture; -uniform float gamma; /// set:2.2 +uniform float u_gamma; /// set:2.2 in vec2 vTexCoord; in vec4 vColor; @@ -54,5 +54,5 @@ void main() { vec4 texColor = texture_AA2(u_texture, vTexCoord); if(texColor.a < 0.9) discard; fragColor = vColor * texColor; - fragColor.rgb = pow(fragColor.rgb, vec3(gamma)); + fragColor.rgb = pow(fragColor.rgb, vec3(u_gamma)); } \ No newline at end of file diff --git a/engine/art/shaders/fs_3_4_skybox_rayleigh.glsl b/engine/art/shaders/fs_3_4_skybox_rayleigh.glsl index bf645cc..6f4bbfa 100644 --- a/engine/art/shaders/fs_3_4_skybox_rayleigh.glsl +++ b/engine/art/shaders/fs_3_4_skybox_rayleigh.glsl @@ -8,7 +8,7 @@ uniform float uMieScattering; uniform float uRayleighScaleHeight; uniform float uMieScaleHeight; uniform float uMiePreferredDirection; -uniform float gamma; /// set:2.2 +uniform float u_gamma; /// set:2.2 in vec3 v_direction; out vec4 fragcolor; @@ -36,7 +36,7 @@ void main() { color = 1.0 - exp(-1.0 * color); fragcolor = vec4(color, 1); - fragcolor.rgb = pow(fragcolor.rgb, vec3(gamma)); + fragcolor.rgb = pow(fragcolor.rgb, vec3(u_gamma)); } diff --git a/engine/art/shaders/fs_font.glsl b/engine/art/shaders/fs_font.glsl index c727064..b398e3d 100644 --- a/engine/art/shaders/fs_font.glsl +++ b/engine/art/shaders/fs_font.glsl @@ -4,7 +4,7 @@ in float color_index; uniform sampler2D sampler_font; uniform sampler1D sampler_colors; uniform float num_colors; -uniform float gamma; /// set:2.2 +uniform float u_gamma; /// set:2.2 out vec4 outColor; @@ -12,5 +12,5 @@ void main() { vec4 col = texture(sampler_colors, (color_index+0.5)/num_colors); float s = texture(sampler_font, uv).r; outColor = vec4(col.rgb, s*col.a); - outColor.rgb = pow(outColor.rgb, vec3(gamma)); + outColor.rgb = pow(outColor.rgb, vec3(u_gamma)); } diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 8b90f05..270a910 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -363504,7 +363504,7 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact glUniform1f(glGetUniformLocation(f->program, "scale_factor"), factor); glUniform2fv(glGetUniformLocation(f->program, "string_offset"), 1, &offset.x); glUniform1f(glGetUniformLocation(f->program, "offset_firstline"), f->ascent*f->factor); - glUniform1f(glGetUniformLocation(f->program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(f->program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); GLint dims[4] = {0}; glGetIntegerv(GL_VIEWPORT, dims); @@ -371882,6 +371882,8 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) { shader_mat44("u_mvp", mvp); if( sky->flags ) { shader_cubemap("u_cubemap", sky->cubemap.id); + } else { + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); } return 0; // @fixme: return sortable hash here? } @@ -374096,7 +374098,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) { glUseProgram(dd_program); glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp); - glUniform1f(glGetUniformLocation(dd_program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(dd_program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); static GLuint vao, vbo; if(!vao) glGenVertexArrays(1, &vao); glBindVertexArray(vao); @@ -375860,6 +375862,7 @@ static void sprite_render_meshes_group(batch_group_t* sprites, int alpha_key, in } shader_bind(sprite_program); shader_mat44("u_mvp", mvp); + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); // set (unit 0) in the uniform texture sampler, and render batch glActiveTexture(GL_TEXTURE0); @@ -380014,7 +380017,7 @@ void window_color(unsigned color) { void window_gamma(float _gamma) { gamma = _gamma; shader_bind(gamma_fx.pass[postfx_find(&gamma_fx, "fxGamma.fs")].program); - shader_float("gamma", gamma); + shader_float("u_gamma", 1.0f / gamma); } float window_get_gamma() { return gamma; diff --git a/engine/split/v4k_font.c b/engine/split/v4k_font.c index a9585e4..1b91f7b 100644 --- a/engine/split/v4k_font.c +++ b/engine/split/v4k_font.c @@ -1957,7 +1957,7 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact glUniform1f(glGetUniformLocation(f->program, "scale_factor"), factor); glUniform2fv(glGetUniformLocation(f->program, "string_offset"), 1, &offset.x); glUniform1f(glGetUniformLocation(f->program, "offset_firstline"), f->ascent*f->factor); - glUniform1f(glGetUniformLocation(f->program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(f->program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); GLint dims[4] = {0}; glGetIntegerv(GL_VIEWPORT, dims); diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 9fa5aa0..b314009 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -1862,6 +1862,8 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) { shader_mat44("u_mvp", mvp); if( sky->flags ) { shader_cubemap("u_cubemap", sky->cubemap.id); + } else { + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); } return 0; // @fixme: return sortable hash here? } diff --git a/engine/split/v4k_renderdd.c b/engine/split/v4k_renderdd.c index 2841b5d..78ad637 100644 --- a/engine/split/v4k_renderdd.c +++ b/engine/split/v4k_renderdd.c @@ -76,7 +76,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) { glUseProgram(dd_program); glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp); - glUniform1f(glGetUniformLocation(dd_program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(dd_program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); static GLuint vao, vbo; if(!vao) glGenVertexArrays(1, &vao); glBindVertexArray(vao); diff --git a/engine/split/v4k_sprite.c b/engine/split/v4k_sprite.c index 2aa3ef4..39ade4f 100644 --- a/engine/split/v4k_sprite.c +++ b/engine/split/v4k_sprite.c @@ -280,6 +280,7 @@ static void sprite_render_meshes_group(batch_group_t* sprites, int alpha_key, in } shader_bind(sprite_program); shader_mat44("u_mvp", mvp); + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); // set (unit 0) in the uniform texture sampler, and render batch glActiveTexture(GL_TEXTURE0); diff --git a/engine/split/v4k_window.c b/engine/split/v4k_window.c index e7f9a3a..50f1cb8 100644 --- a/engine/split/v4k_window.c +++ b/engine/split/v4k_window.c @@ -793,7 +793,7 @@ void window_color(unsigned color) { void window_gamma(float _gamma) { gamma = _gamma; shader_bind(gamma_fx.pass[postfx_find(&gamma_fx, "fxGamma.fs")].program); - shader_float("gamma", gamma); + shader_float("u_gamma", 1.0f / gamma); } float window_get_gamma() { return gamma; diff --git a/engine/v4k.c b/engine/v4k.c index df6deb7..bcada5f 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -10659,7 +10659,7 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact glUniform1f(glGetUniformLocation(f->program, "scale_factor"), factor); glUniform2fv(glGetUniformLocation(f->program, "string_offset"), 1, &offset.x); glUniform1f(glGetUniformLocation(f->program, "offset_firstline"), f->ascent*f->factor); - glUniform1f(glGetUniformLocation(f->program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(f->program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); GLint dims[4] = {0}; glGetIntegerv(GL_VIEWPORT, dims); @@ -19037,6 +19037,8 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) { shader_mat44("u_mvp", mvp); if( sky->flags ) { shader_cubemap("u_cubemap", sky->cubemap.id); + } else { + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); } return 0; // @fixme: return sortable hash here? } @@ -21251,7 +21253,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) { glUseProgram(dd_program); glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp); - glUniform1f(glGetUniformLocation(dd_program, "gamma"), (window_get_gamma() + !window_get_gamma())); + glUniform1f(glGetUniformLocation(dd_program, "u_gamma"), (window_get_gamma() + !window_get_gamma())); static GLuint vao, vbo; if(!vao) glGenVertexArrays(1, &vao); glBindVertexArray(vao); @@ -23015,6 +23017,7 @@ static void sprite_render_meshes_group(batch_group_t* sprites, int alpha_key, in } shader_bind(sprite_program); shader_mat44("u_mvp", mvp); + shader_float("u_gamma", window_get_gamma() + !window_get_gamma()); // set (unit 0) in the uniform texture sampler, and render batch glActiveTexture(GL_TEXTURE0); @@ -27169,7 +27172,7 @@ void window_color(unsigned color) { void window_gamma(float _gamma) { gamma = _gamma; shader_bind(gamma_fx.pass[postfx_find(&gamma_fx, "fxGamma.fs")].program); - shader_float("gamma", gamma); + shader_float("u_gamma", 1.0f / gamma); } float window_get_gamma() { return gamma;