Advertisement
Guest User

MegaMan9.fx

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