mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-26 09:29:45 +00:00
Switched down to four samples per pixel, just more than half as many, to fit into a vec4. Edges aren't as smooth but I'm wondering whether it'll make much odds when I implement a shadow mask.
This commit is contained in:
parent
5d6bee4927
commit
63b648be65
@ -183,7 +183,7 @@ static NSString *const vertexShader =
|
||||
"in vec2 srcCoordinates;\n"
|
||||
"in float lateral;\n"
|
||||
"\n"
|
||||
"out vec2 srcCoordinatesVarying[7];\n"
|
||||
"out vec2 srcCoordinatesVarying[4];\n"
|
||||
"out float lateralVarying;\n"
|
||||
"out float phase;\n"
|
||||
"\n"
|
||||
@ -191,15 +191,11 @@ static NSString *const vertexShader =
|
||||
"\n"
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
"srcCoordinatesVarying[3] = vec2(srcCoordinates.x / textureSize.x, (srcCoordinates.y + 0.5) / textureSize.y);\n"
|
||||
"\n"
|
||||
"srcCoordinatesVarying[0] = srcCoordinatesVarying[3] - vec2(0.4 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[1] = srcCoordinatesVarying[3] - vec2(0.2 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[2] = srcCoordinatesVarying[3] - vec2(0.1 / textureSize.x, 0.0);\n"
|
||||
"\n"
|
||||
"srcCoordinatesVarying[4] = srcCoordinatesVarying[3] + vec2(0.1 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[5] = srcCoordinatesVarying[3] + vec2(0.2 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[6] = srcCoordinatesVarying[3] + vec2(0.4 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[0] = vec2(srcCoordinates.x / textureSize.x, (srcCoordinates.y + 0.5) / textureSize.y);\n"
|
||||
"srcCoordinatesVarying[3] = srcCoordinatesVarying[0] + vec2(0.375 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[2] = srcCoordinatesVarying[0] + vec2(0.125 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[1] = srcCoordinatesVarying[0] - vec2(0.125 / textureSize.x, 0.0);\n"
|
||||
"srcCoordinatesVarying[0] = srcCoordinatesVarying[0] - vec2(0.325 / textureSize.x, 0.0);\n"
|
||||
"\n"
|
||||
"lateralVarying = lateral + 1.0707963267949;\n"
|
||||
"phase = srcCoordinates.x * 6.283185308;\n"
|
||||
@ -212,7 +208,7 @@ static NSString *const vertexShader =
|
||||
static NSString *const fragmentShader =
|
||||
@"#version 150\n"
|
||||
"\n"
|
||||
"in vec2 srcCoordinatesVarying[7];\n"
|
||||
"in vec2 srcCoordinatesVarying[4];\n"
|
||||
"in float lateralVarying;\n"
|
||||
"in float phase;\n"
|
||||
"out vec4 fragColour;\n"
|
||||
@ -224,34 +220,23 @@ static NSString *const fragmentShader =
|
||||
"\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
"vec4 samples[2];\n"
|
||||
"vec4 angles[2];\n"
|
||||
"vec4 angles = vec4(phase) + vec4(-2.35619449019234, -0.78539816339745, 0.78539816339745, 2.35619449019234);\n"
|
||||
"vec4 samples = vec4("
|
||||
" sample(srcCoordinatesVarying[0], angles.x),"
|
||||
" sample(srcCoordinatesVarying[1], angles.y),"
|
||||
" sample(srcCoordinatesVarying[2], angles.z),"
|
||||
" sample(srcCoordinatesVarying[3], angles.w)"
|
||||
");\n"
|
||||
"\n"
|
||||
"vec4 angle = vec4(phase);\n"
|
||||
"angles[0] = angle + vec4(-2.5132741232, -1.2566370616, -0.6283185308, 0.0);\n"
|
||||
"angles[1] = angle + vec4(0.6283185308, 1.2566370616, 2.5132741232, 0.0);\n"
|
||||
"float y = dot(vec4(0.25), samples);\n"
|
||||
"samples -= vec4(y);\n"
|
||||
"\n"
|
||||
"samples[0] = vec4("
|
||||
" sample(srcCoordinatesVarying[0], angles[0].x),"
|
||||
" sample(srcCoordinatesVarying[1], angles[0].y),"
|
||||
" sample(srcCoordinatesVarying[2], angles[0].z),"
|
||||
" sample(srcCoordinatesVarying[3], angles[0].w));\n"
|
||||
"samples[1] = vec4("
|
||||
" sample(srcCoordinatesVarying[4], angles[1].x),"
|
||||
" sample(srcCoordinatesVarying[5], angles[1].y),"
|
||||
" sample(srcCoordinatesVarying[6], angles[1].z),"
|
||||
" 0.0);\n"
|
||||
"float y = dot(vec4(0.2, 0.2, 0.0, 0.2), samples[0]) + dot(vec4(0.0, 0.2, 0.2, 0.0), samples[1]);\n"
|
||||
"\n"
|
||||
"samples[0] -= vec4(y);\n"
|
||||
"samples[1] -= vec4(y);\n"
|
||||
"\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"
|
||||
"float i = dot(cos(angles), samples);\n"
|
||||
"float q = dot(sin(angles), samples);\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), sin(lateralVarying));\n"
|
||||
"fragColour = vec4( yiqToRGB * vec3(y, i, q), 1.0);//sin(lateralVarying));\n"
|
||||
"}\n";
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
Loading…
Reference in New Issue
Block a user