Advertisement
Guest User

Untitled

a guest
Oct 11th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. // ENBSeries Fallout 4 hlsl DX11 format, sample file
  3. // visit http://enbdev.com for updates
  4. // Author: Boris Vorontsov
  5. // It's similar to effect.txt shaders and works with ldr input and output
  6. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. // This is a demo file on bare-bone enbsmaa.fx implementation
  8.  
  9. //+++++++++++++++++++++++++++++
  10. //external enb parameters, do not modify
  11. //+++++++++++++++++++++++++++++
  12. //x = generic timer in range 0..1, period of 16777216 ms (4.6 hours), y = average fps, w = frame time elapsed (in seconds)
  13. float4 Timer;
  14. //x = Width, y = 1/Width, z = aspect, w = 1/aspect, aspect is Width/Height
  15. float4 ScreenSize;
  16. //changes in range 0..1, 0 means full quality, 1 lowest dynamic quality (0.33, 0.66 are limits for quality levels)
  17. float AdaptiveQuality;
  18. //x = current weather index, y = outgoing weather index, z = weather transition, w = time of the day in 24 standart hours. Weather index is value from weather ini file, for example WEATHER002 means index==2, but index==0 means that weather not captured.
  19. float4 Weather;
  20. //x = dawn, y = sunrise, z = day, w = sunset. Interpolators range from 0..1
  21. float4 TimeOfDay1;
  22. //x = dusk, y = night. Interpolators range from 0..1
  23. float4 TimeOfDay2;
  24. //changes in range 0..1, 0 means that night time, 1 - day time
  25. float ENightDayFactor;
  26. //changes 0 or 1. 0 means that exterior, 1 - interior
  27. float EInteriorFactor;
  28.  
  29. //+++++++++++++++++++++++++++++
  30. //external enb debugging parameters for shader programmers, do not modify
  31. //+++++++++++++++++++++++++++++
  32. //keyboard controlled temporary variables. Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
  33. float4 tempF1, tempF2, tempF3; //1, 2, 3, 4, 5, 6, 7, 8, 9, 0
  34. // xy = cursor position in range 0..1 of screen;
  35. // z = is shader editor window active;
  36. // w = mouse buttons with values 0..7 as follows:
  37. // 0 = none
  38. // 1 = left
  39. // 2 = right
  40. // 3 = left+right
  41. // 4 = middle
  42. // 5 = left+middle
  43. // 6 = right+middle
  44. // 7 = left+right+middle (or rather cat is sitting on your mouse)
  45. float4 tempInfo1;
  46. // xy = cursor position of previous left mouse button click
  47. // zw = cursor position of previous right mouse button click
  48. float4 tempInfo2;
  49.  
  50. //+++++++++++++++++++++++++++++
  51. //mod parameters, do not modify
  52. //+++++++++++++++++++++++++++++
  53. Texture2D TextureOriginal; //color R10B10G10A2 32 bit ldr format
  54. Texture2D TextureColor; //color which is output of previous technique (except when drawed to temporary render target), R10B10G10A2 32 bit ldr format
  55. Texture2D TextureDepth; //scene depth R32F 32 bit hdr format
  56.  
  57. //temporary textures which can be set as render target for techniques via annotations like <string RenderTarget="RenderTargetRGBA32";>
  58. Texture2D RenderTargetRGBA32; //R8G8B8A8 32 bit ldr format
  59. Texture2D RenderTargetRGBA64; //R16B16G16A16 64 bit ldr format
  60. Texture2D RenderTargetRGBA64F; //R16B16G16A16F 64 bit hdr format
  61. Texture2D RenderTargetR16F; //R16F 16 bit hdr format with red channel only
  62. Texture2D RenderTargetR32F; //R32F 32 bit hdr format with red channel only
  63. Texture2D RenderTargetRGB32F; //32 bit hdr format without alpha
  64.  
  65. SamplerState Sampler0
  66. {
  67. Filter = MIN_MAG_MIP_POINT;//MIN_MAG_MIP_LINEAR;
  68. AddressU = Clamp;
  69. AddressV = Clamp;
  70. };
  71.  
  72. #define SMAA_UINAME 1
  73. #define PASSNAME0 SMAA
  74. #define PASSNAME1 SMAA1
  75. #define PASSNAME2 SMAA2
  76. #define PASSNAME3 SMAA3
  77. #include "enbsmaa.fx"
  78.  
  79.  
  80. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  81. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  82. //RETRO FX shader code starts here
  83. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  84. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  85.  
  86. /*
  87. Multipass technique groups have such structure:
  88.  
  89. MYAWESOMETECHNIQUENAME <- name of technique group. The techniques you can select in the UI are the starter techniques like this one
  90. MYAWESOMETECHNIQUENAME1 <- consecutive technique name so ENB knows to append this one after MYAWESOMETECHNIQUENAME
  91. MYAWESOMETECHNIQUENAME2 <- consecutive technique name so ENB knows to append this one after MYAWESOMETECHNIQUENAME1
  92.  
  93. We are using SMAA, SMAA1, SMAA2 now, so as we want to use SMAA and Retro (or do we?), we have to use SMAA3 now, to append it after SMAA2.
  94. */
  95.  
  96. #define PASSNAME3 SMAA3
  97.  
  98. /* Kingeric's SMAA port uses own vertex shaders. Vertex shaders determine the area where the pixel shader runs, among other things
  99. such as expensive calculations that are uniform on all pixels so calculating them in the vertex shader is faster.
  100. As we don't need such things, we're reimplementing Boris' standard vertex shader here. */
  101.  
  102. struct VS_INPUT_POST
  103. {
  104. float3 pos : POSITION;
  105. float2 txcoord : TEXCOORD0;
  106. };
  107. struct VS_OUTPUT_POST
  108. {
  109. float4 pos : SV_POSITION;
  110. float2 txcoord0 : TEXCOORD0;
  111. };
  112.  
  113. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  114. {
  115. VS_OUTPUT_POST OUT;
  116. float4 pos;
  117. pos.xyz=IN.pos.xyz;
  118. pos.w=1.0;
  119. OUT.pos=pos;
  120. OUT.txcoord0.xy=IN.txcoord.xy;
  121. return OUT;
  122. }
  123.  
  124. int EColorCount
  125. <
  126. string UIName="Retro:: Amount of singular colors";
  127. string UIWidget="spinner";
  128. int UIMin=1;
  129. int UIMax=255;
  130. > = {16};
  131.  
  132. float EResolutionDiv
  133. <
  134. string UIName="Retro:: Resolution scale";
  135. string UIWidget="spinner";
  136. float UIMin=0.0;
  137. float UIMax=16.0;
  138. float UIStep=0.1;
  139. > = {4.0};
  140.  
  141. float4 PS_Retro(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
  142. {
  143. float2 screenresRescaled = ScreenSize.xx * float2(1.0,ScreenSize.w) / EResolutionDiv;
  144. float2 texcoord = floor(IN.txcoord0.xy * screenresRescaled) / screenresRescaled;
  145.  
  146. float4 color = TextureColor.Sample(Sampler0, texcoord);
  147.  
  148. //Do Vibrance
  149. float VibranceIntensity = 1.0;
  150. float VibranceR = 1.0;
  151. float VibranceG = 1.0;
  152. float VibranceB = 1.0;
  153.  
  154. float3 VibCoeff = float3((VibranceR * VibranceIntensity), (VibranceG * VibranceIntensity), (VibranceB * VibranceIntensity));
  155.  
  156. float3 VibColor = color.rgb;
  157.  
  158. float3 LumCoeff = float3(0.2127, 0.7152, 0.0722);
  159. float Luma = dot(LumCoeff, VibColor.rgb);
  160.  
  161. float VibMaxColor = max(color.r, max(color.g, color.b));
  162. float VibMinColor = min(color.r, min(color.g, color.b));
  163.  
  164. float VibSaturation = VibMaxColor - VibMinColor;
  165.  
  166. VibColor.rgb = lerp(Luma, VibColor.rgb, (1.0 + (VibCoeff * (1.0 - (sign(VibCoeff) * VibSaturation)))));
  167.  
  168. color.rgb = VibColor.rgb;
  169. //
  170.  
  171. //Levels
  172.  
  173. float3 RGB_Lift = float3(1.30,1.30,1.30);
  174. float3 RGB_Gain = float3(1.00,1.00,1.00);
  175. float3 RGB_Gamma = float3(1.00,1.00,1.00);
  176. color.rgb = color.rgb * (1.5-0.5 * RGB_Lift) + 0.5 * RGB_Lift - 0.5;
  177. color.rgb = saturate(color.rgb);
  178.  
  179. color.rgb *= RGB_Gain;
  180.  
  181. color.rgb = pow(color.rgb, 1.0 / RGB_Gamma); //Gamma
  182.  
  183. color.rgb = saturate(color);
  184. //
  185.  
  186.  
  187. color.rgb += 0.12;
  188. float graymax=max(color.r, max(color.g, color.b));
  189. float3 ncolor=color.rgb/graymax;
  190. graymax=floor(graymax * EColorCount)/EColorCount;
  191. color.xyz*=graymax;
  192.  
  193. color.a = 1.0;
  194. return color;
  195.  
  196. }
  197.  
  198. technique11 PASSNAME3 // <- preprocessor will substitute "PASSNAME3" with the "SMAA3" we declared above
  199. {
  200. pass McFlysSimpleRetroShit //arbitrary name
  201. {
  202. SetVertexShader(CompileShader(vs_5_0, VS_PostProcess())); // <- we're using Boris' vertex shader from above
  203. SetPixelShader(CompileShader(ps_5_0, PS_Retro()));
  204. }
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement