Matrix Greenish Color Formula Demo


GeeXLab - Matrix greenish color shader



Downloads

How to run the demo?
Download and unzip GeeXLab and the demopack where you want, launch GeeXLab and drop the demo (main.xml) in GeeXLab. This demo requires OpenGL 2.1+.

 
In the following tweet, iq gives the formula that creates the greenish ambiance of the Matrix movie:

 
I coded this small demo that allows you to play with the color exponents:

GeeXLab - Matrix greenish color shader

 
The pixel shader:

#version 120  
uniform sampler2D tex0;
uniform vec4 exponents; // vec4(1.5, 0.8, 1.5, 0.0)
 
float separator(float mouse_x, float vseparator_width, float uv_x)
{
  float separator_posx = mouse_x;
  float a1 = smoothstep(separator_posx - vseparator_width, separator_posx, uv_x);
  float a2 = smoothstep(separator_posx + vseparator_width, separator_posx, uv_x);
  return 1.0- a1*a2;
}
 
void main(void)
{
  vec2 uv = gl_TexCoord[0].xy;
  uv.y *= -1.0;
 
  vec4 color = texture2D(tex0, uv * vec2(2.0, 1.0));
 
  if (uv.x>0.5)
    color.rgb = pow(color.rgb, exponents.rgb);
 
  float sep = separator(0.5, 0.01, uv.x);
  gl_FragColor = color * sep;
}




Leave a Comment

Your email address will not be published. Required fields are marked *