G2A Many GEOs
SHARE
TWEET

CRTcgwg

a guest Mar 30th, 2017 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ReShade.fxh"
  2.  
  3. uniform float texture_sizeX <
  4.     ui_type = "drag";
  5.     ui_min = 1.0;
  6.     ui_max = BUFFER_WIDTH;
  7.     ui_label = "Screen Width [CRT-cgwg]";
  8. > = 320.0;
  9.  
  10. uniform float texture_sizeY <
  11.     ui_type = "drag";
  12.     ui_min = 1.0;
  13.     ui_max = BUFFER_HEIGHT;
  14.     ui_label = "Screen Height [CRT-cgwg]";
  15. > = 240.0;
  16.  
  17. uniform float CRTCGWG_GAMMA <
  18.     ui_type = "drag";
  19.     ui_min = 0.0;
  20.     ui_max = 10.0;
  21.     ui_step = 0.01;
  22.     ui_label = "Gamma [CRT-cgwg]";
  23. > = 2.7;
  24.  
  25. float fmod(float a, float b)
  26. {
  27.   float c = frac(abs(a/b))*abs(b);
  28.   return (a < 0) ? -c : c;   /* if ( a < 0 ) c = 0-c */
  29. }
  30.  
  31. #define TEX2D(c) tex2D(ReShade::BackBuffer,(c))
  32. #define PI 3.141592653589
  33.  
  34. float4 PS_CRTcgwg(float4 vpos : SV_Position, float2 uv : TexCoord) : SV_Target
  35. {
  36.    
  37.    float2 delta = 1.0 / ReShade::ScreenSize.xy;
  38.    float dx = delta.x;
  39.    float dy = delta.y;
  40.    
  41.    float2 c01 = uv + float2(-dx, 0.0);
  42.    float2 c11 = uv + float2(0.0, 0.0);
  43.    float2 c21 = uv + float2(dx, 0.0);
  44.    float2 c31 = uv + float2(2.0 * dx, 0.0);
  45.    float2 c02 = uv + float2(-dx, dy);
  46.    float2 c12 = uv + float2(0.0, dy);
  47.    float2 c22 = uv + float2(dx, dy);
  48.    float2 c32 = uv + float2(2.0 * dx, dy);
  49.    float mod_factor = uv.x * ReShade::ScreenSize.x * texture_sizeX / texture_sizeX;
  50.    float2 ratio_scale = uv * float2(texture_sizeX,texture_sizeY);
  51.  
  52.    
  53.    float2 uv_ratio = frac(ratio_scale);
  54.    float4 col, col2;
  55.  
  56.    float4x4 texes0 = float4x4((TEX2D(c01).xyz),0.0, (TEX2D(c11).xyz),0.0, (TEX2D(c21).xyz),0.0, (TEX2D(c31).xyz),0.0);
  57.    float4x4 texes1 = float4x4((TEX2D(c02).xyz),0.0, (TEX2D(c12).xyz),0.0, (TEX2D(c22).xyz),0.0, (TEX2D(c32).xyz),0.0);
  58.  
  59.    float4 coeffs = float4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x) + 0.005;
  60.    coeffs = sin(PI * coeffs) * sin(0.5 * PI * coeffs) / (coeffs * coeffs);
  61.    coeffs = coeffs / dot(coeffs, float(1.0));
  62.  
  63.    float3 weights = float3(3.33 * uv_ratio.y, 3.33 * uv_ratio.y, 3.33 * uv_ratio.y);
  64.    float3 weights2 = float3(uv_ratio.y * -3.33 + 3.33, uv_ratio.y * -3.33 + 3.33, uv_ratio.y * -3.33 + 3.33);
  65.  
  66.    col = saturate(mul(coeffs, texes0));
  67.    col2 = saturate(mul(coeffs, texes1));
  68.  
  69.    float3 wid = 2.0 * pow(col, float4(4.0, 4.0, 4.0, 0.0)) + 2.0;
  70.    float3 wid2 = 2.0 * pow(col2, float4(4.0, 4.0, 4.0, 0.0)) + 2.0;
  71.  
  72.    col = pow(col, float4(CRTCGWG_GAMMA, CRTCGWG_GAMMA, CRTCGWG_GAMMA,0.0));
  73.    col2 = pow(col2, float4(CRTCGWG_GAMMA, CRTCGWG_GAMMA, CRTCGWG_GAMMA,0.0));
  74.  
  75.    float3 sqrt1 = rsqrt(0.5 * wid);
  76.    float3 sqrt2 = rsqrt(0.5 * wid2);
  77.  
  78.    float3 pow_mul1 = weights * sqrt1;
  79.    float3 pow_mul2 = weights2 * sqrt2;
  80.  
  81.    float3 div1 = 0.1320 * wid + 0.392;
  82.    float3 div2 = 0.1320 * wid2 + 0.392;
  83.  
  84.    float3 pow1 = -pow(pow_mul1, wid);
  85.    float3 pow2 = -pow(pow_mul2, wid2);
  86.  
  87.    weights = exp(pow1) / div1;
  88.    weights2 = exp(pow2) / div2;
  89.  
  90.    float3 multi = col * weights + col2 * weights2;
  91.    float3 mcol = lerp(float3(1.0, 0.7, 1.0), float3(0.7, 1.0, 0.7), floor(fmod(mod_factor, 2.0)));
  92.  
  93.    return float4(pow(mcol * multi, float3(0.454545, 0.454545, 0.454545)), 1.0);
  94. }
  95.  
  96. technique cgwgCRT {
  97.     pass CRT_cgwg_fast {
  98.         VertexShader=PostProcessVS;
  99.         PixelShader=PS_CRTcgwg;
  100.     }
  101. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
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