您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

gradient.lolfx 3.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. [vert.glsl]
  2. #version 130
  3. attribute vec3 in_Vertex;
  4. attribute vec4 in_Color;
  5. varying vec4 pass_Color;
  6. uniform mat4 proj_matrix;
  7. uniform mat4 view_matrix;
  8. uniform mat4 model_matrix;
  9. void main()
  10. {
  11. gl_Position = proj_matrix * view_matrix * model_matrix
  12. * vec4(in_Vertex, 1.0);
  13. pass_Color = in_Color;
  14. }
  15. [frag.glsl]
  16. #version 130
  17. #if defined GL_ES
  18. precision highp float;
  19. #endif
  20. varying vec4 pass_Color;
  21. mat4 bayer = mat4( 0.0, 12.0, 3.0, 15.0,
  22. 8.0, 4.0, 11.0, 7.0,
  23. 2.0, 14.0, 1.0, 13.0,
  24. 10.0, 6.0, 9.0, 5.0);
  25. mat4 cluster = mat4(12.0, 5.0, 6.0, 13.0,
  26. 4.0, 0.0, 1.0, 7.0,
  27. 11.0, 3.0, 2.0, 8.0,
  28. 15.0, 10.0, 9.0, 14.0);
  29. float rand(vec2 p)
  30. {
  31. return fract(sin(dot(p, vec2(12.9898, 78.2333))) * 123.4567);
  32. }
  33. void main()
  34. {
  35. vec4 col = pass_Color;
  36. #if defined GL_ES
  37. int dx = int(mod(gl_FragCoord.x, 4.0));
  38. int dy = int(mod(gl_FragCoord.y, 4.0));
  39. float t;
  40. if (dx == 0)
  41. {
  42. if (dy == 0) t = cluster[0][0]; else if (dy == 1) t = cluster[0][1]; else if (dy == 2) t = cluster[0][2]; else t = cluster[0][3];
  43. }
  44. else if (dx == 1)
  45. {
  46. if (dy == 0) t = cluster[1][0]; else if (dy == 1) t = cluster[1][1]; else if (dy == 2) t = cluster[1][2]; else t = cluster[1][3];
  47. }
  48. else if (dx == 2)
  49. {
  50. if (dy == 0) t = cluster[2][0]; else if (dy == 1) t = cluster[2][1]; else if (dy == 2) t = cluster[2][2]; else t = cluster[2][3];
  51. }
  52. else
  53. {
  54. if (dy == 0) t = cluster[3][0]; else if (dy == 1) t = cluster[3][1]; else if (dy == 2) t = cluster[3][2]; else t = cluster[3][3];
  55. }
  56. #else
  57. float t = cluster[int(mod(gl_FragCoord.x, 4.0))]
  58. [int(mod(gl_FragCoord.y, 4.0))];
  59. #endif
  60. t += rand(gl_FragCoord.xy) - 0.5;
  61. t = (t + 0.5) / 17.0;
  62. col.x += fract(t - col.x) - t;
  63. col.y += fract(t - col.y) - t;
  64. col.z += fract(t - col.z) - t;
  65. gl_FragColor = col;
  66. }
  67. [vert.hlsl]
  68. void main(float4 in_Vertex : POSITION,
  69. float4 in_Color : COLOR,
  70. uniform float4x4 proj_matrix,
  71. uniform float4x4 view_matrix,
  72. uniform float4x4 model_matrix,
  73. out float4 out_Color : COLOR,
  74. out float4 out_Position : POSITION)
  75. {
  76. out_Position = mul(proj_matrix, mul(view_matrix, mul(model_matrix, in_Vertex)));
  77. out_Color = in_Color;
  78. }
  79. [frag.hlsl]
  80. float4x4 bayer = float4x4( 0.0, 12.0, 3.0, 15.0,
  81. 8.0, 4.0, 11.0, 7.0,
  82. 2.0, 14.0, 1.0, 13.0,
  83. 10.0, 6.0, 9.0, 5.0);
  84. #if 1
  85. float4x4 cluster = float4x4(12.0, 5.0, 6.0, 13.0,
  86. 4.0, 0.0, 1.0, 7.0,
  87. 11.0, 3.0, 2.0, 8.0,
  88. 15.0, 10.0, 9.0, 14.0);
  89. #endif
  90. void main(float4 in_Color : COLOR,
  91. float4 in_FragCoord : WPOS,
  92. out float4 out_FragColor : COLOR)
  93. {
  94. float4 col = in_Color;
  95. #if 1
  96. int x = (int)in_FragCoord.x;
  97. int y = (int)in_FragCoord.y;
  98. // FIXME: we cannot address this matrix directly on the PS3
  99. float t = bayer[int(frac(x * 0.25) * 4.0)]
  100. [int(frac(y * 0.25) * 4.0)];
  101. t = (t + 0.5) / 17.0;
  102. col.x += frac(t - col.x) - t;
  103. col.y += frac(t - col.y) - t;
  104. col.z += frac(t - col.z) - t;
  105. #endif
  106. out_FragColor = col;
  107. }