Skip to content

Instantly share code, notes, and snippets.

@CaptainGPU
Created December 2, 2023 11:28
Show Gist options
  • Save CaptainGPU/8987188f70eb9c4932f30df017147d1c to your computer and use it in GitHub Desktop.
Save CaptainGPU/8987188f70eb9c4932f30df017147d1c to your computer and use it in GitHub Desktop.
Matrix.glsl
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_texture_0;
uniform vec2 u_resolution;
uniform float u_time;
void main()
{
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
uv.y *= 2.;
bool useMatrixFilter = false;
if (uv.y > 1.) // Фікс ClampToEdge семплера glslCanvas
{
useMatrixFilter = true;
uv.y -= 1.;
}
// Вибираємо колір з оригінальної текстури
vec3 color = texture2D(u_texture_0, uv).rgb;
if (useMatrixFilter)
{
// Ступені каналів RGB
float greenPow = 4. / 5.;
float otherPow = 3. / 2.;
// Трансформуємо RGB в кольоровий простір Матриці
color.r = pow(color.r, otherPow);
color.g = pow(color.g, greenPow);
color.b = pow(color.b, otherPow);
}
gl_FragColor = vec4(color, 1.);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment