Advertisement
KoctrX

Untitled

Oct 1st, 2021
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. '#version 300 es\nprecision mediump float;\n\nuniform sampler2D colorSampler;\nuniform int bufferChannel; // 0=Y, 1=U, 2=V\nin vec2 texCoords;\nout float outColor;\n\nvec4 unmultAlpha(vec4 color) {\n if (color.a == 0.) return vec4(0.);\n return vec4(color.rgb / color.a, color.a);\n}\n\nvoid main() {\n vec2 flippedCoords = vec2(texCoords.x, 1. - texCoords.y);\n vec4 color = unmultAlpha(texture(colorSampler, flippedCoords));\n\n // See http://avisynth.nl/index.php/Color_conversions\n // BT.601 = vec3(0.299, 0.587, 0.114)\n // BT.709 = vec3(0.2126, 0.7152, 0.0722)\n vec3 coef = vec3(0.2126, 0.7152, 0.0722);\n\n float y = dot(color.rgb, coef);\n float u = (color.b - y) / (1. - coef.b);\n float v = (color.r - y) / (1. - coef.r);\n\n if (bufferChannel == 0) {\n outColor = mix(16./255., 236./255., y);\n } else if (bufferChannel == 1) {\n outColor = mix(16./255., 240./255., u * 0.5 + 0.5);\n } else if (bufferChannel == 2) {\n outColor = mix(16./255., 240./255., v * 0.5 + 0.5);\n }\n}\n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement