-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
200 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 450 core | ||
|
||
uniform sampler2D colorTexture; | ||
uniform float power = 2.2; | ||
|
||
layout(location = 0) out vec4 color; | ||
|
||
void main() { | ||
vec4 pixel = texelFetch(colorTexture, ivec2(gl_FragCoord.xy), 0); | ||
color = vec4(pow(pixel.xyz, vec3(1) / power), pixel.w); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#version 450 core | ||
|
||
layout(location = 0) in vec3 position; | ||
|
||
void main() { | ||
gl_Position = vec4(position, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef CHROMATICABERRATIONEFFECT_H | ||
#define CHROMATICABERRATIONEFFECT_H | ||
|
||
#include "PostProcessEffect.h" | ||
|
||
class ChromaticAberrationEffect : public PostProcessEffect { | ||
float aberrationStart = 1.5f; | ||
float aberrationROffset = 0.005; | ||
float aberrationGOffset = 0.01; | ||
float aberrationBOffset = -0.005; | ||
|
||
public: | ||
ChromaticAberrationEffect(bool enabled) | ||
: PostProcessEffect(AssetManager::instance().loadShaderProgram("assets/shaders/chromatic_aberration_effect"), | ||
enabled) {} | ||
|
||
void renderGui() override { | ||
ImGui::Checkbox("Enable chromatic aberration effect", &enabled); | ||
|
||
if (enabled) { | ||
ImGui::SliderFloat("Aberration start", &aberrationStart, 0.5, 3); | ||
ImGui::SliderFloat("Aberration R Offset", &aberrationROffset, -0.01, 0.01); | ||
ImGui::SliderFloat("Aberration G Offset", &aberrationGOffset, -0.01, 0.01); | ||
ImGui::SliderFloat("Aberration B Offset", &aberrationBOffset, -0.01, 0.01); | ||
} | ||
} | ||
|
||
void updateUniforms() override { | ||
shader->setFloat("start", aberrationStart); | ||
shader->setFloat("rOffset", aberrationROffset); | ||
shader->setFloat("gOffset", aberrationGOffset); | ||
shader->setFloat("bOffset", aberrationBOffset); | ||
} | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef CROSSHAIREFFECT_H | ||
#define CROSSHAIREFFECT_H | ||
|
||
#include "../../Application/Window.h" | ||
#include "./PostProcessEffect.h" | ||
|
||
class CrosshairEffect : public PostProcessEffect { | ||
float crosshairSize = 0.015f; | ||
float crosshairVerticalWidth = 0.2f; | ||
float crosshairHorizontalWidth = 0.15f; | ||
|
||
public: | ||
CrosshairEffect(bool enabled) | ||
: PostProcessEffect(AssetManager::instance().loadShaderProgram("assets/shaders/crosshair"), enabled) {} | ||
void renderGui() override { | ||
ImGui::Checkbox("Enable crosshair", &enabled); | ||
if (enabled) { | ||
ImGui::SliderFloat("Crosshair size", &crosshairSize, 0.01, 1); | ||
ImGui::SliderFloat("Crosshair vertical width", &crosshairVerticalWidth, 0.01, 1); | ||
ImGui::SliderFloat("Crosshair horizontal width", &crosshairHorizontalWidth, 0.01, 1); | ||
} | ||
} | ||
|
||
void updateUniforms() override { | ||
auto& window = Window::instance(); | ||
auto width = window.getWindowWidth(); | ||
auto height = window.getWindowHeight(); | ||
float aspectRatio = width == 0 || height == 0 ? 0 : static_cast<float>(width) / static_cast<float>(height); | ||
|
||
shader->setFloat("size", crosshairSize); | ||
shader->setFloat("verticalWidth", crosshairVerticalWidth); | ||
shader->setFloat("horizontalWidth", crosshairHorizontalWidth); | ||
shader->setFloat("aspectRatio", aspectRatio); | ||
} | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef INVERTEFFECT_H | ||
#define INVERTEFFECT_H | ||
|
||
#include "PostProcessEffect.h" | ||
|
||
class InvertEffect : public PostProcessEffect { | ||
public: | ||
InvertEffect(bool enabled) | ||
: PostProcessEffect(AssetManager::instance().loadShaderProgram("assets/shaders/invert_effect"), enabled){} | ||
|
||
void updateUniforms() override {} | ||
|
||
void renderGui() override { | ||
ImGui::Checkbox("Enable invert effect", &enabled); | ||
} | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef POSTPROCESSEFFECT_H | ||
#define POSTPROCESSEFFECT_H | ||
|
||
#include "../../AssetManager/AssetManager.h" | ||
#include "../../Rendering/FrameBuffer.h" | ||
#include "../../Rendering/ShaderProgram.h" | ||
#include "../../glCraft.h" | ||
|
||
class PostProcessEffect { | ||
protected: | ||
bool enabled; | ||
Ref<const ShaderProgram> shader; | ||
Ref<Framebuffer> framebuffer; | ||
|
||
public: | ||
explicit PostProcessEffect(const Ref<const ShaderProgram>& shader, bool enabled = false); | ||
|
||
Ref<const ShaderProgram> getShader() { return shader; }; | ||
|
||
virtual void updateUniforms() = 0; | ||
virtual void renderGui() = 0; | ||
void render(); | ||
|
||
virtual ~PostProcessEffect() = default; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef VIGNETTEEFFECT_H | ||
#define VIGNETTEEFFECT_H | ||
|
||
#include "PostProcessEffect.h" | ||
|
||
class VignetteEffect : public PostProcessEffect { | ||
float vignetteIntensity = 2.9; | ||
float vignetteStart = 1.5f; | ||
|
||
public: | ||
VignetteEffect(bool enabled) | ||
: PostProcessEffect(AssetManager::instance().loadShaderProgram("assets/shaders/vignette_effect"), enabled) {} | ||
|
||
void updateUniforms() override { | ||
shader->setFloat("intensity", vignetteIntensity); | ||
shader->setFloat("start", vignetteStart); | ||
} | ||
|
||
void renderGui() override { | ||
ImGui::Checkbox("Enable vignette effect", &enabled); | ||
|
||
if (enabled) { | ||
float invertedIntensity = 4 - vignetteIntensity; | ||
if (ImGui::SliderFloat("Vignette intensity", &invertedIntensity, 1, 3)) { | ||
vignetteIntensity = 4 - invertedIntensity; | ||
} | ||
|
||
ImGui::SliderFloat("Vignette start", &vignetteStart, 0, 3); | ||
} | ||
} | ||
}; | ||
|
||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.