Guest User

Untitled

a guest
Aug 12th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #ifndef OVR_SHADER
  2. #define OVR_SHADER
  3.  
  4. // Vertex Shader
  5. static const char* vertexShader =
  6. "#version 110\n"
  7.  
  8. "uniform vec2 EyeToSourceUVScale;\n"
  9. "uniform vec2 EyeToSourceUVOffset;\n"
  10.  
  11. "attribute vec4 Position;\n"
  12. //"attribute vec4 Color;\n"
  13. // Vignette Fade and TimeWarpFactor encoded into Pos.z and Pos.w
  14. "attribute vec2 TexCoord0;\n"
  15. "attribute vec2 TexCoord1;\n"
  16. "attribute vec2 TexCoord2;\n"
  17.  
  18. "varying vec4 oColor; \n"
  19. "varying vec2 oTexCoord0;\n"
  20. "varying vec2 oTexCoord1;\n"
  21. "varying vec2 oTexCoord2;\n"
  22.  
  23. "void main() {\n"
  24.  
  25. " gl_Position.x = Position.x;\n"
  26. " gl_Position.y = Position.y;\n"
  27. " gl_Position.z = 0.5;\n"
  28. " gl_Position.w = 1.0;\n"
  29.  
  30. // Vertex inputs are in TanEyeAngle space for the R,G,B channels
  31. // (i.e. after chromatic aberration and distortion).
  32. // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
  33. " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
  34. " oTexCoord0.y = 1.0-oTexCoord0.y;\n"
  35. " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
  36. " oTexCoord1.y = 1.0-oTexCoord1.y;\n"
  37. " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
  38. " oTexCoord2.y = 1.0-oTexCoord2.y;\n"
  39.  
  40. " oColor = vec4(Position.w, Position.w, Position.w, Position.z);\n" // Used for VignetteFade.
  41. "}\n";
  42.  
  43. // Fragment Shader
  44. static const char* fragmentShader =
  45. "#version 110 \n"
  46.  
  47. "uniform sampler2D Texture;\n"
  48.  
  49. "varying vec4 oColor;\n"
  50. "varying vec2 oTexCoord0;\n"
  51. "varying vec2 oTexCoord1;\n"
  52. "varying vec2 oTexCoord2;\n"
  53.  
  54. "void main() {\n"
  55.  
  56. //"gl_FragColor = oColor * texture2D(Texture, oTexCoord1);\n"
  57. " gl_FragColor.r = oColor.r * texture2D(Texture, oTexCoord0).r;\n"
  58. " gl_FragColor.g = oColor.g * texture2D(Texture, oTexCoord1).g;\n"
  59. " gl_FragColor.b = oColor.b * texture2D(Texture, oTexCoord2).b;\n"
  60. " gl_FragColor.a = 1.0;\n"
  61. "}\n";
  62.  
  63. #endif /* OVR_SHADER */
Advertisement
Add Comment
Please, Sign In to add comment