SHARE
TWEET

6

a guest Aug 14th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ReShadeUI.fxh"
  2.  
  3. uniform int Gamma_type < __UNIFORM_COMBO_INT1
  4.     ui_items = "Grey gamma\0Regular Gamma\0";
  5. > = 0;
  6.  
  7. uniform float Gamma < __UNIFORM_DRAG_FLOAT1
  8.     ui_min = -1.0; ui_max = 10.0;
  9. > = 1.0;
  10.  
  11. uniform bool Split <> = false;
  12.  
  13. uniform bool Flip_split <> = false;
  14.  
  15. uniform float Split_position < __UNIFORM_SLIDER_FLOAT1
  16.     ui_min = 0; ui_max =1;
  17.     ui_tooltip = "0 is on the far left, 1 on the far right.";
  18. > = 0.5;
  19.  
  20. #include "ReShade.fxh"
  21.  
  22.  
  23. float3 GammaPass(float4 position : SV_Position, float2 texcoord : TEXCOORD0) : SV_Target
  24. {
  25.     float3 colorOrig = tex2D(ReShade::BackBuffer, texcoord).rgb; //take only rgb component as we don't need alpha, see GammaPass writing to RGB only
  26.     float3 color=colorOrig; //we can ditch all .rgb suffixes
  27.  
  28.     //consider using dot(color.rgb, 0.333) - which is color.r * 0.333 + color.b * 0.333 + color.g * 0.333
  29.     float fakeluma = max(color.r, max(color.g, color.b));
  30.     //ternary operator (condition ? iftrue : iffalse) compiles into a cmp and doesn't branch
  31.     color = Gamma_type ? saturate(pow(fakeluma, Gamma) * color / fakeluma) : pow(color, Gamma);
  32.  
  33.     [branch] //force compiler to branch
  34.     if(Split)
  35.     {
  36.         //              | uv.x - split | > one pixel means line will be 2 pixels wide
  37.         float divLine = abs(texcoord.x - Split_position) < BUFFER_RCP_WIDTH;
  38.         float side = position.x > Split_position * BUFFER_WIDTH; //boolean split, left side is 0, right side is 1
  39.  
  40.         side = Flip_split ? 1 - side : side; //0 | 1 ---> 1 | 0
  41.  
  42.         color = lerp(color, colorOrig, side); //lerp(a,b,k) == b*k + a*(1-k), means if k is 0, take a, if k is 1, take b
  43.  
  44.         color *= 1.0 - divLine; //invert divline
  45.     }
  46.  
  47.     return color;
  48. }
  49.  
  50. technique Grey_Gamma
  51. {
  52.     pass
  53.     {
  54.         VertexShader = PostProcessVS;
  55.         PixelShader = GammaPass;
  56.     }
  57. }
RAW Paste Data
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