Advertisement
Guest User

Untitled

a guest
Apr 4th, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. uniform int XhairMode <
  2. ui_type = "combo";
  3. ui_items = "Texture file\0Solid Color\0Inversion\0";
  4. ui_label = "Xhair mode";
  5. > = 2;
  6.  
  7. uniform float Opacity <
  8. ui_type = "drag";
  9. ui_min = 0.0; ui_max = 1.0;
  10. ui_label = "Opacity";
  11. > = 1.0;
  12.  
  13. uniform int ModPosX <
  14. ui_type = "drag";
  15. ui_min = -10; ui_max = 10;
  16. ui_label = "X Axis Shift";
  17. > = 0;
  18.  
  19. uniform int ModPosY <
  20. ui_type = "drag";
  21. ui_min = -10; ui_max = 10;
  22. ui_label = "Y Axis Shift";
  23. > = 0;
  24.  
  25. uniform float3 SolidColor <
  26. ui_type = "color";
  27. ui_label = "[Solid color mode] Color";
  28. > = float3(0.0, 1.0, 1.0);
  29.  
  30. uniform bool UseStroke <
  31. ui_type = "checkbox";
  32. ui_label = "Stroke";
  33. > = true;
  34.  
  35. uniform float3 StrokeColor <
  36. ui_type = "color";
  37. ui_label = "Stroke Color";
  38. > = float3(0.0, 0.0, 0.0);
  39.  
  40. uniform float StrokeOpacity <
  41. ui_type = "drag";
  42. ui_min = 0.0; ui_max = 1.0;
  43. ui_label = "Stroke Opacity";
  44. > = 0.3;
  45.  
  46. uniform float Hue <
  47. ui_type = "drag";
  48. ui_min = -180.0; ui_max = 180.0;
  49. ui_label = "[Texture mode] Hue";
  50. > = 0.0;
  51. uniform float Brightness <
  52. ui_type = "drag";
  53. ui_min = -1.0; ui_max = 1.0;
  54. ui_label = "[Texture mode] Brightness";
  55. > = 0.0;
  56. uniform float Contrast <
  57. ui_type = "drag";
  58. ui_min = 0.0; ui_max = 1.0;
  59. ui_label = "[Texture mode] Contrast";
  60. > = 0.0;
  61. uniform float Saturation <
  62. ui_type = "drag";
  63. ui_min = 0.0; ui_max = 2.0;
  64. ui_label = "[Texture mode] Saturation";
  65. > = 1.0;
  66.  
  67. #include "Reshade.fxh"
  68.  
  69. texture xhairTex < source = "xhair.png"; > {Width = 1920; Height = 1080; Format = RGBA8;};
  70. sampler xhairSampler { Texture = xhairTex; };
  71.  
  72. texture xhairMaskTex < source = "xhair_mask.png"; > {Width = 1920; Height = 1080; Format = RGBA8;};
  73. sampler xhairMaskSampler { Texture = xhairMaskTex; };
  74.  
  75. float3x3 QuaternionToMatrix(float4 quat)
  76. {
  77. float3 cross = quat.yzx * quat.zxy;
  78. float3 square= quat.xyz * quat.xyz;
  79. float3 wimag = quat.w * quat.xyz;
  80.  
  81. square = square.xyz + square.yzx;
  82.  
  83. float3 diag = 0.5 - square;
  84. float3 a = (cross + wimag);
  85. float3 b = (cross - wimag);
  86.  
  87. return float3x3(
  88. 2.0 * float3(diag.x, b.z, a.y),
  89. 2.0 * float3(a.z, diag.y, b.x),
  90. 2.0 * float3(b.y, a.x, diag.z));
  91. }
  92.  
  93. float4 ColorShift(float4 outputColor, float H, float B, float C, float S)
  94. {
  95. float3 hsv;
  96. float3 intensity;
  97.  
  98. float3 root3 = float3(0.57735, 0.57735, 0.57735);
  99. float half_angle = 0.5 * radians(H);
  100. float4 rot_quat = float4((root3 * sin(half_angle)), cos(half_angle));
  101. float3x3 rot_Matrix = QuaternionToMatrix(rot_quat);
  102. outputColor.rgb = mul(rot_Matrix, outputColor.rgb);
  103. outputColor.rgb = (outputColor.rgb - 0.5) *(C + 1.0) + 0.5;
  104. outputColor.rgb = outputColor.rgb + B;
  105. float3 lumCoeff = float3(0.2125, 0.7154, 0.0721);
  106. intensity = float(dot(outputColor.rgb, lumCoeff));
  107. outputColor.rgb = lerp(intensity, outputColor.rgb, S);
  108.  
  109. return outputColor;
  110. }
  111.  
  112. float4 PS_Xhair(float4 vpos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
  113. {
  114. float2 texcoordMod = float2(texcoord.x - ModPosX / ReShade::ScreenSize.x, texcoord.y - ModPosY / ReShade::ScreenSize.y);
  115. float4 xhair_tex = tex2D(xhairSampler, texcoordMod);
  116. float4 xhair_mask = tex2D(xhairMaskSampler, texcoordMod).a;
  117. float4 back = tex2D(ReShade::BackBuffer, texcoord);
  118. float4 center = tex2D(ReShade::BackBuffer, float2(0.5f + ModPosX / ReShade::ScreenSize.x, 0.5f + ModPosY / ReShade::ScreenSize.y));
  119. float4 drawBackground;
  120. float4 drawXhair;
  121. float4 drawOpacity;
  122.  
  123. float4 outXhair;
  124.  
  125. if (XhairMode == 0) // Texture file mode
  126. {
  127. xhair_tex = ColorShift(xhair_tex, Hue, Brightness, Contrast, Saturation);
  128.  
  129. drawBackground = back;
  130. drawXhair = xhair_tex;
  131. drawOpacity = xhair_tex.a*Opacity;
  132. }
  133. if (XhairMode == 1) // Solid color mode
  134. {
  135. drawBackground = back;
  136. drawXhair = float4(SolidColor, 1.0);
  137. drawOpacity = xhair_mask*Opacity;
  138. }
  139. if (XhairMode == 2) // Inversion mode
  140. {
  141. float4 inv_center = 1-center;
  142. inv_center = ColorShift(inv_center, 0, 0, 0, 180);
  143.  
  144. drawBackground = back;
  145. drawXhair = inv_center;
  146. drawOpacity = xhair_mask*Opacity;
  147. }
  148.  
  149. if (UseStroke && XhairMode != 0)
  150. {
  151. float4 strokeN = tex2D(xhairMaskSampler, float2(texcoordMod.x, texcoordMod.y-1/ReShade::ScreenSize.y));
  152. float4 strokeS = tex2D(xhairMaskSampler, float2(texcoordMod.x, texcoordMod.y+1/ReShade::ScreenSize.y));
  153. float4 strokeW = tex2D(xhairMaskSampler, float2(texcoordMod.x-1/ReShade::ScreenSize.x, texcoordMod.y));
  154. float4 strokeE = tex2D(xhairMaskSampler, float2(texcoordMod.x+1/ReShade::ScreenSize.x, texcoordMod.y));
  155. float4 strokeNW = tex2D(xhairMaskSampler, float2(texcoordMod.x-1/ReShade::ScreenSize.x, texcoordMod.y-1/ReShade::ScreenSize.y));
  156. float4 strokeNE = tex2D(xhairMaskSampler, float2(texcoordMod.x+1/ReShade::ScreenSize.x, texcoordMod.y-1/ReShade::ScreenSize.y));
  157. float4 strokeSW = tex2D(xhairMaskSampler, float2(texcoordMod.x-1/ReShade::ScreenSize.x, texcoordMod.y+1/ReShade::ScreenSize.y));
  158. float4 strokeSE = tex2D(xhairMaskSampler, float2(texcoordMod.x+1/ReShade::ScreenSize.x, texcoordMod.y+1/ReShade::ScreenSize.y));
  159. float stroke = saturate(strokeN.a + strokeS.a + strokeW.a + strokeE.a + strokeNW.a + strokeNE.a + strokeSW.a + strokeSE.a);
  160.  
  161. float4 drawStroke = lerp(back,float4(StrokeColor,1.0),stroke*StrokeOpacity);
  162.  
  163. drawBackground = drawStroke;
  164. }
  165.  
  166. outXhair = lerp(drawBackground,drawXhair,drawOpacity);
  167.  
  168. return outXhair;
  169. }
  170.  
  171. technique xhair
  172. {
  173. pass HudPass
  174. {
  175. VertexShader = PostProcessVS;
  176. PixelShader = PS_Xhair;
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement