Advertisement
Drakonas

Untitled

May 29th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [OptionBool]
  2. GUIName = Bloom
  3. OptionName = C_BLOOM
  4. DefaultValue = true
  5.  
  6. [OptionBool]
  7. GUIName = Bloom Only
  8. OptionName = A_BLOOMONLY
  9. DefaultValue = false
  10. DependentOption = C_BLOOM
  11. GUIDescription = Only show Bloom effects. (Testing purposes)
  12.  
  13. [OptionRangeInteger]
  14. GUIName = Mix Mode
  15. OptionName = A_BLOOM_MIXMODE
  16. MinValue = 1
  17. MaxValue = 4
  18. StepAmount = 1
  19. DefaultValue = 2
  20. DependentOption = C_BLOOM
  21. GUIDescription = 1 = Linear add | 2 = Screen add | 3 = Screen/Lighten/Opacity | 4 = Lighten
  22.  
  23. [OptionRangeFloat]
  24. GUIName = Threshold
  25. OptionName = A_BLOOM_THRESHOLD
  26. MinValue = 0.01
  27. MaxValue = 1.00
  28. StepAmount = 0.01
  29. DefaultValue = 0.80
  30. DependentOption = C_BLOOM
  31. GUIDescription = Every pixel brighter than this value triggers bloom.
  32.  
  33. [OptionRangeFloat]
  34. GUIName = Amount
  35. OptionName = B_BLOOM_AMOUNT
  36. MinValue = 0.0
  37. MaxValue = 20.0
  38. StepAmount = 0.1
  39. DefaultValue = 0.8
  40. DependentOption = C_BLOOM
  41. GUIDescription = Intensity of bloom.
  42.  
  43. [OptionRangeFloat]
  44. GUIName = Saturation
  45. OptionName = B_BLOOM_SATURATION
  46. MinValue = 0.00
  47. MaxValue = 2.00
  48. StepAmount = 0.01
  49. DefaultValue = 0.80
  50. DependentOption = C_BLOOM
  51. GUIDescription = Bloom saturation. 0.0 means white bloom, 2.0 means very very colorful bloom.
  52.  
  53. [OptionRangeFloat]
  54. GUIName = Tint
  55. OptionName = B_BLOOM_TINT
  56. MinValue = 0.00, 0.00, 0.00
  57. MaxValue = 1.00, 1.00, 1.00
  58. StepAmount = 0.01, 0.01, 0.01
  59. DefaultValue = 0.70, 0.80, 1.00
  60. DependentOption = C_BLOOM
  61. GUIDescription = R, G and B components of bloom tintcolor the bloom color gets shifted to.
  62.  
  63. [OptionBool]
  64. GUIName = Light Scattering
  65. OptionName = D_SCATTERRING
  66. DefaultValue = True
  67. DependentOption = C_BLOOM
  68.  
  69. [OptionRangeFloat]
  70. GUIName = Density
  71. OptionName = E_SDENSITY
  72. MinValue = 0.0
  73. MaxValue = 1.0
  74. StepAmount = 0.01
  75. DefaultValue = 0.17
  76. DependentOption = C_BLOOM
  77.  
  78. [OptionRangeFloat]
  79. GUIName = Start
  80. OptionName = F_SSTART
  81. MinValue = 0.0
  82. MaxValue = 0.5
  83. StepAmount = 0.01
  84. DefaultValue = 0.05
  85. DependentOption = C_BLOOM
  86.  
  87. [OptionRangeFloat]
  88. GUIName = End
  89. OptionName = G_SEND
  90. MinValue = 0.5
  91. MaxValue = 2.0
  92. StepAmount = 0.01
  93. DefaultValue = 2.0
  94. DependentOption = C_BLOOM
  95.  
  96. [OptionRangeFloat]
  97. GUIName = Default Color
  98. OptionName = H_SCOLOR
  99. MinValue = 0.1, 0.1, 0.1
  100. MaxValue = 1.0, 1.0, 1.0
  101. StepAmount = 0.01, 0.01, 0.01
  102. DefaultValue = 0.91, 0.52, 1
  103. DependentOption = C_BLOOM
  104.  
  105. [OptionRangeFloat]
  106. GUIName = Scattering Intensity
  107. OptionName = I_SINTENSITY
  108. MinValue = 0.0
  109. MaxValue = 1.0
  110. StepAmount = 0.01
  111. DefaultValue = 0.36
  112. DependentOption = C_BLOOM
  113.  
  114. [Pass]
  115. EntryPoint = BloomPrePass
  116. DependantOption = C_BLOOM
  117. Input0=PreviousPass
  118. Input0Filter=Linear
  119. Input0Mode=Clamp
  120. [Pass]
  121. EntryPoint = BloomPass1
  122. DependantOption = C_BLOOM
  123. Input0=PreviousPass
  124. Input0Filter=Linear
  125. Input0Mode=Clamp
  126. [Pass]
  127. EntryPoint = BloomPass2
  128. DependantOption = C_BLOOM
  129. OutputScale = 0.5
  130. Input0=PreviousPass
  131. Input0Filter=Linear
  132. Input0Mode=Clamp
  133. [Pass]
  134. EntryPoint = BloomPass3
  135. DependantOption = C_BLOOM
  136. OutputScale = 0.25
  137. Input0=PreviousPass
  138. Input0Filter=Linear
  139. Input0Mode=Clamp
  140. Input1=DepthBuffer
  141. Input1Filter=Nearest
  142. Input1Mode=Clamp
  143. [Pass]
  144. EntryPoint = BloomPass4
  145. DependantOption = C_BLOOM
  146. OutputScale = 0.125
  147. Input0=PreviousPass
  148. Input0Filter=Linear
  149. Input0Mode=Clamp
  150. Input1=DepthBuffer
  151. Input1Filter=Nearest
  152. Input1Mode=Clamp
  153. [Pass]
  154. EntryPoint = BloomScatering
  155. DependantOption = C_BLOOM
  156. OutputScale = 0.03125
  157. Input0=PreviousPass
  158. Input0Filter=Linear
  159. Input0Mode=Clamp
  160. [Pass]
  161. EntryPoint = BloomMerger
  162. DependantOption = C_BLOOM
  163. Input0=Pass9
  164. Input0Filter=Linear
  165. Input0Mode=Clamp
  166. Input1=Pass14
  167. Input1Filter=Linear
  168. Input1Mode=Clamp
  169. Input2=PreviousPass
  170. Input2Filter=Linear
  171. Input2Mode=Clamp
  172. Input3=DepthBuffer
  173. Input3Filter=Nearest
  174. Input3Mode=Clamp
  175.  
  176. float4 Gauss1dPrev2(float2 coord, float2 axis, float mult)
  177. {
  178.     float4 sum = 0;
  179.     float weight[11] = { 0.082607, 0.080977, 0.076276, 0.069041, 0.060049, 0.050187, 0.040306, 0.031105, 0.023066, 0.016436, 0.011254 };
  180.     axis *= GetInvResolution() * mult;
  181.     for (int i = -10; i < 11; i++)
  182.     {
  183.         float currweight = weight[abs(i)];
  184.         sum += SamplePrevLocation(coord.xy + axis.xy * (float)i) * currweight;
  185.     }
  186.     return sum;
  187. }
  188.  
  189. //------------------------------------------------------------------------------
  190. // BLOOM
  191. //------------------------------------------------------------------------------
  192.  
  193. void BloomPrePass()
  194. {
  195.     float4 bloom=0.0;
  196.     float2 bloomuv;
  197.     float2 texcoord = GetCoordinates();
  198.  
  199.     float2 offset[4]=
  200.     {
  201.         float2(1.0, 1.0),
  202.         float2(1.0, 1.0),
  203.         float2(-1.0, 1.0),
  204.         float2(-1.0, -1.0)
  205.     };
  206.  
  207.     for (int i=0; i<4; i++)
  208.     {
  209.         bloomuv.xy=offset[i]*2;
  210.         bloomuv.xy=texcoord.xy + bloomuv.xy;
  211.         float4 tempbloom = SampleLocation(bloomuv.xy);
  212.         tempbloom.a = max(0,dot(tempbloom.xyz,float3(0.333,0.333,0.333))-GetOption(A_ANAMFLARE_THRESHOLD));
  213.         tempbloom.xyz = max(float3(0,0,0), tempbloom.xyz-GetOption(A_BLOOM_THRESHOLD));
  214.         bloom+=tempbloom;
  215.     }
  216.  
  217.     bloom *= 0.25;
  218.     SetOutput(bloom);
  219. }
  220.  
  221. void BloomPass1()
  222. {
  223.  
  224.     float4 bloom=0.0;
  225.     float2 bloomuv;
  226.     float2 texcoord = GetCoordinates();
  227.  
  228.     float2 offset[8]=
  229.     {
  230.         float2(1.0, 1.0),
  231.         float2(0.0, -1.0),
  232.         float2(-1.0, 1.0),
  233.         float2(-1.0, -1.0),
  234.         float2(0.0, 1.0),
  235.         float2(0.0, -1.0),
  236.         float2(1.0, 0.0),
  237.         float2(-1.0, 0.0)
  238.     };
  239.  
  240.     for (int i=0; i<8; i++)
  241.     {
  242.         bloomuv.xy=offset[i]*4;
  243.         bloomuv.xy=texcoord.xy + bloomuv.xy;
  244.         float4 tempbloom=SampleLocation(bloomuv.xy);
  245.         bloom+=tempbloom;
  246.     }
  247.  
  248.     bloom *= 0.125;
  249.     SetOutput(bloom);
  250. }
  251.  
  252. void BloomPass2()
  253. {
  254.     float4 bloom=0.0;
  255.     float2 bloomuv;
  256.     float2 texcoord = GetCoordinates();
  257.  
  258.     float2 offset[8]=
  259.     {
  260.         float2(0.707, 0.707),
  261.         float2(0.707, -0.707),
  262.         float2(-0.707, 0.707),
  263.         float2(-0.707, -0.707),
  264.         float2(0.0, 1.0),
  265.         float2(0.0, -1.0),
  266.         float2(1.0, 0.0),
  267.         float2(-1.0, 0.0)
  268.     };
  269.  
  270.     for (int i=0; i<8; i++)
  271.     {
  272.         bloomuv.xy=offset[i]*8;
  273.         bloomuv.xy=texcoord.xy + bloomuv.xy;
  274.         float4 tempbloom=SampleLocation(bloomuv.xy);
  275.         bloom+=tempbloom;
  276.     }
  277.  
  278.     bloom *= 0.5; //to brighten up the sample, it will lose brightness in H/V gaussian blur
  279.     SetOutput(bloom);
  280. }
  281.  
  282. void BloomPass3()
  283. {
  284.     float4 bloom = 0.0;
  285.     float2 texcoord = GetCoordinates();
  286.     bloom = Gauss1dPrev2(texcoord, float2(1.0, 0.0), 16);
  287.     bloom.a *= GetOption(B_ANAMFLARE_AMOUNT);
  288.     bloom.xyz *= GetOption(B_BLOOM_AMOUNT);
  289.  
  290.     SetOutput(bloom);
  291. }
  292.  
  293. void BloomPass4()
  294. {
  295.     float4 bloom = 0.0;
  296.     float2 texcoord = GetCoordinates();
  297.     bloom.xyz = Gauss1dPrev2(texcoord, float2(0.0, 1.0), 16).xyz*2.5;
  298.     bloom.a = Gauss1dPrev2(texcoord, float2(1.0, 0.0), 32*GetOption(A_ANAMFLARE_WIDENESS)).a*2.5; //to have anamflare texture (bloom.w) avoid vertical blur
  299.     SetOutput(bloom);
  300. }
  301.  
  302. void BloomScatering()
  303. {
  304.     float2 SamplePos[20] = {
  305.         float2(0.25, 0.125),
  306.         float2(0.375, 0.125),
  307.         float2(0.5, 0.125),
  308.         float2(0.625, 0.125),
  309.         float2(0.75, 0.125),
  310.  
  311.         float2(0.25, 0.25),
  312.         float2(0.375, 0.25),
  313.         float2(0.5, 0.25),
  314.         float2(0.625, 0.25),
  315.         float2(0.75, 0.25),
  316.  
  317.         float2(0.25, 0.75),
  318.         float2(0.375, 0.75),
  319.         float2(0.5, 0.75),
  320.         float2(0.625, 0.75),
  321.         float2(0.75, 0.75),
  322.  
  323.         float2(0.25, 0.875),
  324.         float2(0.375, 0.875),
  325.         float2(0.5, 0.875),
  326.         float2(0.625, 0.875),
  327.         float2(0.75, 0.875),
  328.     };
  329.     float3 lumColor = GetOption(H_SCOLOR) * 3.0;
  330.     float samplecount = 3.0;
  331.     for (int i = 0; i < 20; i++)
  332.     {
  333.         float3 color = SamplePrevLocation(SamplePos[i]).rgb;
  334.         lumColor += color;
  335.         samplecount += 1.0;
  336.     }
  337.     lumColor /= samplecount;
  338.     float luma = dot(lumColor, lumCoeff);
  339.     float maxval = max(max(lumColor.r, lumColor.g), lumColor.b);
  340.     lumColor /= maxval;
  341.     SetOutput(float4(lumColor, luma * luma));
  342. }
  343.  
  344. void BloomMerger()
  345. {
  346.     float2 texcoord = GetCoordinates();
  347.     float4 basecolor = float4(0.0,0.0,0.0,0.0);
  348.     float3 colorbloom = float3(0.0,0.0,0.0);
  349.     float4 lumColor = SamplePrevLocation(float2(0.5, 0.5));
  350.     if (!OptionEnabled(A_BLOOMONLY))
  351.     {
  352.         basecolor = SampleInput(0);
  353.     }
  354.     float4 color = basecolor;
  355.  
  356.     colorbloom.xyz += SampleInputLocation(1,texcoord.xy).xyz*9.0;
  357.     colorbloom.xyz *= 0.1;
  358.  
  359.     colorbloom.xyz = saturate(colorbloom.xyz);
  360.     float colorbloomgray = dot(colorbloom.xyz, 0.333);
  361.     colorbloom.xyz = lerp(colorbloomgray, colorbloom.xyz, GetOption(B_BLOOM_SATURATION));
  362.     colorbloom.xyz *= GetOption(B_BLOOM_TINT);
  363.     float colorgray = dot(color.xyz, 0.333);
  364.  
  365.     if (GetOption(A_BLOOM_MIXMODE) == 1)
  366.     {
  367.         color.xyz = color.xyz + colorbloom.xyz;
  368.     }
  369.     else if (GetOption(A_BLOOM_MIXMODE) == 2)
  370.     {
  371.         color.xyz = 1-(1-color.xyz)*(1-colorbloom.xyz);
  372.     }
  373.     else if (GetOption(A_BLOOM_MIXMODE) == 3)
  374.     {
  375.         color.xyz = max(float3(0.0,0.0,0.0),max(color.xyz,lerp(color.xyz,(float3(1.0,1.0,1.0) - (float3(1.0,1.0,1.0) - saturate(colorbloom.xyz)) *(float3(1.0,1.0,1.0) - saturate(colorbloom.xyz * float3(1.0,1.0,1.0)))),float3(1.0,1.0,1.0))));
  376.     }
  377.     else if (GetOption(A_BLOOM_MIXMODE) == 4)
  378.     {
  379.         color.xyz = max(color.xyz, colorbloom.xyz);
  380.     }
  381.  
  382.     if (OptionEnabled(D_SCATTERRING))
  383.     {
  384.         float depth = SampleDepth();
  385.         float linearcomponent = (GetOption(G_SEND) - depth) / (GetOption(G_SEND) - GetOption(F_SSTART));
  386.         depth = depth * GetOption(E_SDENSITY);
  387.         lumColor.rgb = lerp(basecolor.rgb, lumColor.rgb, saturate(GetOption(I_SINTENSITY) + lumColor.a));
  388.         basecolor.rgb = lerp(lumColor.rgb, basecolor.rgb, clamp(linearcomponent / exp(depth * depth), 0.0, 1.0));
  389.     }
  390.  
  391.     color.rgb += basecolor.rgb;
  392.  
  393.     if (OptionEnabled(C_GAUSSIAN_ANAMFLARE))
  394.     {
  395.         float3 anamflare = SampleInputBicubic(1).w*2*GetOption(C_ANAMFLARE_COLOR);
  396.         color.xyz += pow(anamflare.xyz,1/GetOption(B_ANAMFLARE_CURVE));
  397.     }
  398.     SetOutput(color);
  399. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement