Need help with masking bloom effects
- klotim
- Topic Author
Less
More
5 years 4 months ago - 5 years 4 months ago #1
by klotim
Need help with masking bloom effects was created by klotim
Hey!
Im looking for some code guru that can help me with masking bloom so it wont affect hud. I'm aware of UI mask and it works but the bloom is still applied so the "aura" is outside the mask. I would do it myself if I knew how to do it.
Anyone that would like to help please?
You can see it here:
As you can see, the UI on the bottom is masked, but the bloom is still processed.
Im looking for some code guru that can help me with masking bloom so it wont affect hud. I'm aware of UI mask and it works but the bloom is still applied so the "aura" is outside the mask. I would do it myself if I knew how to do it.
Anyone that would like to help please?
You can see it here:
As you can see, the UI on the bottom is masked, but the bloom is still processed.
Last edit: 5 years 4 months ago by klotim.
Please Log in or Create an account to join the conversation.
- klotim
- Topic Author
Less
More
5 years 4 months ago - 5 years 4 months ago #2
by klotim
Replied by klotim on topic Need help with masking bloom effects
There is no bloom shaders that uses ui mask right? It's been asked soooo many times already.
Last edit: 5 years 4 months ago by klotim.
Please Log in or Create an account to join the conversation.
- Daodan
Less
More
5 years 4 months ago - 5 years 4 months ago #3
by Daodan
Replied by Daodan on topic Need help with masking bloom effects
Just wrote a small generic shader that should do the trick. This is more of a workaround than a solution; masking in the bloom shader itself would definitely be better. As it is unknowable what kind of math the bloom shader uses to apply the bloom the mask should only be black and white (no gradients), otherwise it looks bad. Just place the PreBloom technique right before the bloom and the PostBloom technique right after it.
Here the left part of the bar is masked the right is not:
Here the left part of the bar is masked the right is not:
Warning: Spoiler!
#include "ReShade.fxh"
uniform int Readme <
ui_type = "combo";
ui_items = "Add BLOOM_MASK_NAME=\"name\" to settings.";
> = 0;
namespace BloomMask {
texture2D texBloomMask < source=BLOOM_MASK_NAME; > { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
sampler2D sBloomMask { Texture = texBloomMask; };
texture2D texBloomMask_Backup { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };
sampler2D sBloomMask_Backup { Texture = texBloomMask_Backup; };
void PreBloomBackupPS(float4 vpos : SV_Position, float2 texcoord : TexCoord, out float3 backup : SV_Target0) {
//Save the original backbuffer
backup = tex2D(ReShade::BackBuffer, texcoord).rgb;
}
void PreBloomPS(float4 vpos : SV_Position, float2 texcoord : TexCoord, out float3 masked : SV_Target0) {
//Set everything that should be masked to black
masked = lerp(0.0.rrr, tex2D(ReShade::BackBuffer, texcoord).rgb, tex2Dfetch(sBloomMask, int4(vpos.xy, 0, 0)).r);
}
float3 PostBloomPS(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
//merge original and bloomed backbuffer
return lerp(tex2Dfetch(sBloomMask_Backup, int4(vpos.xy, 0, 0)).rgb, tex2Dfetch(ReShade::BackBuffer, int4(vpos.xy, 0, 0)).rgb, tex2Dfetch(sBloomMask, int4(vpos.xy, 0, 0)).r);
}
float3 ShowBloomMaskPS(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
return tex2Dfetch(sBloomMask, int4(vpos.xy, 0, 0)).rrr;
}
}
technique PreBloom {
pass {
VertexShader = PostProcessVS;
PixelShader = BloomMask::PreBloomBackupPS;
RenderTarget0 = BloomMask::texBloomMask_Backup;
}
pass {
VertexShader = PostProcessVS;
PixelShader = BloomMask::PreBloomPS;
}
}
technique PostBloom {
pass {
VertexShader = PostProcessVS;
PixelShader = BloomMask::PostBloomPS;
}
}
technique ShowBloomMask {
pass {
VertexShader = PostProcessVS;
PixelShader = BloomMask::ShowBloomMaskPS;
}
}
Last edit: 5 years 4 months ago by Daodan.
The following user(s) said Thank You: klotim
Please Log in or Create an account to join the conversation.
- klotim
- Topic Author
Less
More
wow it works! Thank you!!!
You should submit this one!
You should submit this one!
Please Log in or Create an account to join the conversation.
- crosire
Less
More
You can use two passes in the same technique instead of two techniques though.Daodan wrote: There are two pre-bloom techniques because rendering to a texture and the backbuffer simultaneously is not possible.
Please Log in or Create an account to join the conversation.
- Daodan
Less
More
crosire wrote: You can use two passes in the same technique instead of two techniques though.
Oh, right! I don't know why I haven't done that... embarrassing...
Please Log in or Create an account to join the conversation.
- Edgarska
Less
More
3 years 5 months ago - 3 years 5 months ago #7
by Edgarska
Replied by Edgarska on topic Need help with masking bloom effects
Edit: I screwed up, it is working still.
Last edit: 3 years 5 months ago by Edgarska. Reason: Mistake
Please Log in or Create an account to join the conversation.