daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jul 21st, 2015 269 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct __sampler2D
  2.  
  3. {
  4.         sampler2D s;
  5.         float2 pixelsize;
  6. }
  7.  
  8. ;
  9. float4 __tex2Dgather0(__sampler2D s, float2 c)
  10. {
  11.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).r, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).r, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).r, tex2Dlod(s.s, float4(c, 0, 0)).r);
  12. }
  13.  
  14. float4 __tex2Dgather1(__sampler2D s, float2 c)
  15. {
  16.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).g, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).g, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).g, tex2Dlod(s.s, float4(c, 0, 0)).g);
  17. }
  18.  
  19. float4 __tex2Dgather2(__sampler2D s, float2 c)
  20. {
  21.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).b, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).b, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).b, tex2Dlod(s.s, float4(c, 0, 0)).b);
  22. }
  23.  
  24. float4 __tex2Dgather3(__sampler2D s, float2 c)
  25. {
  26.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).a, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).a, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).a, tex2Dlod(s.s, float4(c, 0, 0)).a);
  27. }
  28.  
  29. float4 __tex2Dgather0offset(__sampler2D s, float2 c, int2 offset)
  30. {
  31.         return __tex2Dgather0(s, c + offset * s.pixelsize);
  32. }
  33.  
  34. float4 __tex2Dgather1offset(__sampler2D s, float2 c, int2 offset)
  35. {
  36.         return __tex2Dgather1(s, c + offset * s.pixelsize);
  37. }
  38.  
  39. float4 __tex2Dgather2offset(__sampler2D s, float2 c, int2 offset)
  40. {
  41.         return __tex2Dgather2(s, c + offset * s.pixelsize);
  42. }
  43.  
  44. float4 __tex2Dgather3offset(__sampler2D s, float2 c, int2 offset)
  45. {
  46.         return __tex2Dgather3(s, c + offset * s.pixelsize);
  47. }
  48.  
  49. float4 __tex2Dlodoffset(__sampler2D s, float4 c, int2 offset)
  50. {
  51.         return tex2Dlod(s.s, c + float4(offset * s.pixelsize, 0, 0));
  52. }
  53.  
  54. float4 __tex2Doffset(__sampler2D s, float2 c, int2 offset)
  55. {
  56.         return tex2D(s.s, c + offset * s.pixelsize);
  57. }
  58.  
  59. int2 __tex2Dsize(__sampler2D s, int lod)
  60. {
  61.         return int2(1 / s.pixelsize) / exp2(lod);
  62. }
  63. uniform float2 __TEXEL_SIZE__
  64.  
  65. :
  66. register(c255);
  67. uniform float _NSRFX_timer
  68.  
  69. :
  70. register(c0);
  71. uniform float _NSRFX_timeleft
  72.  
  73. :
  74. register(c1);
  75. uniform float _NSRFX_frametime
  76.  
  77. :
  78. register(c2);
  79. static const float _NSCFX_NSpermTexUnit = 0.003906f;
  80. static const float _NSCFX_NSpermTexUnitHalf = 0.001953f;
  81. uniform float _NSCFX_NSwidth
  82.  
  83. :
  84. register(c3);
  85. uniform float _NSCFX_NSheight
  86.  
  87. :
  88. register(c4);
  89. uniform float _NSCFX_NStimer
  90.  
  91. :
  92. register(c5);
  93. static const float _NSCFX_NSgrainamount = 0.050000f;
  94. uniform float _NSCFX_NScolored
  95.  
  96. :
  97. register(c6);
  98. uniform float _NSCFX_NScoloramount
  99.  
  100. :
  101. register(c7);
  102. uniform float _NSCFX_NSgrainsize
  103.  
  104. :
  105. register(c8);
  106. uniform float _NSCFX_NSlumamount
  107.  
  108. :
  109. register(c9);
  110.  
  111. void _NSRFX_VS_PostProcess(in uint id, out float4 pos, out float2 texcoord)
  112. {
  113.         (texcoord.x = ((id == 2) ? 2.000000f : 0.000000f));
  114.         (texcoord.y = ((id == 1) ? 2.000000f : 0.000000f));
  115.         (pos = float4(((texcoord * float2(2.000000f, -2.000000f)) + float2(-1.000000f, 1.000000f)), 0.000000f, 1.000000f));
  116. }
  117.  
  118. void __main(in uint
  119.             id : TEXCOORD0, out float4 pos : POSITION, out float2 texcoord : TEXCOORD)
  120. {
  121.         _NSRFX_VS_PostProcess(id, pos, texcoord);
  122.         pos.xy += __TEXEL_SIZE__ * pos.ww;
  123. }
  124.  
  125. 21/07/2015 16:56:51:867 [19652] | TRACE | > Compiling shader
  126. 'GrainPass':
  127.  
  128. struct __sampler2D
  129.  
  130. {
  131.         sampler2D s;
  132.         float2 pixelsize;
  133. }
  134.  
  135. ;
  136. float4 __tex2Dgather0(__sampler2D s, float2 c)
  137. {
  138.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).r, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).r, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).r, tex2Dlod(s.s, float4(c, 0, 0)).r);
  139. }
  140.  
  141. float4 __tex2Dgather1(__sampler2D s, float2 c)
  142. {
  143.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).g, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).g, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).g, tex2Dlod(s.s, float4(c, 0, 0)).g);
  144. }
  145.  
  146. float4 __tex2Dgather2(__sampler2D s, float2 c)
  147. {
  148.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).b, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).b, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).b, tex2Dlod(s.s, float4(c, 0, 0)).b);
  149. }
  150.  
  151. float4 __tex2Dgather3(__sampler2D s, float2 c)
  152. {
  153.         return float4(tex2Dlod(s.s, float4(c + float2(0, 1) * s.pixelsize, 0, 0)).a, tex2Dlod(s.s, float4(c + float2(1, 1) * s.pixelsize.xy, 0, 0)).a, tex2Dlod(s.s, float4(c + float2(1, 0) * s.pixelsize.xy, 0, 0)).a, tex2Dlod(s.s, float4(c, 0, 0)).a);
  154. }
  155.  
  156. float4 __tex2Dgather0offset(__sampler2D s, float2 c, int2 offset)
  157. {
  158.         return __tex2Dgather0(s, c + offset * s.pixelsize);
  159. }
  160.  
  161. float4 __tex2Dgather1offset(__sampler2D s, float2 c, int2 offset)
  162. {
  163.         return __tex2Dgather1(s, c + offset * s.pixelsize);
  164. }
  165.  
  166. float4 __tex2Dgather2offset(__sampler2D s, float2 c, int2 offset)
  167. {
  168.         return __tex2Dgather2(s, c + offset * s.pixelsize);
  169. }
  170.  
  171. float4 __tex2Dgather3offset(__sampler2D s, float2 c, int2 offset)
  172. {
  173.         return __tex2Dgather3(s, c + offset * s.pixelsize);
  174. }
  175.  
  176. float4 __tex2Dlodoffset(__sampler2D s, float4 c, int2 offset)
  177. {
  178.         return tex2Dlod(s.s, c + float4(offset * s.pixelsize, 0, 0));
  179. }
  180.  
  181. float4 __tex2Doffset(__sampler2D s, float2 c, int2 offset)
  182. {
  183.         return tex2D(s.s, c + offset * s.pixelsize);
  184. }
  185.  
  186. int2 __tex2Dsize(__sampler2D s, int lod)
  187. {
  188.         return int2(1 / s.pixelsize) / exp2(lod);
  189. }
  190. #define POSITION VPOS
  191. uniform float _NSRFX_timer
  192.  
  193. :
  194. register(c0);
  195. uniform float _NSRFX_timeleft
  196.  
  197. :
  198. register(c1);
  199. uniform float _NSRFX_frametime
  200.  
  201. :
  202. register(c2);
  203. static const float _NSCFX_NSpermTexUnit = 0.003906f;
  204. static const float _NSCFX_NSpermTexUnitHalf = 0.001953f;
  205. uniform float _NSCFX_NSwidth
  206.  
  207. :
  208. register(c3);
  209. uniform float _NSCFX_NSheight
  210.  
  211. :
  212. register(c4);
  213. uniform float _NSCFX_NStimer
  214.  
  215. :
  216. register(c5);
  217. static const float _NSCFX_NSgrainamount = 0.050000f;
  218. uniform float _NSCFX_NScolored
  219.  
  220. :
  221. register(c6);
  222. uniform float _NSCFX_NScoloramount
  223.  
  224. :
  225. register(c7);
  226. uniform float _NSCFX_NSgrainsize
  227.  
  228. :
  229. register(c8);
  230. uniform float _NSCFX_NSlumamount
  231.  
  232. :
  233. register(c9);
  234.  
  235. float2 _NSCFX_NScoordRot(in float2
  236.                          tc, in float angle
  237.  
  238.  
  239.                         )
  240. {
  241.         float aspectr = (_NSCFX_NSwidth / _NSCFX_NSheight);
  242.         float rotX = (((((tc.x * 2.000000f) - 1.000000f) * aspectr) * cos(angle)) - (((tc.y * 2.000000f) - 1.000000f) * sin(angle)));
  243.         float rotY = ((((tc.y * 2.000000f) - 1.000000f) * cos(angle)) + ((((tc.x * 2.000000f) - 1.000000f) * aspectr) * sin(angle)));
  244.         (rotX = (((rotX / aspectr) * 0.500000f) + 0.500000f));
  245.         (rotY = ((rotY * 0.500000f) + 0.500000f));
  246.         return float2(rotX, rotY);
  247. }
  248.  
  249. float4 _NSCFX_NSrnm(in float2
  250.                     tc)
  251. {
  252.         float noise = (sin(dot(float3(tc.x, tc.y, _NSCFX_NStimer), float3(12.989800f, 78.233002f, 0.002522f))) * 43758.546875f);
  253.         float noiseR = ((frac(noise) * 2.000000f) - 1.000000f);
  254.         float noiseG = ((frac((noise * 1.215400f)) * 2.000000f) - 1.000000f);
  255.         float noiseB = ((frac((noise * 1.345300f)) * 2.000000f) - 1.000000f);
  256.         float noiseA = ((frac((noise * 1.364700f)) * 2.000000f) - 1.000000f);
  257.         return float4(noiseR, noiseG, noiseB, noiseA);
  258. }
  259.  
  260. float _NSCFX_NSfade(in float t
  261.  
  262.  
  263.                    )
  264. {
  265.         return (((t * t) * t) * ((t * ((t * 6.000000f) - 15.000000f)) + 10.000000f));
  266. }
  267.  
  268. float _NSCFX_NSpnoise3D(in float3
  269.                         p)
  270. {
  271.         float3 pi = ((0.003906f * floor(p)) + 0.001953f);
  272.         float3 pf = frac(p);
  273.         float perm00 = _NSCFX_NSrnm(pi.xy).w;
  274.         float3 grad000 = ((_NSCFX_NSrnm(float2(perm00, pi.z)).xyz * 4.000000f) - 1.000000f);
  275.         float n000 = dot(grad000, pf);
  276.         float3 grad001 = ((_NSCFX_NSrnm(float2(perm00, (pi.z + 0.003906f))).xyz * 4.000000f) - 1.000000f);
  277.         float n001 = dot(grad001, (pf - float3(0.000000f, 0.000000f, 1.000000f)));
  278.         float perm01 = _NSCFX_NSrnm((pi.xy + float2(0.000000f, 0.003906f))).w;
  279.         float3 grad010 = ((_NSCFX_NSrnm(float2(perm01, pi.z)).xyz * 4.000000f) - 1.000000f);
  280.         float n010 = dot(grad010, (pf - float3(0.000000f, 1.000000f, 0.000000f)));
  281.         float3 grad011 = ((_NSCFX_NSrnm(float2(perm01, (pi.z + 0.003906f))).xyz * 4.000000f) - 1.000000f);
  282.         float n011 = dot(grad011, (pf - float3(0.000000f, 1.000000f, 1.000000f)));
  283.         float perm10 = _NSCFX_NSrnm((pi.xy + float2(0.003906f, 0.000000f))).w;
  284.         float3 grad100 = ((_NSCFX_NSrnm(float2(perm10, pi.z)).xyz * 4.000000f) - 1.000000f);
  285.         float n100 = dot(grad100, (pf - float3(1.000000f, 0.000000f, 0.000000f)));
  286.         float3 grad101 = ((_NSCFX_NSrnm(float2(perm10, (pi.z + 0.003906f))).xyz * 4.000000f) - 1.000000f);
  287.         float n101 = dot(grad101, (pf - float3(1.000000f, 0.000000f, 1.000000f)));
  288.         float perm11 = _NSCFX_NSrnm((pi.xy + float2(0.003906f, 0.003906f))).w;
  289.         float3 grad110 = ((_NSCFX_NSrnm(float2(perm11, pi.z)).xyz * 4.000000f) - 1.000000f);
  290.         float n110 = dot(grad110, (pf - float3(1.000000f, 1.000000f, 0.000000f)));
  291.         float3 grad111 = ((_NSCFX_NSrnm(float2(perm11, (pi.z + 0.003906f))).xyz * 4.000000f) - 1.000000f);
  292.         float n111 = dot(grad111, (pf - float3(1.000000f, 1.000000f, 1.000000f)));
  293.         float4 n_x = lerp(float4(n000, n001, n010, n011), float4(n100, n101, n110, n111), _NSCFX_NSfade(pf.x));
  294.         float2 n_xy = lerp(n_x.xy, n_x.zw, _NSCFX_NSfade(pf.y));
  295.         float n_xyz = lerp(n_xy.x, n_xy.y, _NSCFX_NSfade(pf.z));
  296.         return n_xyz;
  297. }
  298.  
  299. float4 _NSCFX_NSGrainPass(in float4
  300.                           position, in float2 texcoord)
  301. {
  302.         float3 rotOffset = float3(1.425000f, 3.892000f, 5.835000f);
  303.         float2 rotCoordsR = _NSCFX_NScoordRot(texcoord, (_NSCFX_NStimer + rotOffset.x));
  304.         float2 rot = (rotCoordsR * float2((_NSCFX_NSwidth / _NSCFX_NSgrainsize), (_NSCFX_NSheight / _NSCFX_NSgrainsize)));
  305.         float pNoise = _NSCFX_NSpnoise3D(float3(rot.x, rot.y, 0.000000f));
  306.         float3 noise = float3(pNoise, pNoise, pNoise);
  307.         if ((_NSCFX_NScolored == 1)) {
  308.                 float2 rotCoordsG = _NSCFX_NScoordRot(texcoord, (_NSCFX_NStimer + rotOffset.y));
  309.                 float2 rotCoordsB = _NSCFX_NScoordRot(texcoord, (_NSCFX_NStimer + rotOffset.z));
  310.                 (noise.y = lerp(noise.x, _NSCFX_NSpnoise3D(float3((rotCoordsG * float2((_NSCFX_NSwidth / _NSCFX_NSgrainsize), (_NSCFX_NSheight / _NSCFX_NSgrainsize))), 1.000000f)), _NSCFX_NScoloramount));
  311.                 (noise.z = lerp(noise.x, _NSCFX_NSpnoise3D(float3((rotCoordsB * float2((_NSCFX_NSwidth / _NSCFX_NSgrainsize), (_NSCFX_NSheight / _NSCFX_NSgrainsize))), 2.000000f)), _NSCFX_NScoloramount));
  312.         }
  313.         float3 col = position.xyz;
  314.         float3 lumcoeff = float3(0.299000f, 0.587000f, 0.114000f);
  315.         float luminance = lerp(0.000000f, dot(col, lumcoeff), _NSCFX_NSlumamount);
  316.         float lum = smoothstep(0.200000f, 0.000000f, luminance);
  317.         (lum += luminance);
  318.         float2 thepow = pow(lum, 4.000000f);
  319.         (noise = lerp(noise, float3(0.000000f, 0.000000f, 0.000000f), pow(lum, 4.000000f)));
  320.         (col += (noise * 0.050000f));
  321.         return float4(col, 1.000000f);
  322. }
  323.  
  324. float4 __main(in float4
  325.               position : POSITION, in float2 texcoord : TEXCOORD0) : COLOR {
  326.         float4 _return = _NSCFX_NSGrainPass(position, texcoord);
  327.         return _return;
  328. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top