Created
June 14, 2013 02:44
-
-
Save kazukitanaka0611/5779123 to your computer and use it in GitHub Desktop.
pink halfton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)getFragmentShaderString | |
{ | |
NSString *const kFragmentShaderString = SHADER_STRING | |
( | |
varying highp vec2 textureCoordinate; | |
uniform sampler2D inputImageTexture; | |
uniform highp float fractionalWidthOfPixel; | |
uniform highp float aspectRatio; | |
uniform highp float dotScaling; | |
const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); | |
void main() | |
{ | |
highp vec2 sampleDivisor = vec2(fractionalWidthOfPixel, fractionalWidthOfPixel / aspectRatio); | |
highp vec2 samplePos = textureCoordinate - mod(textureCoordinate, sampleDivisor) + 0.5 * sampleDivisor; | |
highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio)); | |
highp vec2 adjustedSamplePos = vec2(samplePos.x, (samplePos.y * aspectRatio + 0.5 - 0.5 * aspectRatio)); | |
highp float distanceFromSamplePoint = distance(adjustedSamplePos, textureCoordinateToUse); | |
lowp float checkForPresenceWithinDot = step(distanceFromSamplePoint, (fractionalWidthOfPixel * 0.5) * dotScaling); | |
highp vec3 dispColor = vec4(texture2D(inputImageTexture, samplePos ).rgb * checkForPresenceWithinDot, 1.0).rgb; | |
highp float gray = step(0.45,dot(dispColor, W)); | |
lowp vec4 colorToDisplay = vec4(1.0, 1.0, 1.0, 1.0); | |
if (gray < 1.00) | |
{ | |
colorToDisplay = vec4(0.58, 0.00, 0.83, 1.0); | |
} | |
highp float gray2 = step(0.25,dot(dispColor, W)); | |
if (gray2 < 1.00) | |
{ | |
colorToDisplay = vec4(1.00, 0.41, 0.71, 1.0); | |
} | |
gl_FragColor = colorToDisplay; | |
} | |
); | |
return kFragmentShaderString; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment