Skip to content

Commit

Permalink
p
Browse files Browse the repository at this point in the history
  • Loading branch information
PurSnake committed Jun 18, 2024
1 parent c029667 commit ba385a5
Show file tree
Hide file tree
Showing 32 changed files with 1,052 additions and 531 deletions.
4 changes: 4 additions & 0 deletions source/funkin/audio/visualize/ABotVis.hx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class ABotVis extends FlxTypedSpriteGroup<FlxSprite>
{
var animFrame:Int = Math.round(levels[i].value * 5);

#if desktop
animFrame = Math.round(animFrame * FlxG.sound.volume);
#end

animFrame = Math.floor(Math.min(5, animFrame));
animFrame = Math.floor(Math.max(0, animFrame));

Expand Down
86 changes: 62 additions & 24 deletions source/funkin/graphics/shaders/AngleMask.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,78 @@ import flixel.system.FlxAssets.FlxShader;

class AngleMask extends FlxShader
{
@:glFragmentSource('
@:glFragmentSource('
#pragma header
uniform vec2 endPosition;
void main()
{
vec4 base = texture2D(bitmap, openfl_TextureCoordv);

vec2 uv = openfl_TextureCoordv.xy;
uniform vec2 endPosition;
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.xx + p3.yz) * p3.zy);
}



vec2 start = vec2(0.0, 0.0);
vec2 end = vec2(endPosition.x / openfl_TextureSize.x, 1.0);
// ====== GAMMA CORRECTION ====== //
// Helps with color mixing -- good to have by default in almost any shader
// See https://www.shadertoy.com/view/lscSzl
vec3 gamma(in vec3 color) {
return pow(color, vec3(1.0 / 2.2));
}

float dx = end.x - start.x;
float dy = end.y - start.y;
vec4 mainPass(vec2 fragCoord) {
vec4 base = texture2D(bitmap, fragCoord);

float angle = atan(dy, dx);
vec2 uv = fragCoord.xy;

uv.x -= start.x;
uv.y -= start.y;
vec2 start = vec2(0.0, 0.0);
vec2 end = vec2(endPosition.x / openfl_TextureSize.x, 1.0);

float uvA = atan(uv.y, uv.x);
float dx = end.x - start.x;
float dy = end.y - start.y;

if (uvA < angle)
gl_FragColor = base;
else
gl_FragColor = vec4(0.0);
float angle = atan(dy, dx);

uv.x -= start.x;
uv.y -= start.y;

float uvA = atan(uv.y, uv.x);

if (uvA < angle)
return base;
else
return vec4(0.0);
}

vec4 antialias(vec2 fragCoord) {

const float AA_STAGES = 2.0;

const float AA_TOTAL_PASSES = AA_STAGES * AA_STAGES + 1.0;
const float AA_JITTER = 0.5;

// Run the shader multiple times with a random subpixel offset each time and average the results
vec4 color = mainPass(fragCoord);
for (float x = 0.0; x < AA_STAGES; x++)
{
for (float y = 0.0; y < AA_STAGES; y++)
{
vec2 offset = AA_JITTER * (2.0 * hash22(vec2(x, y)) - 1.0) / openfl_TextureSize.xy;
color += mainPass(fragCoord + offset);
}
}
return color / AA_TOTAL_PASSES;
}

void main() {
vec4 col = antialias(openfl_TextureCoordv);
// col.xyz = gamma(col.xyz);
gl_FragColor = col;
}')
public function new()
{
super();
public function new()
{
super();

endPosition.value = [90, 100]; // 100 AS DEFAULT WORKS NICELY FOR FREEPLAY?
}
}
endPosition.value = [90, 100]; // 100 AS DEFAULT WORKS NICELY FOR FREEPLAY?
}
}
Loading

0 comments on commit ba385a5

Please sign in to comment.