Skip to content

Commit fe58ef1

Browse files
Merge pull request #7 from stringfromjava/develop
Develop
2 parents 3491d5a + dc06e28 commit fe58ef1

21 files changed

+1439
-997
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# HaxeFlixel
22
.haxelib/
33
export/
4-
dump/
54
temp/
65

76
# macOS

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Ignore artifacts
2-
export/
2+
.haxelib/
33
dump/
4+
export/
45
temp/

COMPILING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ These are the necessary steps required to compile on the game on __***every***__
3131

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

34+
> [!TIP]
35+
> If the libraries do not install correctly, then you can run the `.bat` file or `.sh` file (according to your system).
36+
3437
9. Run `haxelib run lime setup` to setup the lime command.
3538
- 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.
3639

@@ -40,6 +43,9 @@ These are the necessary steps required to compile on the game on __***every***__
4043
> [!TIP]
4144
> You can replace `html5` with other platforms to compile it accordingly.
4245
46+
> [!IMPORTANT]
47+
> 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.
48+
4349
## Extra Steps (for Running and Configuring the Game on Other Platforms)
4450

4551
### Windows

assets/shaders/ntsc.frag

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#pragma header
2+
3+
#pragma format R8G8B8A8_SRGB
4+
5+
#define NTSC_CRT_GAMMA 2.5
6+
#define NTSC_MONITOR_GAMMA 2.0
7+
8+
#define TWO_PHASE
9+
#define COMPOSITE
10+
//#define THREE_PHASE
11+
// #define SVIDEO
12+
13+
// begin params
14+
#define PI 3.14159265
15+
16+
#if defined(TWO_PHASE)
17+
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
18+
#elif defined(THREE_PHASE)
19+
#define CHROMA_MOD_FREQ (PI / 3.0)
20+
#endif
21+
22+
#if defined(COMPOSITE)
23+
#define SATURATION 1.0
24+
#define BRIGHTNESS 1.0
25+
#define ARTIFACTING 1.0
26+
#define FRINGING 1.0
27+
#elif defined(SVIDEO)
28+
#define SATURATION 1.0
29+
#define BRIGHTNESS 1.0
30+
#define ARTIFACTING 0.0
31+
#define FRINGING 0.0
32+
#endif
33+
// end params
34+
35+
uniform int uFrame;
36+
uniform float uInterlace;
37+
38+
// fragment compatibility #defines
39+
40+
#if defined(COMPOSITE) || defined(SVIDEO)
41+
mat3 mix_mat = mat3(
42+
BRIGHTNESS, FRINGING, FRINGING,
43+
ARTIFACTING, 2.0 * SATURATION, 0.0,
44+
ARTIFACTING, 0.0, 2.0 * SATURATION
45+
);
46+
#endif
47+
48+
// begin ntsc-rgbyuv
49+
const mat3 yiq2rgb_mat = mat3(
50+
1.0, 0.956, 0.6210,
51+
1.0, -0.2720, -0.6474,
52+
1.0, -1.1060, 1.7046);
53+
54+
vec3 yiq2rgb(vec3 yiq)
55+
{
56+
return yiq * yiq2rgb_mat;
57+
}
58+
59+
const mat3 yiq_mat = mat3(
60+
0.2989, 0.5870, 0.1140,
61+
0.5959, -0.2744, -0.3216,
62+
0.2115, -0.5229, 0.3114
63+
);
64+
65+
vec3 rgb2yiq(vec3 col)
66+
{
67+
return col * yiq_mat;
68+
}
69+
// end ntsc-rgbyuv
70+
71+
#define TAPS 32
72+
const float luma_filter[TAPS + 1] = float[TAPS + 1](
73+
-0.000174844,
74+
-0.000205844,
75+
-0.000149453,
76+
-0.000051693,
77+
0.000000000,
78+
-0.000066171,
79+
-0.000245058,
80+
-0.000432928,
81+
-0.000472644,
82+
-0.000252236,
83+
0.000198929,
84+
0.000687058,
85+
0.000944112,
86+
0.000803467,
87+
0.000363199,
88+
0.000013422,
89+
0.000253402,
90+
0.001339461,
91+
0.002932972,
92+
0.003983485,
93+
0.003026683,
94+
-0.001102056,
95+
-0.008373026,
96+
-0.016897700,
97+
-0.022914480,
98+
-0.021642347,
99+
-0.008863273,
100+
0.017271957,
101+
0.054921920,
102+
0.098342579,
103+
0.139044281,
104+
0.168055832,
105+
0.178571429);
106+
107+
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
108+
0.001384762,
109+
0.001678312,
110+
0.002021715,
111+
0.002420562,
112+
0.002880460,
113+
0.003406879,
114+
0.004004985,
115+
0.004679445,
116+
0.005434218,
117+
0.006272332,
118+
0.007195654,
119+
0.008204665,
120+
0.009298238,
121+
0.010473450,
122+
0.011725413,
123+
0.013047155,
124+
0.014429548,
125+
0.015861306,
126+
0.017329037,
127+
0.018817382,
128+
0.020309220,
129+
0.021785952,
130+
0.023227857,
131+
0.024614500,
132+
0.025925203,
133+
0.027139546,
134+
0.028237893,
135+
0.029201910,
136+
0.030015081,
137+
0.030663170,
138+
0.031134640,
139+
0.031420995,
140+
0.031517031);
141+
142+
vec4 pass1(vec2 uv)
143+
{
144+
vec2 fragCoord = uv * openfl_TextureSize;
145+
146+
vec4 cola = texture2D(bitmap, uv).rgba;
147+
vec3 yiq = rgb2yiq(cola.rgb);
148+
149+
#if defined(TWO_PHASE)
150+
float chroma_phase = PI * (mod(fragCoord.y, 2.0) + float(uFrame));
151+
#elif defined(THREE_PHASE)
152+
float chroma_phase = 0.6667 * PI * (mod(fragCoord.y, 3.0) + float(uFrame));
153+
#endif
154+
155+
float mod_phase = chroma_phase + fragCoord.x * CHROMA_MOD_FREQ;
156+
157+
float i_mod = cos(mod_phase);
158+
float q_mod = sin(mod_phase);
159+
160+
if(uInterlace == 1.0) {
161+
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
162+
yiq *= mix_mat; // Cross-talk.
163+
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
164+
}
165+
return vec4(yiq, cola.a);
166+
}
167+
168+
vec4 fetch_offset(vec2 uv, float offset, float one_x) {
169+
return pass1(uv + vec2((offset - 0.5) * one_x, 0.0)).xyzw;
170+
}
171+
172+
void main()
173+
{
174+
vec2 uv = openfl_TextureCoordv;
175+
vec2 fragCoord = uv * openfl_TextureSize;
176+
177+
float one_x = 1.0 / openfl_TextureSize.x;
178+
vec4 signal = vec4(0.0);
179+
180+
for (int i = 0; i < TAPS; i++)
181+
{
182+
float offset = float(i);
183+
184+
vec4 sums = fetch_offset(uv, offset - float(TAPS), one_x) * 2;
185+
186+
signal += sums * vec4(luma_filter[i], chroma_filter[i], chroma_filter[i], 1.0);
187+
}
188+
signal += pass1(uv - vec2(0.5 / openfl_TextureSize.x, 0.0)).xyzw *
189+
vec4(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS], 1.0);
190+
191+
vec3 rgb = yiq2rgb(signal.xyz);
192+
gl_FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA / NTSC_MONITOR_GAMMA)), flixel_texture2D(bitmap, uv).a);
193+
}

assets/shaders/skew.frag

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//SHADERTOY PORT FIX
2+
#pragma header
3+
vec2 uv = openfl_TextureCoordv.xy;
4+
vec2 fragCoord = openfl_TextureCoordv*openfl_TextureSize;
5+
vec2 iResolution = openfl_TextureSize;
6+
uniform float iTime;
7+
#define iChannel0 bitmap
8+
#define texture flixel_texture2D
9+
#define fragColor gl_FragColor
10+
#define mainImage main
11+
//SHADERTOY PORT FIX
12+
13+
uniform float skew = 0.0;
14+
15+
16+
17+
float lerpp(float a, float b, float t){
18+
return a + (b - a) * t;
19+
}
20+
void main(void){
21+
float dfb = uv.y;
22+
vec4 c = vec4(0.0,0.0,0.0,0.0);
23+
vec2 pos = uv;
24+
pos.x = uv.x+(skew*dfb);
25+
if(pos.x > 0 && pos.x < 1){
26+
gl_FragColor = flixel_texture2D( bitmap, pos);
27+
}
28+
29+
}

assets/shaders/vcrlines.frag

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#pragma header
2+
3+
#ifdef GL_ES
4+
precision mediump float;
5+
#endif
6+
7+
uniform float time;
8+
uniform vec2 resolution;
9+
10+
float pi = 3.14159265359;
11+
float curvature = 0.065;
12+
float vignetteStrength = 0.4;
13+
float theScanLine = 0.0;
14+
15+
vec2 curve(vec2 inp)
16+
{
17+
inp.x = inp.x - sin(inp.y * pi) * curvature * (inp.x - 0.5);
18+
inp.y = inp.y - sin(inp.x * pi) * curvature * (inp.y - 0.5);
19+
return inp;
20+
}
21+
22+
vec2 zoomOut(vec2 inp)
23+
{
24+
float zoom = 1.0 + 1.3 * curvature;
25+
return vec2(0.5, 0.5) + ((inp - vec2(0.5, 0.5)) * zoom);
26+
}
27+
28+
float lerp(float a, float b, float c)
29+
{
30+
return a + c * (b - a);
31+
}
32+
33+
vec4 vignette(vec2 inp)
34+
{
35+
float t = 0.0;
36+
t = lerp(0.5, vignetteStrength * distance(inp, vec2(0.5, 0.5)), 0.98);
37+
return vec4(t, t, t, 1.0);
38+
}
39+
40+
vec4 staticc(vec2 inp)
41+
{
42+
float t = 0.0;
43+
t = cos(inp.y * resolution.y) * 2.0;
44+
45+
float val = sin(100.0 + time * cos(100.0 + time) * 2.0) * 14.0 * inp.y;
46+
val = clamp(val, -1.55, 1.55);
47+
t += tan(val) * 0.05;
48+
49+
return vec4(t, t, t, 1.0);
50+
}
51+
52+
bool inRect(vec2 rect, vec2 rectDim, vec2 inp)
53+
{
54+
vec2 clamped = clamp(inp, rect, rectDim);
55+
return (clamped.x == inp.x && clamped.y == inp.y);
56+
}
57+
58+
void main(void)
59+
{
60+
vec2 uv = zoomOut(curve(openfl_TextureCoordv.xy));
61+
vec4 col;
62+
theScanLine = sin(time * pi + uv.y) + tan(time - uv.y * uv.y) - cos(uv.y);
63+
64+
if (inRect(vec2(0.0, 0.0), vec2(1.0, 1.0), uv))
65+
{
66+
if (inRect(vec2(0.0, theScanLine), vec2(1.0, theScanLine + 0.1), uv))
67+
uv.x -= sin(theScanLine - uv.y) * 0.04; // Scanline distortion is determined by the last number
68+
69+
// FIXED: use `bitmap` and `texture`
70+
col = texture(bitmap, uv);
71+
72+
col -= vignette(uv);
73+
col += staticc(uv) * 0.015;
74+
}
75+
else
76+
{
77+
col = vec4(0.0, 0.0, 0.0, 1.0);
78+
}
79+
80+
gl_FragColor = col;
81+
}

0 commit comments

Comments
 (0)