1
0

__shdBulbNormal.fsh 1.0 KB

123456789101112131415161718192021222324252627282930
  1. varying vec2 v_vTexcoord;
  2. varying vec4 v_vColour;
  3. uniform float u_fAlphaThreshold;
  4. uniform float u_fDisable;
  5. const float twoPi = 2.0*3.14159265;
  6. const float conversion = twoPi / (257.0 + (1.0 / 63.0));
  7. void main()
  8. {
  9. gl_FragColor = texture2D(gm_BaseTexture, v_vTexcoord);
  10. if (gl_FragColor.a < u_fAlphaThreshold) discard;
  11. gl_FragColor.a = 1.0;
  12. gl_FragColor.rgb = 2.0*gl_FragColor.rgb - 1.0;
  13. //Use the least significant bits in the red channel for the
  14. float xFlip = mod(v_vColour.r*255.0, 2.0);
  15. float yFlip = mod((v_vColour.r*255.0 - xFlip) / 2.0, 2.0);
  16. //Technically we should remove the least significant bits (the x flip and y flip bits)
  17. //Ultimately, it doesn't change the outcome much
  18. float angle = dot(v_vColour.rgb, conversion*vec3(1.0/63.0, 1.0, 256.0));
  19. float sine = sin(angle);
  20. float cosine = cos(angle);
  21. mat2 matrix = mat2(cosine, -sine, sine, cosine)*(mat2(1.0 - 2.0*xFlip, 0.0, 0.0, 1.0 - 2.0*yFlip));
  22. gl_FragColor.rg = 0.5 + 0.5*(matrix*gl_FragColor.rg);
  23. }