1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Of course, being in-phase means being the cosine wave.

This commit is contained in:
Thomas Harte 2015-09-10 21:30:39 -04:00 committed by Thomas Harte
parent 82aa6d074a
commit 5d6bee4927
2 changed files with 6 additions and 6 deletions

View File

@ -158,7 +158,7 @@ const char *Machine::get_signal_decoder()
"vec2 c = texture(texID, coordinate).rg;"
"float y = 0.1 + c.x * 0.91071428571429;\n"
"float aOffset = 6.283185308 * (c.y - 3.0 / 16.0) * 1.14285714285714;\n"
"return y + step(0.03125, c.y) * 0.1 * sin(phase + aOffset);\n"
"return y + step(0.03125, c.y) * 0.1 * cos(phase - aOffset);\n"
"}";
}

View File

@ -110,8 +110,8 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
// NSOpenGLPFASampleBuffers, 1,
// NSOpenGLPFASamples, 2,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 2,
0
};
@ -246,12 +246,12 @@ static NSString *const fragmentShader =
"samples[0] -= vec4(y);\n"
"samples[1] -= vec4(y);\n"
"\n"
"float i = dot(vec4(0.0, sin(angles[0].y), sin(angles[0].z), sin(angles[0].w)), samples[0]) + dot(vec4(sin(angles[1].x), sin(angles[1].y), 0.0, 0.0), samples[1]);\n"
"float q = dot(vec4(0.0, cos(angles[0].y), cos(angles[0].z), cos(angles[0].w)), samples[0]) + dot(vec4(cos(angles[1].x), cos(angles[1].y), 0.0, 0.0), samples[1]);\n"
"float i = dot(vec4(0.0, cos(angles[0].y), cos(angles[0].z), cos(angles[0].w)), samples[0]) + dot(vec4(cos(angles[1].x), cos(angles[1].y), 0.0, 0.0), samples[1]);\n"
"float q = dot(vec4(0.0, sin(angles[0].y), sin(angles[0].z), sin(angles[0].w)), samples[0]) + dot(vec4(sin(angles[1].x), sin(angles[1].y), 0.0, 0.0), samples[1]);\n"
"\n"
"// now i and q are in the range [-0.5, 0.5], so i needs to be multiplied by 1.1914 and q by 1.0452\n"
"const mat3 yiqToRGB = mat3(1.0, 1.0, 1.0, 1.1389784, -0.3240608, -1.3176884, 0.6490692, -0.6762444, 1.7799756);\n"
"fragColour = vec4( yiqToRGB * vec3(y, i, q), 1.0);\n"
"fragColour = vec4( yiqToRGB * vec3(y, i, q), sin(lateralVarying));\n"
"}\n";
#if defined(DEBUG)