Advertisement
Guest User

MegaMan9.fx

a guest
Nov 26th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ReShade.fxh"
  2.  
  3. uniform bool sharper <
  4.     ui_tooltip = "Sharper";
  5. > = 1;
  6.  
  7. sampler2D buffer
  8. {
  9.     Texture = ReShade::BackBufferTex;
  10.     MinFilter = POINT;
  11.     MagFilter = POINT;
  12.     MipFilter = POINT;
  13.     AddressU = Clamp;
  14.     AddressV = Clamp;
  15. };
  16.  
  17. float2 goodtobad (float2 pos)
  18. {
  19.     float2 badpos;
  20.     badpos.x = (343.0 + pos.x * 1234) / 1920.0;
  21.     badpos.y = pos.y;
  22.     return badpos;
  23. }  
  24.  
  25. float4 PS_BilinearMM9(float4 pos : SV_Position, float2 uv : TEXCOORD0) : SV_Target
  26. {
  27.     //  Input:
  28.     //   256x224 scaled into 343 -> 1234 -> 343 (8:7) in 1920x1080 buffer
  29.     //  Output:
  30.     //   240 -> 1440 -> 240 (4/3) in 1920x1080 buffer
  31.        
  32.     float2 fragment = float2(1920, 1080) * uv;
  33.  
  34.     // Our uv coords in the 256x224 buffer
  35.     float2 samp;
  36.     samp.x = (fragment.x - 240.0) / 1440.0;
  37.     samp.y = fragment.y / 1080.0;
  38.  
  39.     float2 ploc;
  40.     ploc = samp * float2(256, 224);
  41.     float2 ppoffset = (ploc - 0.5) - (floor(ploc - 0.5));
  42.  
  43.     // Centers of 4 sampled pixels
  44.     float2 ul = ploc - ppoffset;
  45.     float2 ur = float2(ul.x + 1.0, ul.y);
  46.     float2 ll = float2(ul.x, ul.y + 1.0);
  47.     float2 lr = float2(ul.x + 1.0, ul.y + 1.0);
  48.    
  49.     if (sharper)
  50.         ppoffset = ppoffset * ppoffset * ppoffset * ppoffset * (ppoffset * (ppoffset * (-20.0 * ppoffset + float2(70.0, 70.0)) - float2(84.0, 84.0)) + float2(35.0, 35.0));
  51.  
  52.     ul /= float2(256, 224);
  53.     ur /= float2(256, 224);
  54.     ll /= float2(256, 224);
  55.     lr /= float2(256, 224);
  56.    
  57.     float4 cul = tex2D(buffer, goodtobad(ul));
  58.     float4 cur = tex2D(buffer, goodtobad(ur));
  59.     float4 cll = tex2D(buffer, goodtobad(ll));
  60.     float4 clr = tex2D(buffer, goodtobad(lr));
  61.  
  62.     return lerp(lerp(cul, cur, ppoffset.x), lerp(cll, clr, ppoffset.x), ppoffset.y);
  63. }
  64.  
  65. technique BilinearMM9
  66. {
  67.     pass BilinearMM9
  68.     {
  69.         VertexShader=PostProcessVS;
  70.         PixelShader=PS_BilinearMM9;
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement