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 vec2 u_direction;
68 uniform vec3 u_rgb_offset;
69 uniform sampler2D u_texture;
73 vec2 tex_size = textureSize(u_texture, 0).xy;
74 vec2 tex_coord = gl_FragCoord.xy / tex_size;
76 vec2 direction = tex_coord - u_direction;
78 io_frag_colour = texture(u_texture, tex_coord);
79 io_frag_colour.r = texture(u_texture, tex_coord + (direction * vec2(u_rgb_offset.x))).r;
80 io_frag_colour.g = texture(u_texture, tex_coord + (direction * vec2(u_rgb_offset.y))).g;
81 io_frag_colour.b = texture(u_texture, tex_coord + (direction * vec2(u_rgb_offset.z))).b;
92 , m_b_offset {-0.006f}
115 glActiveTexture(GL_TEXTURE0);
116 glBindTexture(GL_TEXTURE_2D, input);
117 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
151 return core::ServiceLocator<core::Config>::ref().get<
bool>(
"chromatic_abberation",
"graphics.effects");
constexpr const char *const chromaticaberration_frag
Chromatic Aberration fragment shader.
constexpr const char *const chromaticaberration_vert
ChromaticAberration.cpp galaxy.
ChromaticAberration()=delete
Constructor.
void resize(const int width, const int height) override
Resize framebuffers.
float m_g_offset
Effect g colour offset.
float m_r_offset
Effect r colour offset.
void set_g_offset(const float g)
Set chromatic r offset.
void set_r_offset(const float r)
Set chromatic r offset.
void set_rgb_offset(const float r, const float g, const float b)
Set chromatic rgb offset.
float m_b_offset
Effect b colour offset.
unsigned int render(const unsigned int input) override
Render effect to input texture.
RenderTexture m_fb
Framebuffer to render aberration.
bool is_enabled() override
Is this effect enabled?
Shader m_shader
Shader for post processing effect.
void set_b_offset(const float b)
Set chromatic r offset.
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.