12#include "galaxy/core/ServiceLocator.hpp"
21 layout (location = 0) in vec2 l_pos;
22 layout (location = 1) in vec2 l_texels;
26 gl_Position = vec4(l_pos, 0.0, 1.0);
65 #define PI 3.1415926535897932384626433832795
67 out vec4 io_frag_colour;
69 uniform float u_amount;
71 uniform sampler2D u_texture;
75 vec2 tex_size = textureSize(u_texture, 0).xy;
76 vec2 tex_coord = gl_FragCoord.xy / tex_size;
78 vec4 colour = texture(u_texture, tex_coord);
80 float intensity = fract(10000 * sin((gl_FragCoord.x + gl_FragCoord.y * u_time) * PI));
82 colour.rgb += (u_amount * intensity);
84 io_frag_colour = colour;
119 glActiveTexture(GL_TEXTURE0);
120 glBindTexture(GL_TEXTURE_2D, input);
121 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
134 return core::ServiceLocator<core::Config>::ref().get<
bool>(
"film_grain",
"graphics.effects");
constexpr const char *const filmicgrain_vert
FilmicGrain.cpp galaxy.
constexpr const char *const filmicgrain_frag
Filmic Grain fragment shader.
RenderTexture m_fb
Framebuffer to render aberration.
Shader m_shader
Shader for post processing effect.
void resize(const int width, const int height) override
Resize framebuffers.
void set_amount(const float amount)
Set intensity of film grain effect.
bool is_enabled() override
Is this effect enabled?
unsigned int render(const unsigned int input) override
Render effect to input texture.
float m_amount
Film grain intensity.
FilmicGrain()=delete
Constructor.
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.