post-processing-fx.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <!--
  3. FurMark's post processing effect.
  4. See at Geeks3D.com for a complete tutorial on how to code an effect for FurMark.
  5. Tags (for searching on Geeks3D.com): furmark post-processing effect
  6. -->
  7. <furmark>
  8. <post_processing>
  9. <texture filename="" uniform_sampler_name="fxTexture1" />
  10. <vertex_shader>
  11. <raw_data><![CDATA[
  12. void main()
  13. {
  14. gl_TexCoord[0] = gl_MultiTexCoord0;
  15. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  16. gl_Position = ftransform();
  17. }
  18. ]]></raw_data>
  19. </vertex_shader>
  20. <!--
  21. <pixel_shader>
  22. <raw_data><![CDATA[
  23. uniform sampler2D sceneBuffer;
  24. uniform float elapsedTime;
  25. uniform int sceneWidth;
  26. uniform int sceneHeight;
  27. uniform sampler2D fxTexture1;
  28. void main ()
  29. {
  30. //vec4 textureColor = texture2D(fxTexture1, gl_TexCoord[0].st);
  31. vec4 sceneColor = texture2D(sceneBuffer, gl_TexCoord[0].st);
  32. vec4 tex1Color = texture2D(fxTexture1, gl_TexCoord[0].st);
  33. sceneColor.r += texture2D(sceneBuffer, gl_TexCoord[0].st - 0.009*cos(elapsedTime*2.0)).r;
  34. sceneColor.g += texture2D(sceneBuffer, gl_TexCoord[0].st + 0.009*cos(elapsedTime*1.2)).g;
  35. sceneColor.b += texture2D(sceneBuffer, gl_TexCoord[0].st + 0.009*sin(elapsedTime*4.0)).b;
  36. sceneColor.rgb *= 0.5;
  37. gl_FragColor = sceneColor + tex1Color;
  38. }
  39. ]]></raw_data>
  40. </pixel_shader>
  41. -->
  42. <!--
  43. <pixel_shader>
  44. <raw_data><![CDATA[
  45. uniform sampler2D sceneBuffer;
  46. uniform float elapsedTime;
  47. uniform int sceneWidth;
  48. uniform int sceneHeight;
  49. //uniform sampler2D fxTexture1;
  50. const float saturation = 0.6;
  51. const float pi = 3.1415926535897932;
  52. const float offmul = 0.008;
  53. const float tcmul = 4.0;
  54. float noise(float x)
  55. {
  56. return (cos(x*pi)*cos(x*pi))*cos(x*3.0*pi)*cos(x*5.0*pi)*0.5+sin(x*25.0*pi)*0.02*saturation;
  57. }
  58. void main ()
  59. {
  60. float t = elapsedTime;
  61. float rt=0.014, gt=0.008, bt=0.010;
  62. float ro=0.018, go=0.006, bo=-0.026;
  63. vec2 tc = gl_TexCoord[0].xy;
  64. vec2 tcr = vec2(tc.x+ro+offmul*noise(rt+tc.y*tcmul+noise(t*pi+tc.y)), tc.y);
  65. vec2 tcg = vec2(tc.x+go+offmul*noise(gt+tc.y*tcmul+noise(t*pi+tc.y)), tc.y);
  66. vec2 tcb = vec2(tc.x+bo+offmul*noise(bt+tc.y*tcmul+noise(t*pi+tc.y)), tc.y);
  67. float r = texture2D(sceneBuffer, tcr).r;
  68. float g = texture2D(sceneBuffer, tcg).g;
  69. float b = texture2D(sceneBuffer, tcb).b;
  70. // N
  71. float gr = (r+g+b)*0.5;
  72. float fd = saturation;
  73. gr = gr*0.25+0.75*gr*gr;
  74. r = r*fd + gr*(1-fd);
  75. g = g*fd + gr*(1-fd);
  76. b = b*fd + gr*(1-fd);
  77. // N
  78. gl_FragColor = vec4(r, g, b, 1.0);
  79. }
  80. ]]></raw_data>
  81. </pixel_shader>
  82. -->
  83. <pixel_shader>
  84. <raw_data><![CDATA[
  85. uniform sampler2D sceneBuffer;
  86. uniform float elapsedTime;
  87. uniform int sceneWidth;
  88. uniform int sceneHeight;
  89. //uniform sampler2D fxTexture1;
  90. void main(void)
  91. {
  92. vec2 pixels[13];
  93. pixels[0] = vec2( -6, -6 );
  94. pixels[1] = vec2( -5, -5 );
  95. pixels[2] = vec2( -4, -4 );
  96. pixels[3] = vec2( -3, -3 );
  97. pixels[4] = vec2( -2, -2 );
  98. pixels[5] = vec2( -1, -1 );
  99. pixels[6] = vec2( 0, 0 );
  100. pixels[7] = vec2( 1, 1 );
  101. pixels[8] = vec2( 2, 2 );
  102. pixels[9] = vec2( 3, 3 );
  103. pixels[10] = vec2( 4, 4 );
  104. pixels[11] = vec2( 5, 5 );
  105. pixels[12] = vec2( 6, 6 );
  106. float weights[13];
  107. weights[0] = 0.002216;
  108. weights[1] = 0.008764,
  109. weights[2] = 0.026995;
  110. weights[3] = 0.064759;
  111. weights[4] = 0.120985;
  112. weights[5] = 0.176033;
  113. weights[6] = 0.199471;
  114. weights[7] = 0.176033;
  115. weights[8] = 0.120985;
  116. weights[9] = 0.064759;
  117. weights[10] = 0.026995;
  118. weights[11] = 0.008764;
  119. weights[12] = 0.002216;
  120. vec2 radius = vec2(0.002, 0.002);
  121. float bias = 0.05;
  122. float scale = 0.9;
  123. vec2 texcoord = gl_TexCoord[0].xy;
  124. vec4 col = vec4(0.0);
  125. for (int i=0; i<13; i++)
  126. {
  127. col += texture2D(sceneBuffer, texcoord+pixels[i]*radius)*weights[i];
  128. }
  129. col = clamp((col + bias) * scale, 0.0, 1.0);
  130. gl_FragColor = col;
  131. }
  132. ]]></raw_data>
  133. </pixel_shader>
  134. </post_processing>
  135. </furmark>