11#include "galaxy/core/ServiceLocator.hpp"
20 layout (location = 0) in vec2 l_pos;
21 layout (location = 1) in vec2 l_texels;
25 gl_Position = vec4(l_pos, 0.0, 1.0);
65 out vec4 io_frag_colour;
67 uniform float u_gamma;
68 uniform sampler2D u_texture;
72 vec2 uv = gl_FragCoord.xy / textureSize(u_texture, 0).xy;
74 io_frag_colour = texture(u_texture, uv);
75 io_frag_colour.rgb = pow(io_frag_colour.rgb, vec3(1.0 / u_gamma));
106 glActiveTexture(GL_TEXTURE0);
107 glBindTexture(GL_TEXTURE_2D, input);
108 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
117 if (
static_cast<int>(
m_gamma) == 0)
132 return core::ServiceLocator<core::Config>::ref().get<
bool>(
"gamma_correction",
"graphics.effects");
constexpr const char *const gammacorrection_vert
GammaCorrection.cpp galaxy.
constexpr const char *const gammacorrection_frag
Gamma Correction fragment shader.
bool is_enabled() override
Is this effect enabled?
void set_gamma(const float gamma_mod)
Set gamma modifier.
unsigned int render(const unsigned int input) override
Render effect to input texture.
float m_gamma
Amount to adjust gamma by.
RenderTexture m_fb
Framebuffer to render effect to.
float get_gamma() const
Get gamma modifier.
GammaCorrection()=delete
Constructor.
void resize(const int width, const int height) override
Resize framebuffers.
Shader m_shader
Shader for post processing effect.
void create(const int width, const int height)
Create framebuffer and texture.
unsigned int texture() const
Gets framebuffer texture.
void recreate(const int width=-1, const int height=-1)
Destroy and re-create framebuffer.
void bind(bool clear=true)
Activate context.
bool parse(const std::string &src)
Loads a combined raw shader.
void set_uniform(const std::string &name, const Uniforms &... args)
Specialized variadic template for setting shader uniforms.
void compile()
Compiles shader into GPU mem.
void bind() const
Make active shader.