1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-28 07:29:45 +00:00

Merge pull request #140 from TomHarte/ColourSuppression

Causes the CRT to react properly to absence of a colour burst
This commit is contained in:
Thomas Harte 2017-07-06 21:42:02 -04:00 committed by GitHub
commit a5359027f0
2 changed files with 11 additions and 9 deletions

View File

@ -113,7 +113,7 @@ Flywheel::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested,
#define source_output_position_y() (*(uint16_t *)&next_run[SourceVertexOffsetOfOutputStart + 2])
#define source_output_position_x2() (*(uint16_t *)&next_run[SourceVertexOffsetOfEnds + 2])
#define source_phase() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 0]
#define source_amplitude() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 2]
#define source_amplitude() next_run[SourceVertexOffsetOfPhaseTimeAndAmplitude + 1]
void CRT::advance_cycles(unsigned int number_of_cycles, bool hsync_requested, bool vsync_requested, const Scan::Type type) {
std::unique_lock<std::mutex> output_lock = openGL_output_builder_.get_output_lock();

View File

@ -47,7 +47,7 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_shader(const std::s
"uniform float outputVerticalOffset;"
"uniform float textureHeightDivisor;"
"out vec2 phaseAndAmplitudeVarying;"
"out vec3 phaseAndAmplitudeVarying;"
"out vec2 inputPositionsVarying[11];"
"out vec2 iInputPositionVarying;"
"out vec2 delayLinePositionVarying;"
@ -94,9 +94,11 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_shader(const std::s
"delayLinePositionVarying = mappedInputPosition - vec2(0.0, 1.0);"
// setup phaseAndAmplitudeVarying.x as colour burst subcarrier phase, in radians;
// setup phaseAndAmplitudeVarying.x as colour burst amplitude
// setup phaseAndAmplitudeVarying.y as colour burst amplitude;
// setup phaseAndAmplitudeVarying.z as 1 / (colour burst amplitude), or 0.0 if amplitude is 0.0;
"phaseAndAmplitudeVarying.x = (extendedOutputPosition.x + (phaseTimeAndAmplitude.x / 64.0)) * 0.5 * 3.141592654;"
"phaseAndAmplitudeVarying.y = 0.33;" // TODO: reinstate connection with (phaseTimeAndAmplitude.y/256.0)
"phaseAndAmplitudeVarying.y = phaseTimeAndAmplitude.y / 255.0;"
"phaseAndAmplitudeVarying.z = (phaseAndAmplitudeVarying.y > 0.0) ? 1.0 / phaseAndAmplitudeVarying.y : 0.0;"
// determine output position by scaling the output position according to the texture size
"vec2 eyePosition = 2.0*(extendedOutputPosition / outputTextureSize) - vec2(1.0);"
@ -133,7 +135,7 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_source_conversion_s
"in vec2 inputPositionsVarying[11];"
"in vec2 iInputPositionVarying;"
"in vec2 phaseAndAmplitudeVarying;"
"in vec3 phaseAndAmplitudeVarying;"
"out vec4 fragColour;"
@ -161,7 +163,7 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_rgb_source_shader(c
"in vec2 inputPositionsVarying[11];"
"in vec2 iInputPositionVarying;"
"in vec2 phaseAndAmplitudeVarying;"
"in vec3 phaseAndAmplitudeVarying;"
"out vec3 fragColour;"
@ -185,7 +187,7 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_chroma_luma_separat
return make_shader(
"#version 150\n"
"in vec2 phaseAndAmplitudeVarying;"
"in vec3 phaseAndAmplitudeVarying;"
"in vec2 inputPositionsVarying[11];"
"out vec3 fragColour;"
@ -200,10 +202,10 @@ std::unique_ptr<IntermediateShader> IntermediateShader::make_chroma_luma_separat
"texture(texID, inputPositionsVarying[5]).r,"
"texture(texID, inputPositionsVarying[6]).r"
");"
"float luminance = dot(samples, vec4(0.25));"
"float luminance = mix(dot(samples, vec4(0.25)), dot(samples, vec4(0.0, 0.16, 0.66, 0.16)), step(phaseAndAmplitudeVarying.z, 0.0));"
// define chroma to be whatever was here, minus luma
"float chrominance = 0.5 * (samples.z - luminance) / phaseAndAmplitudeVarying.y;"
"float chrominance = 0.5 * (samples.z - luminance) * phaseAndAmplitudeVarying.z;"
"luminance /= (1.0 - phaseAndAmplitudeVarying.y);"
// split choma colours here, as the most direct place, writing out