Advertisement
Guest User

option.txt

a guest
Jun 28th, 2011
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1. //// FXAA from Myster92 conversion & SHARPENING from Boris
  2. //// Edited by H1Vltg3
  3.  
  4. #define ESHARPENING
  5. #define ESHARPENINGCOLOR
  6. #define ENOISE
  7.  
  8.  
  9. float ShiftSamplingRange=0.2;
  10. float SamplingRange=1.1; //sharpening or blurring range
  11. float SharpeningAmount=1.85;
  12. float ScanLineAmount=1.0;
  13. float ScanLineRepeat=1.0; //0.5, 0.3333, 0.25, 0.125, so on
  14. float NoiseAmount=0.15;
  15.  
  16. float tempF1;
  17. float tempF2;
  18. float tempF3;
  19. float tempF4;
  20. float tempF5;
  21. float tempF6;
  22. float tempF7;
  23. float tempF8;
  24. float tempF9;
  25. float tempF0;
  26.  
  27. float ScreenSize;
  28. float ScreenScaleY;
  29.  
  30. texture2D texColor;
  31. texture2D texNoise;
  32.  
  33. sampler2D SamplerColor = sampler_state
  34. {
  35. Texture = <texColor>;
  36. MinFilter = LINEAR;
  37. MagFilter = LINEAR;
  38. MipFilter = NONE;//NONE;
  39. AddressU = Clamp;
  40. AddressV = Clamp;
  41. SRGBTexture=FALSE;
  42. MaxMipLevel=0;
  43. MipMapLodBias=0;
  44. };
  45.  
  46. sampler2D SamplerNoise = sampler_state
  47. {
  48. Texture = <texNoise>;
  49. MinFilter = POINT;
  50. MagFilter = POINT;
  51. MipFilter = NONE;//NONE;
  52. AddressU = Wrap;
  53. AddressV = Wrap;
  54. SRGBTexture=FALSE;
  55. MaxMipLevel=0;
  56. MipMapLodBias=0;
  57. };
  58.  
  59. struct VS_OUTPUT_POST {
  60. float4 vpos : POSITION;
  61. float2 txcoord : TEXCOORD0;
  62. };
  63.  
  64. struct VS_INPUT_POST {
  65. float3 pos : POSITION;
  66. float2 txcoord : TEXCOORD0;
  67. };
  68.  
  69.  
  70. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  71. //
  72. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  73. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  74. {
  75. VS_OUTPUT_POST OUT;
  76.  
  77. float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  78.  
  79. OUT.vpos=pos;
  80. OUT.txcoord.xy=IN.txcoord.xy;
  81.  
  82. return OUT;
  83. }
  84.  
  85. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  86. //--------------------Fast Approximate Anti-Aliasing --------------------------
  87. // FXAA v2 CONSOLE by TIMOTHY LOTTES @ NVIDIA
  88. // Ported to ENBSeries by MysTer92 (Svyatoslav Gampel)
  89. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  90. float4 PS_PostProcess(VS_OUTPUT_POST i) : COLOR
  91. {
  92. #define FXAA_SUBPIX_SHIFT (1.0/4.0)
  93. #define FXAA_REDUCE_MIN (1.0/128.0)
  94. #define FXAA_REDUCE_MUL (1.0/8.0)
  95. #define FXAA_SPAN_MAX 8.0
  96.  
  97. half2 rcpFrame = half2(1/ScreenSize, 1/(ScreenSize/ScreenScaleY));
  98.  
  99. half4 posPos;
  100. posPos.xy = i.txcoord.xy;
  101. posPos.zw = posPos.xy - (rcpFrame.xy * (0.5 + FXAA_SUBPIX_SHIFT));
  102.  
  103. half3 rgbNW = tex2D(SamplerColor, posPos.zw ).xyz;
  104. half3 rgbNE = tex2D(SamplerColor, posPos.zw + half2(rcpFrame.x, 0.0) ).xyz;
  105. half3 rgbSW = tex2D(SamplerColor, posPos.zw + half2(0.0, rcpFrame.y) ).xyz;
  106. half3 rgbSE = tex2D(SamplerColor, posPos.zw +rcpFrame.xy ).xyz;
  107. half3 rgbM = tex2D(SamplerColor, posPos.xy).xyz;
  108.  
  109. half3 luma = half3(0.299, 0.587, 0.114);
  110. half lumaNW = dot(rgbNW, luma);
  111. half lumaNE = dot(rgbNE, luma);
  112. half lumaSW = dot(rgbSW, luma);
  113. half lumaSE = dot(rgbSE, luma);
  114. half lumaM = dot(rgbM, luma);
  115.  
  116. half lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
  117. half lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
  118.  
  119. half2 dir;
  120.  
  121. half lumaNWNE = lumaNW + lumaNE;
  122. half lumaSWSE = lumaSW + lumaSE;
  123.  
  124. dir.x = -((lumaNWNE) - (lumaSWSE));
  125. dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
  126.  
  127. half dirReduce = max( (lumaSWSE + lumaNWNE) * (0.25 * FXAA_REDUCE_MUL),
  128. FXAA_REDUCE_MIN);
  129. half rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);
  130. dir = min(half2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),
  131. max(half2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
  132. dir * rcpDirMin)) * rcpFrame.xy;
  133.  
  134. half3 rgbA = (1.0/2.0) * (
  135. tex2D(SamplerColor, posPos.xy + dir * (1.0/3.0 - 0.5) ).xyz +
  136. tex2D(SamplerColor, posPos.xy + dir * (2.0/3.0 - 0.5) ).xyz);
  137. half3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
  138. tex2D(SamplerColor, posPos.xy + dir * (0.0/3.0 - 0.5) ).xyz +
  139. tex2D(SamplerColor, posPos.xy + dir * (3.0/3.0 - 0.5) ).xyz);
  140. half lumaB = dot(rgbB, luma);
  141.  
  142. if((lumaB < lumaMin) || (lumaB > lumaMax))
  143. return half4(rgbA, 1.0);
  144.  
  145. return float4(rgbB, 1.0);
  146. }
  147.  
  148. float4 PS_PostProcess5(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  149. {
  150. float4 res;
  151. float4 coord=0.0;
  152.  
  153. coord.xy=IN.txcoord.xy;
  154. float4 origcolor;
  155.  
  156. coord.w=0.0;
  157.  
  158.  
  159. origcolor=tex2Dlod(SamplerColor, coord);
  160.  
  161. // coord.x=IN.txcoord.x-(1.5/ScreenSize);
  162. // float4 lshift=tex2Dlod(SamplerColor, coord);
  163. // coord.x=IN.txcoord.x+(1.5/ScreenSize);
  164. // float4 rshift=tex2Dlod(SamplerColor, coord);
  165.  
  166.  
  167. float2 offset[8]=
  168. {
  169. float2(1.0, 1.0),
  170. float2(-1.0, -1.0),
  171. float2(-1.0, 1.0),
  172. float2(1.0, -1.0),
  173.  
  174. float2(1.41, 0.0),
  175. float2(-1.41, 0.0),
  176. float2(0.0, 1.41),
  177. float2(0.0, -1.41)
  178. };
  179. int i=0;
  180.  
  181. float4 tcol=origcolor;
  182. float invscreensize=1.0/ScreenSize;
  183. //for (i=0; i<8; i++) //higher quality
  184. for (i=0; i<8; i++)
  185. {
  186. float2 tdir=offset[i].xy;
  187. coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*SamplingRange;//*1.0;
  188. float4 ct=tex2Dlod(SamplerColor, coord);
  189.  
  190. tcol+=ct;
  191. }
  192. tcol*=0.111; // 1.0/(4+1)
  193. //tcol*=0.111; // 1.0/(8+1) //higher quality
  194.  
  195.  
  196. /*
  197. //not interesting
  198. #ifdef EBLURRING
  199. //blur
  200. res=tcol;
  201. #endif
  202. */
  203.  
  204. //sharp
  205. #ifdef ESHARPENING
  206.  
  207. #ifdef ESHARPENINGCOLOR
  208. //color
  209. res=origcolor*(1.0+((origcolor-tcol)*SharpeningAmount));
  210. #else
  211. //non color
  212. float difffact=dot((origcolor.xyz-tcol.xyz), 0.333);
  213. res=origcolor*(1.0+difffact*SharpeningAmount);
  214. #endif
  215.  
  216. //less sharpening for bright pixels
  217. float rgray=origcolor.z; //blue fit well
  218. //float rgray=max(origcolor.x, max(origcolor.y, origcolor.z));
  219. rgray=pow(rgray, 3.0);
  220. res=lerp(res, origcolor, saturate(rgray));
  221.  
  222. #endif
  223.  
  224.  
  225.  
  226.  
  227. //grain noise
  228. #ifdef ENOISE
  229. float origgray=max(res.x, res.y);//dot(res.xyz, 0.333);
  230. origgray=max(origgray, res.z);
  231. coord.xy=IN.txcoord.xy*16.0 + origgray;
  232. float4 cnoi=tex2Dlod(SamplerNoise, coord);
  233. res=lerp(res, (cnoi.x+0.5)*res, NoiseAmount*saturate(1.0-origgray*1.8));
  234. #endif
  235.  
  236.  
  237. res.w=1.0;
  238. return res;
  239. }
  240.  
  241. float4 PS_Process6(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
  242. {
  243. float4 res;
  244. float4 coord=0.0;
  245.  
  246. coord.xy=IN.txcoord.xy;
  247. float4 origcolor;
  248.  
  249. coord.w=0.0;
  250.  
  251.  
  252. origcolor=tex2Dlod(SamplerColor, coord);
  253.  
  254. // coord.x=IN.txcoord.x-(1.5/ScreenSize);
  255. // float4 lshift=tex2Dlod(SamplerColor, coord);
  256. // coord.x=IN.txcoord.x+(1.5/ScreenSize);
  257. // float4 rshift=tex2Dlod(SamplerColor, coord);
  258.  
  259.  
  260. float2 offset[8]=
  261. {
  262. float2(1.0, 1.0),
  263. float2(-1.0, -1.0),
  264. float2(-1.0, 1.0),
  265. float2(1.0, -1.0),
  266.  
  267. float2(1.41, 0.0),
  268. float2(-1.41, 0.0),
  269. float2(0.0, 1.41),
  270. float2(0.0, -1.41)
  271. };
  272. int i=0;
  273.  
  274. float4 tcol=origcolor;
  275. float2 invscreensize=1.0/ScreenSize;
  276. invscreensize.y=invscreensize.y/ScreenScaleY;
  277. //for (i=0; i<8; i++) //higher quality
  278. /* for (i=0; i<4; i++)
  279. {
  280. float2 tdir=offset[i].xy;
  281. coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*SamplingRange;//*1.0;
  282. float4 ct=tex2Dlod(SamplerColor, coord);
  283.  
  284. tcol+=ct;
  285. }
  286. tcol*=0.2; // 1.0/(4+1)
  287. //tcol*=0.111; // 1.0/(8+1) //higher quality
  288. */
  289.  
  290. coord.xy=IN.txcoord.xy;
  291. origcolor=tex2Dlod(SamplerColor, coord);
  292. res.y=origcolor.y;
  293.  
  294. coord.xy=IN.txcoord.xy;
  295. coord.y-=invscreensize*ShiftSamplingRange;
  296. origcolor=tex2Dlod(SamplerColor, coord);
  297. res.x=origcolor.x;
  298.  
  299. coord.xy=IN.txcoord.xy;
  300. coord.y+=invscreensize*ShiftSamplingRange;
  301. origcolor=tex2Dlod(SamplerColor, coord);
  302. res.z=origcolor.z;
  303.  
  304.  
  305. res.w=1.0;
  306. return res;
  307. }
  308.  
  309.  
  310. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  311. //--------------------Fast Approximate Anti-Aliasing Techniques -------------
  312. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  313. technique PostProcess
  314. {
  315. pass P0
  316. {
  317. VertexShader = compile vs_3_0 VS_PostProcess();
  318. PixelShader = compile ps_3_0 PS_PostProcess();
  319.  
  320. FogEnable=FALSE;
  321. ALPHATESTENABLE=FALSE;
  322. SEPARATEALPHABLENDENABLE=FALSE;
  323. AlphaBlendEnable=FALSE;
  324. FogEnable=FALSE;
  325. SRGBWRITEENABLE=FALSE;
  326. }
  327. }
  328. technique PostProcess2
  329. {
  330. pass P0
  331. {
  332. VertexShader = compile vs_3_0 VS_PostProcess();
  333. PixelShader = compile ps_3_0 PS_PostProcess();
  334.  
  335. FogEnable=FALSE;
  336. ALPHATESTENABLE=FALSE;
  337. SEPARATEALPHABLENDENABLE=FALSE;
  338. AlphaBlendEnable=FALSE;
  339. FogEnable=FALSE;
  340. SRGBWRITEENABLE=FALSE;
  341. }
  342. }
  343. technique PostProcess3
  344. {
  345. pass P0
  346. {
  347. VertexShader = compile vs_3_0 VS_PostProcess();
  348. PixelShader = compile ps_3_0 PS_PostProcess();
  349.  
  350. FogEnable=FALSE;
  351. ALPHATESTENABLE=FALSE;
  352. SEPARATEALPHABLENDENABLE=FALSE;
  353. AlphaBlendEnable=FALSE;
  354. FogEnable=FALSE;
  355. SRGBWRITEENABLE=FALSE;
  356. }
  357. }
  358. technique PostProcess4
  359. {
  360. pass P0
  361. {
  362. VertexShader = compile vs_3_0 VS_PostProcess();
  363. PixelShader = compile ps_3_0 PS_PostProcess();
  364.  
  365. FogEnable=FALSE;
  366. ALPHATESTENABLE=FALSE;
  367. SEPARATEALPHABLENDENABLE=FALSE;
  368. AlphaBlendEnable=FALSE;
  369. FogEnable=FALSE;
  370. SRGBWRITEENABLE=FALSE;
  371. }
  372. }
  373. technique PostProcess5
  374. {
  375. pass P0
  376. {
  377.  
  378. VertexShader = compile vs_3_0 VS_PostProcess();
  379. PixelShader = compile ps_3_0 PS_PostProcess5();
  380.  
  381. DitherEnable=FALSE;
  382. ZEnable=FALSE;
  383. CullMode=NONE;
  384. ALPHATESTENABLE=FALSE;
  385. SEPARATEALPHABLENDENABLE=FALSE;
  386. AlphaBlendEnable=FALSE;
  387. StencilEnable=FALSE;
  388. FogEnable=FALSE;
  389. SRGBWRITEENABLE=FALSE;
  390. }
  391. }
  392. technique PostProcess6
  393. {
  394. pass P0
  395. {
  396.  
  397. VertexShader = compile vs_3_0 VS_PostProcess();
  398. PixelShader = compile ps_3_0 PS_Process6();
  399.  
  400. DitherEnable=FALSE;
  401. ZEnable=FALSE;
  402. CullMode=NONE;
  403. ALPHATESTENABLE=FALSE;
  404. SEPARATEALPHABLENDENABLE=FALSE;
  405. AlphaBlendEnable=FALSE;
  406. StencilEnable=FALSE;
  407. FogEnable=FALSE;
  408. SRGBWRITEENABLE=FALSE;
  409. }
  410. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement