Advertisement
Guest User

MegaMan10.fx

a guest
Nov 30th, 2018
440
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. uniform bool aspect65 <
  8.     ui_tooltip = "Leave aspect ratio at 6:5 to show full borders.";
  9. > = 0;
  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 = (312.0 + pos.x * 1296) / 1920.0;
  25.     badpos.y = pos.y;
  26.     return badpos;
  27. }  
  28.  
  29. float4 PS_BilinearMM10(float4 pos : SV_Position, float2 uv : TEXCOORD0) : SV_Target
  30. {
  31.     //  Input:
  32.     //   256x224 scaled into 312 -> 1296 -> 312 (6:5) 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 (aspect65)
  42.     {
  43.         left = 312;
  44.         middle = 1296;
  45.     }
  46.  
  47.     if (fragment.x < left || fragment.x >= (left + middle))
  48.         return tex2D(buffer, uv);
  49.    
  50.     samp.x = (fragment.x - left) / middle;
  51.     samp.y = fragment.y / 1080.0;      
  52.  
  53.     float2 ploc;
  54.     ploc = samp * float2(256, 224);
  55.     float2 ppoffset = (ploc - 0.5) - (floor(ploc - 0.5));
  56.  
  57.     // Centers of 4 sampled pixels
  58.     float2 ul = ploc - ppoffset;
  59.     float2 ur = float2(ul.x + 1.0, ul.y);
  60.     float2 ll = float2(ul.x, ul.y + 1.0);
  61.     float2 lr = float2(ul.x + 1.0, ul.y + 1.0);
  62.  
  63.     if (sharper)
  64.     {
  65.         ppoffset = clamp((ppoffset - 0.375) * 4.0, 0.0, 1.0);
  66.     }
  67.  
  68.     ul /= float2(256, 224);
  69.     ur /= float2(256, 224);
  70.     ll /= float2(256, 224);
  71.     lr /= float2(256, 224);
  72.    
  73.     float4 cul = tex2D(buffer, goodtobad(ul));
  74.     float4 cur = tex2D(buffer, goodtobad(ur));
  75.     float4 cll = tex2D(buffer, goodtobad(ll));
  76.     float4 clr = tex2D(buffer, goodtobad(lr));
  77.  
  78.     return lerp(lerp(cul, cur, ppoffset.x), lerp(cll, clr, ppoffset.x), ppoffset.y);
  79. }
  80.  
  81. technique BilinearMM10
  82. {
  83.     pass BilinearMM10
  84.     {
  85.         VertexShader=PostProcessVS;
  86.         PixelShader=PS_BilinearMM10;
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement