Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Common.fx"
- #if USE_PBB
- #pragma message "MassFX: Physically-Based Bloom Initialized\n"
- #define sclX (BUFFER_WIDTH*PBB_ResolutionScale)
- #define sclY (BUFFER_HEIGHT*PBB_ResolutionScale)
- namespace MassFX {
- texture tex1 { Width=sclX/2; Height=sclY/2; Format=RGBA16F; };
- texture tex2 { Width=sclX/4; Height=sclY/4; Format=RGBA16F; };
- texture tex3 { Width=sclX/8; Height=sclY/8; Format=RGBA16F; };
- texture tex4 { Width=sclX/16; Height=sclY/16; Format=RGBA16F; };
- texture tex5 { Width=sclX/32; Height=sclY/32; Format=RGBA16F; };
- texture tex6 { Width=sclX/64; Height=sclY/64; Format=RGBA16F; };
- texture tex7 { Width=sclX/128; Height=sclY/128; Format=RGBA16F; };
- texture tex8 { Width=sclX/256; Height=sclY/256; Format=RGBA16F; };
- sampler2D sTex1 { Texture=tex1; };
- sampler2D sTex2 { Texture=tex2; };
- sampler2D sTex3 { Texture=tex3; };
- sampler2D sTex4 { Texture=tex4; };
- sampler2D sTex5 { Texture=tex5; };
- sampler2D sTex6 { Texture=tex6; };
- sampler2D sTex7 { Texture=tex7; };
- sampler2D sTex8 { Texture=tex8; };
- float3 Blur(int scale, sampler2D sp, float2 srcCoord) {
- float3 col = float3(0,0,0);
- int c = 0;
- srcCoord /= scale;
- [loop]
- for(int i = 0; i < PBB_Samples+1; ++i) {
- for(int j = 0; j < PBB_Samples+1; ++j) {
- float2 coord = float2(i - PBB_Samples/2, j - PBB_Samples/2);
- coord.x /= BUFFER_WIDTH;
- coord.y /= BUFFER_HEIGHT;
- float2 fCoord = (srcCoord + coord) * scale;
- col += pow(saturate(tex2D(sp, fCoord)), PBB_Threshold).rgb;
- c += 1;
- }
- }
- return col/c;
- }
- float3 Downsample1(v2f i) : SV_Target {
- return Blur(2, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample2(v2f i) : SV_Target {
- return Blur(4, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample3(v2f i) : SV_Target {
- return Blur(8, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample4(v2f i) : SV_Target {
- return Blur(16, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample5(v2f i) : SV_Target {
- return Blur(32, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample6(v2f i) : SV_Target {
- return Blur(64, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample7(v2f i) : SV_Target {
- return Blur(128, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Downsample8(v2f i) : SV_Target {
- return Blur(256, ReShade::BackBuffer, i.uv).rgb;
- }
- float3 Main(v2f i) : SV_Target {
- return lerp(tex2D(ReShade::BackBuffer, i.uv), tex2D(ReShade::BackBuffer, i.uv)
- + tex2D(sTex1, i.uv)
- + tex2D(sTex2, i.uv)
- + tex2D(sTex3, i.uv)
- + tex2D(sTex4, i.uv)
- + tex2D(sTex5, i.uv)
- + tex2D(sTex6, i.uv)
- + tex2D(sTex7, i.uv)
- + tex2D(sTex8, i.uv)
- , PBB_Power).rgb;
- }
- technique PBB_Tech <bool enabled = RESHADE_START_ENABLED; int toggle = PBB_ToggleKey; > {
- pass d1 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample1;
- RenderTarget = tex1;
- }
- pass d2 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample2;
- RenderTarget = tex2;
- }
- pass d3 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample3;
- RenderTarget = tex3;
- }
- pass d4 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample4;
- RenderTarget = tex4;
- }
- pass d5 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample5;
- RenderTarget = tex5;
- }
- pass d6 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample6;
- RenderTarget = tex6;
- }
- pass d7 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample7;
- RenderTarget = tex7;
- }
- pass d8 {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Downsample8;
- RenderTarget = tex8;
- }
- pass main {
- VertexShader = ReShade::VS_PostProcess;
- PixelShader = Main;
- }
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement