Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ntsc-simple to match ZX Spectrum actual composite/RF artifacts #391

Merged
merged 3 commits into from
Feb 5, 2024
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
4 changes: 2 additions & 2 deletions ntsc/shaders/ntsc-simple/ntsc-simple-1.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const mat3 RGBYIQ = mat3(0.299, 0.596, 0.211,

void main()
{
float phase = vTexCoord.x*SourceSize.x*PI/2.0 -vTexCoord.y*SourceSize.y*2.0;
float phase = (vTexCoord.x*SourceSize.x -mod(vTexCoord.y*SourceSize.y,2.0))*PI/2.0 ;
phase += ntsc_hue;
vec3 YIQ = COMPAT_TEXTURE(Source,vTexCoord).rgb;
YIQ = YIQ*RGBYIQ;
if (animate_afacts == 1.0) phase -= (vTexCoord.y*SourceSize.y*2.0)*PI*mod(float(FrameCount),2.0);
if (animate_afacts == 1.0) phase -= sin(float(FrameCount));
float signal = ntsc_bri*YIQ.x + (YIQ.y*cos(phase) + YIQ.z*sin(phase)) ;
FragColor = vec4(vec3(signal), 1.0);

Expand Down
6 changes: 3 additions & 3 deletions ntsc/shaders/ntsc-simple/ntsc-simple-2.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#pragma parameter ntsc_sat "NTSC Saturation" 1.25 0.0 2.0 0.05
#pragma parameter afacts "NTSC Artifacts Strength (lowpass Y)" 0.02 0.0 1.0 0.01
#pragma parameter animate_afacts "NTSC Artifacts Animate" 1.0 0.0 1.0 1.0
#pragma parameter animate_afacts "NTSC Artifacts Animate" 0.0 0.0 1.0 1.0

#if defined(VERTEX)

Expand Down Expand Up @@ -141,9 +141,9 @@ vec2 uv = vTexCoord;

for (int n=-8; n<8; n++) {
vec2 pos = uv + vec2(float(n) / size.x, 0.0);
float phase = (vTexCoord.x*SourceSize.x + float(n))*PI/2.0 - vTexCoord.y*SourceSize.y*2.0;
float phase = (vTexCoord.x*SourceSize.x + float(n)- mod(vTexCoord.y*SourceSize.y,2.0))*PI/2.0 ;
//animate to hide artifacts
if (animate_afacts == 1.0) phase -= (vTexCoord.y*SourceSize.y*2.0)*PI*mod(float(FrameCount),2.0);
if (animate_afacts == 1.0) phase -= sin(float(FrameCount));
// missing a bandpass here to weaken artifacts on high luminance
YIQ.yz += COMPAT_TEXTURE(Source, pos).gb * ntsc_sat*vec2(cos(phase), sin(phase));
}
Expand Down