Skip to content

Commit

Permalink
Make Pixelate a replacement for Mosaic
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Oct 28, 2024
1 parent b817644 commit 2545359
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 118 deletions.
11 changes: 0 additions & 11 deletions fluXis.Game/Graphics/Shaders/Pixelate/PixelateContainer.cs

This file was deleted.

76 changes: 0 additions & 76 deletions fluXis.Game/Graphics/Shaders/Pixelate/PixelateDrawNode.cs

This file was deleted.

1 change: 0 additions & 1 deletion fluXis.Game/Map/Structures/Events/ShaderEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,5 @@ public enum ShaderType
Vignette,
Retro,
HueShift,
Pixelate,
Glitch
}
2 changes: 0 additions & 2 deletions fluXis.Game/Screens/Edit/Tabs/Design/DesignContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using fluXis.Game.Graphics.Shaders.Retro;
using fluXis.Game.Graphics.Shaders.Vignette;
using fluXis.Game.Graphics.Shaders.HueShift;
using fluXis.Game.Graphics.Shaders.Pixelate;
using fluXis.Game.Graphics.Sprites;
using fluXis.Game.Map.Structures.Events;
using fluXis.Game.Screens.Edit.Tabs.Design.Effects;
Expand Down Expand Up @@ -112,7 +111,6 @@ private ShaderStackContainer createShaderStack()
ShaderType.Vignette => new VignetteContainer(),
ShaderType.Retro => new RetroContainer(),
ShaderType.HueShift => new HueShiftContainer(),
ShaderType.Pixelate => new PixelateContainer(),
ShaderType.Glitch => new GlitchContainer(),
_ => null
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ protected override IEnumerable<Drawable> CreateSettings()
case ShaderType.Vignette:
case ShaderType.Retro:
case ShaderType.HueShift:
case ShaderType.Pixelate:
default: // default shader settings
settings.AddRange(new Drawable[]
{
Expand Down
2 changes: 0 additions & 2 deletions fluXis.Game/Screens/Gameplay/GameplayScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using fluXis.Game.Graphics.Shaders.Retro;
using fluXis.Game.Graphics.Shaders.Vignette;
using fluXis.Game.Graphics.Shaders.HueShift;
using fluXis.Game.Graphics.Shaders.Pixelate;
using fluXis.Game.Graphics.Shaders.Glitch;
using fluXis.Game.Input;
using fluXis.Game.Map;
Expand Down Expand Up @@ -333,7 +332,6 @@ private ShaderStackContainer buildShaders()
ShaderType.Vignette => new VignetteContainer(),
ShaderType.Retro => new RetroContainer(),
ShaderType.HueShift => new HueShiftContainer(),
ShaderType.Pixelate => new PixelateContainer(),
ShaderType.Glitch => new GlitchContainer(),
_ => null
};
Expand Down
13 changes: 8 additions & 5 deletions fluXis.Resources/Shaders/sh_Mosaic.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
layout(std140, set = 0, binding = 0) uniform m_MosaicParameters
layout(std140, set = 0, binding = 0) uniform m_PixelateParameters
{
vec2 g_TexSize;
float g_Strength; // 0 means no effect, 1 means 1x1 pixel blocks
float g_Strength;
};

layout(set = 1, binding = 0) uniform texture2D m_Texture;
Expand All @@ -11,7 +11,10 @@ layout(location = 0) out vec4 o_Colour;

void main(void) {
vec2 uv = gl_FragCoord.xy / g_TexSize;
float blockSize = g_TexSize.x * (1.0 - g_Strength);
vec2 blockPos = floor(uv * blockSize) / blockSize;
o_Colour = texture(sampler2D(m_Texture, m_Sampler), blockPos);

float pixelSizeFactor = mix(1.0, min(g_TexSize.x, g_TexSize.y), 1.0 - g_Strength);
vec2 pixelSize = vec2(pixelSizeFactor, pixelSizeFactor * (g_TexSize.y / g_TexSize.x));
vec2 pixelatedUV = (floor(uv * pixelSize) + 0.5) / pixelSize;

o_Colour = textureLod(sampler2D(m_Texture, m_Sampler), pixelatedUV, 0.0);
}
20 changes: 0 additions & 20 deletions fluXis.Resources/Shaders/sh_Pixelate.fs

This file was deleted.

0 comments on commit 2545359

Please sign in to comment.