~leinnan/raylibGame unlisted

05d87f582b6aa24f2f61b5be36ff86bf7b29cb2d — Piotr Siuszko 4 months ago c72996b
Pixelated shader
2 files changed, 11 insertions(+), 5 deletions(-)

M data/shaders/pixelizer.fs
M src/systems/RenderSystem.cpp
M data/shaders/pixelizer.fs => data/shaders/pixelizer.fs +4 -4
@@ 14,11 14,11 @@ out vec4 finalColor;
// NOTE: Add here your custom variables

// NOTE: Render size values must be passed from code
const float renderWidth = 800;
const float renderHeight = 450;
const float renderWidth = 1280;
const float renderHeight = 720;

uniform float pixelWidth = 5.0;
uniform float pixelHeight = 5.0;
uniform float pixelWidth = 1.5;
uniform float pixelHeight = 1.5;

void main()
{

M src/systems/RenderSystem.cpp => src/systems/RenderSystem.cpp +7 -1
@@ 25,6 25,7 @@ void RenderSystem::Update(entt::registry<> &registry, Camera &camera) {
    const float w = GetScreenWidth();
    const float h = GetScreenHeight();
    auto target = LoadRenderTexture(w,h);
    auto fxShader = LoadShader(0, "data/shaders/pixelizer.fs");
    UpdateCamera(registry,camera);
    BeginDrawing();
    ClearBackground(SKYBLUE);


@@ 56,7 57,11 @@ void RenderSystem::Update(entt::registry<> &registry, Camera &camera) {

    EndMode3D();
    EndTextureMode();
    DrawTextureRec(target.texture, {0,0,w,-h},{0,0},WHITE);
    BeginShaderMode(fxShader);
    {
        DrawTextureRec(target.texture, {0,0,w,-h},{0,0},WHITE);
    }
    EndShaderMode();
    registry.view<Components::WorldScreenText, Components::Transform>().each(
        [&](const auto, const auto &screenText, const auto &transform) {
            Vector2 textScreenPos =


@@ 86,6 91,7 @@ void RenderSystem::Update(entt::registry<> &registry, Camera &camera) {
        });
    EndDrawing();
    UnloadRenderTexture(target);
    UnloadShader(fxShader);
}

Vector3 RenderSystem::getCameraPos(const Vector3 &pos, const float &angle, const Vector3 &cameraOffset) {