Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# HaxeFlixel
.haxelib/
export/
dump/
temp/

# macOS
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore artifacts
export/
.haxelib/
dump/
export/
temp/
6 changes: 6 additions & 0 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ These are the necessary steps required to compile on the game on __***every***__

8. Run `hmm install` to start installing all of the game's dependencies. **This will take a bit, so be patient**.

> [!TIP]
> If the libraries do not install correctly, then you can run the `.bat` file or `.sh` file (according to your system).

9. Run `haxelib run lime setup` to setup the lime command.
- This will allow you to compile and run the game on many common platforms, such as every major desktop platform (Windows, macOS, Linux, etc.), both popular mobile systems (Android and iOS), and more.

Expand All @@ -40,6 +43,9 @@ These are the necessary steps required to compile on the game on __***every***__
> [!TIP]
> You can replace `html5` with other platforms to compile it accordingly.

> [!IMPORTANT]
> If ever, for some reason, the shaders make the screen become black, it is advised you clear your computer's `Temp/` directory. If the issue persists, then please take a look at the [contributing](CONTRIBUTING.md) file for info on how to report a bug.

## Extra Steps (for Running and Configuring the Game on Other Platforms)

### Windows
Expand Down
193 changes: 193 additions & 0 deletions assets/shaders/ntsc.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#pragma header

#pragma format R8G8B8A8_SRGB

#define NTSC_CRT_GAMMA 2.5
#define NTSC_MONITOR_GAMMA 2.0

#define TWO_PHASE
#define COMPOSITE
//#define THREE_PHASE
// #define SVIDEO

// begin params
#define PI 3.14159265

#if defined(TWO_PHASE)
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
#elif defined(THREE_PHASE)
#define CHROMA_MOD_FREQ (PI / 3.0)
#endif

#if defined(COMPOSITE)
#define SATURATION 1.0
#define BRIGHTNESS 1.0
#define ARTIFACTING 1.0
#define FRINGING 1.0
#elif defined(SVIDEO)
#define SATURATION 1.0
#define BRIGHTNESS 1.0
#define ARTIFACTING 0.0
#define FRINGING 0.0
#endif
// end params

uniform int uFrame;
uniform float uInterlace;

// fragment compatibility #defines

#if defined(COMPOSITE) || defined(SVIDEO)
mat3 mix_mat = mat3(
BRIGHTNESS, FRINGING, FRINGING,
ARTIFACTING, 2.0 * SATURATION, 0.0,
ARTIFACTING, 0.0, 2.0 * SATURATION
);
#endif

// begin ntsc-rgbyuv
const mat3 yiq2rgb_mat = mat3(
1.0, 0.956, 0.6210,
1.0, -0.2720, -0.6474,
1.0, -1.1060, 1.7046);

vec3 yiq2rgb(vec3 yiq)
{
return yiq * yiq2rgb_mat;
}

const mat3 yiq_mat = mat3(
0.2989, 0.5870, 0.1140,
0.5959, -0.2744, -0.3216,
0.2115, -0.5229, 0.3114
);

vec3 rgb2yiq(vec3 col)
{
return col * yiq_mat;
}
// end ntsc-rgbyuv

#define TAPS 32
const float luma_filter[TAPS + 1] = float[TAPS + 1](
-0.000174844,
-0.000205844,
-0.000149453,
-0.000051693,
0.000000000,
-0.000066171,
-0.000245058,
-0.000432928,
-0.000472644,
-0.000252236,
0.000198929,
0.000687058,
0.000944112,
0.000803467,
0.000363199,
0.000013422,
0.000253402,
0.001339461,
0.002932972,
0.003983485,
0.003026683,
-0.001102056,
-0.008373026,
-0.016897700,
-0.022914480,
-0.021642347,
-0.008863273,
0.017271957,
0.054921920,
0.098342579,
0.139044281,
0.168055832,
0.178571429);

const float chroma_filter[TAPS + 1] = float[TAPS + 1](
0.001384762,
0.001678312,
0.002021715,
0.002420562,
0.002880460,
0.003406879,
0.004004985,
0.004679445,
0.005434218,
0.006272332,
0.007195654,
0.008204665,
0.009298238,
0.010473450,
0.011725413,
0.013047155,
0.014429548,
0.015861306,
0.017329037,
0.018817382,
0.020309220,
0.021785952,
0.023227857,
0.024614500,
0.025925203,
0.027139546,
0.028237893,
0.029201910,
0.030015081,
0.030663170,
0.031134640,
0.031420995,
0.031517031);

