Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [OptionBool]
- GUIName = Bloom
- OptionName = C_BLOOM
- DefaultValue = true
- [OptionBool]
- GUIName = Bloom Only
- OptionName = A_BLOOMONLY
- DefaultValue = false
- DependentOption = C_BLOOM
- GUIDescription = Only show Bloom effects. (Testing purposes)
- [OptionRangeInteger]
- GUIName = Mix Mode
- OptionName = A_BLOOM_MIXMODE
- MinValue = 1
- MaxValue = 4
- StepAmount = 1
- DefaultValue = 2
- DependentOption = C_BLOOM
- GUIDescription = 1 = Linear add | 2 = Screen add | 3 = Screen/Lighten/Opacity | 4 = Lighten
- [OptionRangeFloat]
- GUIName = Threshold
- OptionName = A_BLOOM_THRESHOLD
- MinValue = 0.01
- MaxValue = 1.00
- StepAmount = 0.01
- DefaultValue = 0.80
- DependentOption = C_BLOOM
- GUIDescription = Every pixel brighter than this value triggers bloom.
- [OptionRangeFloat]
- GUIName = Amount
- OptionName = B_BLOOM_AMOUNT
- MinValue = 0.0
- MaxValue = 20.0
- StepAmount = 0.1
- DefaultValue = 0.8
- DependentOption = C_BLOOM
- GUIDescription = Intensity of bloom.
- [OptionRangeFloat]
- GUIName = Saturation
- OptionName = B_BLOOM_SATURATION
- MinValue = 0.00
- MaxValue = 2.00
- StepAmount = 0.01
- DefaultValue = 0.80
- DependentOption = C_BLOOM
- GUIDescription = Bloom saturation. 0.0 means white bloom, 2.0 means very very colorful bloom.
- [OptionRangeFloat]
- GUIName = Tint
- OptionName = B_BLOOM_TINT
- MinValue = 0.00, 0.00, 0.00
- MaxValue = 1.00, 1.00, 1.00
- StepAmount = 0.01, 0.01, 0.01
- DefaultValue = 0.70, 0.80, 1.00
- DependentOption = C_BLOOM
- GUIDescription = R, G and B components of bloom tintcolor the bloom color gets shifted to.
- [OptionBool]
- GUIName = Light Scattering
- OptionName = D_SCATTERRING
- DefaultValue = True
- DependentOption = C_BLOOM
- [OptionRangeFloat]
- GUIName = Density
- OptionName = E_SDENSITY
- MinValue = 0.0
- MaxValue = 1.0
- StepAmount = 0.01
- DefaultValue = 0.17
- DependentOption = C_BLOOM
- [OptionRangeFloat]
- GUIName = Start
- OptionName = F_SSTART
- MinValue = 0.0
- MaxValue = 0.5
- StepAmount = 0.01
- DefaultValue = 0.05
- DependentOption = C_BLOOM
- [OptionRangeFloat]
- GUIName = End
- OptionName = G_SEND
- MinValue = 0.5
- MaxValue = 2.0
- StepAmount = 0.01
- DefaultValue = 2.0
- DependentOption = C_BLOOM
- [OptionRangeFloat]
- GUIName = Default Color
- OptionName = H_SCOLOR
- MinValue = 0.1, 0.1, 0.1
- MaxValue = 1.0, 1.0, 1.0
- StepAmount = 0.01, 0.01, 0.01
- DefaultValue = 0.91, 0.52, 1
- DependentOption = C_BLOOM
- [OptionRangeFloat]
- GUIName = Scattering Intensity
- OptionName = I_SINTENSITY
- MinValue = 0.0
- MaxValue = 1.0
- StepAmount = 0.01
- DefaultValue = 0.36
- DependentOption = C_BLOOM
- [Pass]
- EntryPoint = BloomPrePass
- DependantOption = C_BLOOM
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- [Pass]
- EntryPoint = BloomPass1
- DependantOption = C_BLOOM
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- [Pass]
- EntryPoint = BloomPass2
- DependantOption = C_BLOOM
- OutputScale = 0.5
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- [Pass]
- EntryPoint = BloomPass3
- DependantOption = C_BLOOM
- OutputScale = 0.25
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- Input1=DepthBuffer
- Input1Filter=Nearest
- Input1Mode=Clamp
- [Pass]
- EntryPoint = BloomPass4
- DependantOption = C_BLOOM
- OutputScale = 0.125
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- Input1=DepthBuffer
- Input1Filter=Nearest
- Input1Mode=Clamp
- [Pass]
- EntryPoint = BloomScatering
- DependantOption = C_BLOOM
- OutputScale = 0.03125
- Input0=PreviousPass
- Input0Filter=Linear
- Input0Mode=Clamp
- [Pass]
- EntryPoint = BloomMerger
- DependantOption = C_BLOOM
- Input0=Pass9
- Input0Filter=Linear
- Input0Mode=Clamp
- Input1=Pass14
- Input1Filter=Linear
- Input1Mode=Clamp
- Input2=PreviousPass
- Input2Filter=Linear
- Input2Mode=Clamp
- Input3=DepthBuffer
- Input3Filter=Nearest
- Input3Mode=Clamp
- float4 Gauss1dPrev2(float2 coord, float2 axis, float mult)
- {
- float4 sum = 0;
- 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 };
- axis *= GetInvResolution() * mult;
- for (int i = -10; i < 11; i++)
- {
- float currweight = weight[abs(i)];
- sum += SamplePrevLocation(coord.xy + axis.xy * (float)i) * currweight;
- }
- return sum;
- }
- //------------------------------------------------------------------------------
- // BLOOM
- //------------------------------------------------------------------------------
- void BloomPrePass()
- {
- float4 bloom=0.0;
- float2 bloomuv;
- float2 texcoord = GetCoordinates();
- float2 offset[4]=
- {
- float2(1.0, 1.0),
- float2(1.0, 1.0),
- float2(-1.0, 1.0),
- float2(-1.0, -1.0)
- };
- for (int i=0; i<4; i++)
- {
- bloomuv.xy=offset[i]*2;
- bloomuv.xy=texcoord.xy + bloomuv.xy;
- float4 tempbloom = SampleLocation(bloomuv.xy);
- tempbloom.a = max(0,dot(tempbloom.xyz,float3(0.333,0.333,0.333))-GetOption(A_ANAMFLARE_THRESHOLD));
- tempbloom.xyz = max(float3(0,0,0), tempbloom.xyz-GetOption(A_BLOOM_THRESHOLD));
- bloom+=tempbloom;
- }
- bloom *= 0.25;
- SetOutput(bloom);
- }
- void BloomPass1()
- {
- float4 bloom=0.0;
- float2 bloomuv;
- float2 texcoord = GetCoordinates();
- float2 offset[8]=
- {
- float2(1.0, 1.0),
- float2(0.0, -1.0),
- float2(-1.0, 1.0),
- float2(-1.0, -1.0),
- float2(0.0, 1.0),
- float2(0.0, -1.0),
- float2(1.0, 0.0),
- float2(-1.0, 0.0)
- };
- for (int i=0; i<8; i++)
- {
- bloomuv.xy=offset[i]*4;
- bloomuv.xy=texcoord.xy + bloomuv.xy;
- float4 tempbloom=SampleLocation(bloomuv.xy);
- bloom+=tempbloom;
- }
- bloom *= 0.125;
- SetOutput(bloom);
- }
- void BloomPass2()
- {
- float4 bloom=0.0;
- float2 bloomuv;
- float2 texcoord = GetCoordinates();
- float2 offset[8]=
- {
- float2(0.707, 0.707),
- float2(0.707, -0.707),
- float2(-0.707, 0.707),
- float2(-0.707, -0.707),
- float2(0.0, 1.0),
- float2(0.0, -1.0),
- float2(1.0, 0.0),
- float2(-1.0, 0.0)
- };
- for (int i=0; i<8; i++)
- {
- bloomuv.xy=offset[i]*8;
- bloomuv.xy=texcoord.xy + bloomuv.xy;
- float4 tempbloom=SampleLocation(bloomuv.xy);
- bloom+=tempbloom;
- }
- bloom *= 0.5; //to brighten up the sample, it will lose brightness in H/V gaussian blur
- SetOutput(bloom);
- }
- void BloomPass3()
- {
- float4 bloom = 0.0;
- float2 texcoord = GetCoordinates();
- bloom = Gauss1dPrev2(texcoord, float2(1.0, 0.0), 16);
- bloom.a *= GetOption(B_ANAMFLARE_AMOUNT);
- bloom.xyz *= GetOption(B_BLOOM_AMOUNT);
- SetOutput(bloom);
- }
- void BloomPass4()
- {
- float4 bloom = 0.0;
- float2 texcoord = GetCoordinates();
- bloom.xyz = Gauss1dPrev2(texcoord, float2(0.0, 1.0), 16).xyz*2.5;
- 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
- SetOutput(bloom);
- }
- void BloomScatering()
- {
- float2 SamplePos[20] = {
- float2(0.25, 0.125),
- float2(0.375, 0.125),
- float2(0.5, 0.125),
- float2(0.625, 0.125),
- float2(0.75, 0.125),
- float2(0.25, 0.25),
- float2(0.375, 0.25),
- float2(0.5, 0.25),
- float2(0.625, 0.25),
- float2(0.75, 0.25),
- float2(0.25, 0.75),
- float2(0.375, 0.75),
- float2(0.5, 0.75),
- float2(0.625, 0.75),
- float2(0.75, 0.75),
- float2(0.25, 0.875),
- float2(0.375, 0.875),
- float2(0.5, 0.875),
- float2(0.625, 0.875),
- float2(0.75, 0.875),
- };
- float3 lumColor = GetOption(H_SCOLOR) * 3.0;
- float samplecount = 3.0;
- for (int i = 0; i < 20; i++)
- {
- float3 color = SamplePrevLocation(SamplePos[i]).rgb;
- lumColor += color;
- samplecount += 1.0;
- }
- lumColor /= samplecount;
- float luma = dot(lumColor, lumCoeff);
- float maxval = max(max(lumColor.r, lumColor.g), lumColor.b);
- lumColor /= maxval;
- SetOutput(float4(lumColor, luma * luma));
- }
- void BloomMerger()
- {
- float2 texcoord = GetCoordinates();
- float4 basecolor = float4(0.0,0.0,0.0,0.0);
- float3 colorbloom = float3(0.0,0.0,0.0);
- float4 lumColor = SamplePrevLocation(float2(0.5, 0.5));
- if (!OptionEnabled(A_BLOOMONLY))
- {
- basecolor = SampleInput(0);
- }
- float4 color = basecolor;
- colorbloom.xyz += SampleInputLocation(1,texcoord.xy).xyz*9.0;
- colorbloom.xyz *= 0.1;
- colorbloom.xyz = saturate(colorbloom.xyz);
- float colorbloomgray = dot(colorbloom.xyz, 0.333);
- colorbloom.xyz = lerp(colorbloomgray, colorbloom.xyz, GetOption(B_BLOOM_SATURATION));
- colorbloom.xyz *= GetOption(B_BLOOM_TINT);
- float colorgray = dot(color.xyz, 0.333);
- if (GetOption(A_BLOOM_MIXMODE) == 1)
- {
- color.xyz = color.xyz + colorbloom.xyz;
- }
- else if (GetOption(A_BLOOM_MIXMODE) == 2)
- {
- color.xyz = 1-(1-color.xyz)*(1-colorbloom.xyz);
- }
- else if (GetOption(A_BLOOM_MIXMODE) == 3)
- {
- 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))));
- }
- else if (GetOption(A_BLOOM_MIXMODE) == 4)
- {
- color.xyz = max(color.xyz, colorbloom.xyz);
- }
- if (OptionEnabled(D_SCATTERRING))
- {
- float depth = SampleDepth();
- float linearcomponent = (GetOption(G_SEND) - depth) / (GetOption(G_SEND) - GetOption(F_SSTART));
- depth = depth * GetOption(E_SDENSITY);
- lumColor.rgb = lerp(basecolor.rgb, lumColor.rgb, saturate(GetOption(I_SINTENSITY) + lumColor.a));
- basecolor.rgb = lerp(lumColor.rgb, basecolor.rgb, clamp(linearcomponent / exp(depth * depth), 0.0, 1.0));
- }
- color.rgb += basecolor.rgb;
- if (OptionEnabled(C_GAUSSIAN_ANAMFLARE))
- {
- float3 anamflare = SampleInputBicubic(1).w*2*GetOption(C_ANAMFLARE_COLOR);
- color.xyz += pow(anamflare.xyz,1/GetOption(B_ANAMFLARE_CURVE));
- }
- SetOutput(color);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement