galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Sharpen.cpp File Reference
#include <algorithm>
#include <glad/glad.h>
#include "galaxy/core/Config.hpp"
#include "galaxy/core/ServiceLocator.hpp"
#include "Sharpen.hpp"
+ Include dependency graph for Sharpen.cpp:

Go to the source code of this file.

Namespaces

namespace  galaxy
 Animated.cpp galaxy.
 
namespace  galaxy::graphics
 

Variables

constexpr const char *const sharpen_vert
 Sharpen.cpp galaxy.
 
constexpr const char *const sharpen_frag
 Sharpen fragment shader.
 

Variable Documentation

◆ sharpen_vert

const char* const sharpen_vert
constexpr
Initial value:
= R"(
#version 460 core
layout (location = 0) in vec2 l_pos;
layout (location = 1) in vec2 l_texels;
void main()
{
gl_Position = vec4(l_pos, 0.0, 1.0);
}
)"

Sharpen.cpp galaxy.

Refer to LICENSE.txt for more details. Basic vertex shader.

Definition at line 20 of file Sharpen.cpp.

◆ sharpen_frag

const char* const sharpen_frag
constexpr
Initial value:
= R"(
#version 460 core
out vec4 io_frag_colour;
uniform float u_amount;
uniform sampler2D u_texture;
void main()
{
vec2 tex_size = textureSize(u_texture, 0).xy;
vec2 frag_coord = gl_FragCoord.xy;
vec2 tex_coord = frag_coord / tex_size;
float neighbour = u_amount * -1.0;
float center = u_amount * 4.0 + 1.0;
vec3 sharpen =
texture(u_texture, (frag_coord + vec2( 0, 1)) / tex_size).rgb * neighbour
+ texture(u_texture, (frag_coord + vec2(-1, 0)) / tex_size).rgb * neighbour
+ texture(u_texture, (frag_coord + vec2( 0, 0)) / tex_size).rgb * center
+ texture(u_texture, (frag_coord + vec2( 1, 0)) / tex_size).rgb * neighbour
+ texture(u_texture, (frag_coord + vec2( 0, -1)) / tex_size).rgb * neighbour;
io_frag_colour = vec4(sharpen, texture(u_texture, tex_coord).a);
}
)"

Sharpen fragment shader.

BSD 3-Clause License

Copyright (c) 2019, David Lettier All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition at line 64 of file Sharpen.cpp.