vec4 pass1(vec2 uv)
{
vec2 fragCoord = uv * openfl_TextureSize;

vec4 cola = texture2D(bitmap, uv).rgba;
vec3 yiq = rgb2yiq(cola.rgb);

#if defined(TWO_PHASE)
float chroma_phase = PI * (mod(fragCoord.y, 2.0) + float(uFrame));
#elif defined(THREE_PHASE)
float chroma_phase = 0.6667 * PI * (mod(fragCoord.y, 3.0) + float(uFrame));
#endif

float mod_phase = chroma_phase + fragCoord.x * CHROMA_MOD_FREQ;

float i_mod = cos(mod_phase);
float q_mod = sin(mod_phase);

if(uInterlace == 1.0) {
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
yiq *= mix_mat; // Cross-talk.
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
}
return vec4(yiq, cola.a);
}

vec4 fetch_offset(vec2 uv, float offset, float one_x) {
return pass1(uv + vec2((offset - 0.5) * one_x, 0.0)).xyzw;
}

void main()
{
vec2 uv = openfl_TextureCoordv;
vec2 fragCoord = uv * openfl_TextureSize;

float one_x = 1.0 / openfl_TextureSize.x;
vec4 signal = vec4(0.0);

for (int i = 0; i < TAPS; i++)
{
float offset = float(i);

vec4 sums = fetch_offset(uv, offset - float(TAPS), one_x) * 2;

signal += sums * vec4(luma_filter[i], chroma_filter[i], chroma_filter[i], 1.0);
}
signal += pass1(uv - vec2(0.5 / openfl_TextureSize.x, 0.0)).xyzw *
vec4(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS], 1.0);

vec3 rgb = yiq2rgb(signal.xyz);
gl_FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA / NTSC_MONITOR_GAMMA)), flixel_texture2D(bitmap, uv).a);
}
29 changes: 29 additions & 0 deletions assets/shaders/skew.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//SHADERTOY PORT FIX
#pragma header
vec2 uv = openfl_TextureCoordv.xy;
vec2 fragCoord = openfl_TextureCoordv*openfl_TextureSize;
vec2 iResolution = openfl_TextureSize;
uniform float iTime;
#define iChannel0 bitmap
#define texture flixel_texture2D
#define fragColor gl_FragColor
#define mainImage main
//SHADERTOY PORT FIX

uniform float skew = 0.0;



float lerpp(float a, float b, float t){
return a + (b - a) * t;
}
void main(void){
float dfb = uv.y;
vec4 c = vec4(0.0,0.0,0.0,0.0);
vec2 pos = uv;
pos.x = uv.x+(skew*dfb);
if(pos.x > 0 && pos.x < 1){
gl_FragColor = flixel_texture2D( bitmap, pos);
}

}
81 changes: 81 additions & 0 deletions assets/shaders/vcrlines.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#pragma header

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 resolution;

float pi = 3.14159265359;
float curvature = 0.065;
float vignetteStrength = 0.4;
float theScanLine = 0.0;

vec2 curve(vec2 inp)
{
inp.x = inp.x - sin(inp.y * pi) * curvature * (inp.x - 0.5);
inp.y = inp.y - sin(inp.x * pi) * curvature * (inp.y - 0.5);
return inp;
}

vec2 zoomOut(vec2 inp)
{
float zoom = 1.0 + 1.3 * curvature;
return vec2(0.5, 0.5) + ((inp - vec2(0.5, 0.5)) * zoom);
}

float lerp(float a, float b, float c)
{
return a + c * (b - a);
}

vec4 vignette(vec2 inp)
{
float t = 0.0;
t = lerp(0.5, vignetteStrength * distance(inp, vec2(0.5, 0.5)), 0.98);
return vec4(t, t, t, 1.0);
}

vec4 staticc(vec2 inp)
{
float t = 0.0;
t = cos(inp.y * resolution.y) * 2.0;

float val = sin(100.0 + time * cos(100.0 + time) * 2.0) * 14.0 * inp.y;
val = clamp(val, -1.55, 1.55);
t += tan(val) * 0.05;

return vec4(t, t, t, 1.0);
}

bool inRect(vec2 rect, vec2 rectDim, vec2 inp)
{
vec2 clamped = clamp(inp, rect, rectDim);
return (clamped.x == inp.x && clamped.y == inp.y);
}

void main(void)
{
vec2 uv = zoomOut(curve(openfl_TextureCoordv.xy));
vec4 col;
theScanLine = sin(time * pi + uv.y) + tan(time - uv.y * uv.y) - cos(uv.y);

if (inRect(vec2(0.0, 0.0), vec2(1.0, 1.0), uv))
{
if (inRect(vec2(0.0, theScanLine), vec2(1.0, theScanLine + 0.1), uv))
uv.x -= sin(theScanLine - uv.y) * 0.04; // Scanline distortion is determined by the last number

// FIXED: use `bitmap` and `texture`
col = texture(bitmap, uv);

col -= vignette(uv);
col += staticc(uv) * 0.015;
}
else
{
col = vec4(0.0, 0.0, 0.0, 1.0);
}

gl_FragColor = col;
}
Loading