Skip to content

Commit

Permalink
dont ask
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Feb 22, 2024
1 parent 8e890e9 commit 9e6e629
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
Binary file added assets/shared/images/funnyskeletonman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/zzzzzzzz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions source/shaders/MosaicEffect.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package shaders;

import shaders.MosaicShader;

class MosaicEffect
{
/**
* The effect's "start-value" on the x/y-axes (the effect is not visible with this value).
*/
public static inline var DEFAULT_STRENGTH:Float = 1;

/**
* The instance of the actual shader class
*/
public var shader(default, null):MosaicShader;

/**
* The effect's strength on the x-axis.
*/
public var strengthX(default, null):Float = DEFAULT_STRENGTH;

/**
* The effect's strength on the y-axis.
*/
public var strengthY(default, null):Float = DEFAULT_STRENGTH;

public function new():Void
{
shader = new MosaicShader();
shader.data.uBlocksize.value = [strengthX, strengthY];
}

public function setStrength(strengthX:Float, strengthY:Float):Void
{
this.strengthX = strengthX;
this.strengthY = strengthY;
shader.uBlocksize.value[0] = strengthX;
shader.uBlocksize.value[1] = strengthY;
}
}
24 changes: 24 additions & 0 deletions source/shaders/MosaicShader.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package shaders;

import flixel.system.FlxAssets.FlxShader;

/**
* A classic mosaic effect, just like in the old days!
*
* Usage notes:
* - The effect will be applied to the whole screen.
* - Set the x/y-values on the 'uBlocksize' vector to the desired size (setting this to 0 will make the screen go black)
*/
class MosaicShader extends FlxShader
{
@:glFragmentSource('
#pragma header
uniform vec2 uBlocksize;

void main()
{
vec2 blocks = openfl_TextureSize / uBlocksize;
gl_FragColor = flixel_texture2D(bitmap, floor(openfl_TextureCoordv * blocks) / blocks);
}')
public function new() super();
}

0 comments on commit 9e6e629

Please sign in to comment.