Go to content Go to navigation

Mayan with GLSL · 2009-12-09 00:00 by Black in

The first test implementation of Mayan was a Photoshop file containing the picture in various states of desaturation and blending. The second implementation was a direct show filter for the group’s stereo movie player. The third and latest implementation is an OpenGL Shading Language shader for ExaminationRoom.

ExaminationRoom was extended to support shader assisted merging of the two viewpoints. This was done by rendering both the left and the right camera’s view to FramebufferObjects, which then get drawn while the given Fragment Shader is active. The shader can calculate how to modify each sides’ fragments. The blend func is GL_ONE during this time, so no further modification is performed.

mayan.fs [526.00 B]

  1. uniform sampler2D tex;
  2. uniform float side;
  4. // Factor that determines how much of the other
  5. // colors is mixed into the primary channel of that
  6. // side. This is the same lambda as in the mayan paper.
  7. uniform float lambda;
  9. void main()
  10. {
  11.   float facR = 1.0-side;
  12.   float facG = side;
  13.   float mixFactor = (1.0-lambda)*0.5;
  15.   vec4 c = texture2D(tex, gl_TexCoord[0].xy);
  16.   gl_FragColor = vec4(
  17.     facR*(c.r*lambda + (c.g+c.b)*mixFactor), // Red
  18.     facG*(c.g*lambda + (c.r+c.b)*mixFactor), // Green
  19.     c.b*0.5, // Blue
  20.     0.5); // Alpha
  21. }

Fragment shaders get a uniform variable that defines which side the currently drawn texture is on. Lambda is a factor that influences the desaturation of the colors for better 3D impression.

Using shaders for mixing allows for maximal adaptability with hardware accelerated speed. Unlike the original Anaglyph renderer it can mix different colors and is able to handle shared channels like Mayan’s blue.

  Textile help