diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 7ab74c41a..395047d9a 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -54,14 +54,15 @@ template class MOS6560 { audio_generator_(audio_queue_), speaker_(audio_generator_) { - crt_->set_composite_sampling_function( - "float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)" + crt_->set_svideo_sampling_function( + "vec2 svideo_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase)" "{" "vec2 yc = texture(texID, coordinate).rg / vec2(255.0);" - "float phaseOffset = 6.283185308 * 2.0 * yc.y;" - "float chroma = cos(phase + phaseOffset);" - "return mix(yc.x, step(yc.y, 0.75) * chroma, amplitude);" + "float phaseOffset = 6.283185308 * 2.0 * yc.y;" + "float chroma = step(yc.y, 0.75) * cos(phase + phaseOffset);" + + "return vec2(yc.x, chroma);" "}"); // default to NTSC diff --git a/Machines/Atari2600/TIA.cpp b/Machines/Atari2600/TIA.cpp index 63d637bf6..f1f8b1437 100644 --- a/Machines/Atari2600/TIA.cpp +++ b/Machines/Atari2600/TIA.cpp @@ -123,20 +123,20 @@ void TIA::set_output_mode(Atari2600::TIA::OutputMode output_mode) { Outputs::CRT::DisplayType display_type; if(output_mode == OutputMode::NTSC) { - crt_->set_composite_sampling_function( - "float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)" + crt_->set_svideo_sampling_function( + "vec2 svideo_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase)" "{" "uint c = texture(texID, coordinate).r;" "uint y = c & 14u;" "uint iPhase = (c >> 4);" "float phaseOffset = 6.283185308 * float(iPhase) / 13.0 + 5.074880441076923;" - "return mix(float(y) / 14.0, step(1, iPhase) * cos(phase + phaseOffset), amplitude);" + "return vec2(float(y) / 14.0, step(1, iPhase) * cos(phase + phaseOffset));" "}"); display_type = Outputs::CRT::DisplayType::NTSC60; } else { - crt_->set_composite_sampling_function( - "float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)" + crt_->set_svideo_sampling_function( + "vec2 svideo_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase)" "{" "uint c = texture(texID, coordinate).r;" "uint y = c & 14u;" @@ -145,7 +145,7 @@ void TIA::set_output_mode(Atari2600::TIA::OutputMode output_mode) { "uint direction = iPhase & 1u;" "float phaseOffset = float(7u - direction) + (float(direction) - 0.5) * 2.0 * float(iPhase >> 1);" "phaseOffset *= 6.283185308 / 12.0;" - "return mix(float(y) / 14.0, step(4, (iPhase + 2u) & 15u) * cos(phase + phaseOffset), amplitude);" + "return vec2(float(y) / 14.0, step(4, (iPhase + 2u) & 15u) * cos(phase + phaseOffset));" "}"); display_type = Outputs::CRT::DisplayType::PAL50; } diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index f989d725f..8bb35bbe2 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -180,7 +180,7 @@ std::unique_ptr IntermediateShader::make_svideo_source_shade fragment_shader << rgb_shader << "uniform mat3 rgbToLumaChroma;" - "float svideo_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase)" + "vec2 svideo_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase)" "{" "vec3 rgbColour = clamp(rgb_sample(texID, coordinate, iCoordinate), vec3(0.0), vec3(1.0));" "vec3 lumaChromaColour = rgbToLumaChroma * rgbColour;" @@ -194,7 +194,7 @@ std::unique_ptr IntermediateShader::make_svideo_source_shade "{" "vec2 sample = svideo_sample(texID, inputPositionsVarying[5], iInputPositionVarying, phaseAndAmplitudeVarying.x);" "vec2 quadrature = vec2(cos(phaseAndAmplitudeVarying.x), -sin(phaseAndAmplitudeVarying.x));" - "fragColour = vec3(luminance, vec2(0.5) + (chrominance * quadrature));" + "fragColour = vec3(sample.x, vec2(0.5) + (sample.y * quadrature));" "}"; return make_shader(fragment_shader.str(), true, true);