Skip to content

Commit

Permalink
Add Src and Dest factors
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Apr 14, 2022
1 parent ad41b31 commit b367809
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace Shared_Resources_Bloom
OPTION(float, _Threshold, "Main", "Threshold", "drag", 1.0, 0.8)
OPTION(float, _Smooth, "Main", "Smoothing", "drag", 1.0, 0.5)
OPTION(float, _Saturation, "Main", "Saturation", "drag", 4.0, 1.0)
OPTION(float, _ColorShift, "Main", "Saturation", "drag", 1.0, 1.0)
OPTION(float3, _ColorShift, "Main", "Color shift", "color", 1.0, 1.0)
OPTION(float, _Intensity, "Main", "Color Intensity", "drag", 4.0, 1.0)

OPTION(float, _Level6Weight, "Level Weights", "Level 6", "drag", 2.0, 1.0)
Expand Down
10 changes: 5 additions & 5 deletions shaders/cFrameBlending.fx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ sampler2D Sample_Color
#endif
};

texture2D Render_Copy
texture2D Render_Blend
{
Width = BUFFER_WIDTH;
Height = BUFFER_HEIGHT;
Format = RGBA8;
};

sampler2D Sample_Copy
sampler2D Sample_Blend
{
Texture = Render_Copy;
Texture = Render_Blend;
MagFilter = LINEAR;
MinFilter = LINEAR;
MipFilter = LINEAR;
Expand All @@ -88,7 +88,7 @@ void Blend_PS(in float4 Position : SV_POSITION, in float2 Coord : TEXCOORD0, out
void Display_PS(in float4 Position : SV_POSITION, in float2 Coord : TEXCOORD0, out float4 OutputColor0 : SV_TARGET0)
{
// Display the buffer
OutputColor0 = tex2D(Sample_Copy, Coord);
OutputColor0 = tex2D(Sample_Blend, Coord);
}

technique cFrameBlending
Expand All @@ -97,7 +97,7 @@ technique cFrameBlending
{
VertexShader = Basic_VS;
PixelShader = Blend_PS;
RenderTarget0 = Render_Copy;
RenderTarget0 = Render_Blend;
ClearRenderTargets = FALSE;
BlendEnable = TRUE;
BlendOp = ADD;
Expand Down
21 changes: 14 additions & 7 deletions shaders/cSrcDestBlend.fx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,24 @@
uniform int _Blend <
ui_label = "Blend Mode";
ui_type = "combo";
ui_items = " Add\0 Subtract\0 Multiply\0 Min\0 Max\0 Screen\0 Lerp\0";
ui_items = " Add\0 Subtract\0 Multiply\0 Min\0 Max\0 Screen\0";
> = 0;

uniform float _Lerp_Weight <
uniform float _LerpWeight <
ui_label = "Lerp Weight";
ui_type = "slider";
> = 0.5;

uniform float _SrcFactor <
ui_label = "Source Factor";
ui_type = "drag";
> = 1.0;

uniform float _DestFactor <
ui_label = "Destination Factor";
ui_type = "drag";
> = 1.0;

texture2D Render_Color : COLOR;

sampler2D Sample_Color
Expand Down Expand Up @@ -93,8 +103,8 @@ void Blit_PS(in float4 Position : SV_POSITION, in float2 Coord : TEXCOORD0, out

void Blend_PS(in float4 Position : SV_POSITION, in float2 Coord : TEXCOORD0, out float4 OutputColor0 : SV_TARGET0)
{
float4 Src = tex2D(Sample_Copy, Coord);
float4 Dest = tex2D(Sample_Color, Coord);
float4 Src = tex2D(Sample_Copy, Coord) * _SrcFactor;
float4 Dest = tex2D(Sample_Color, Coord) * _DestFactor;

switch(_Blend)
{
Expand All @@ -116,9 +126,6 @@ void Blend_PS(in float4 Position : SV_POSITION, in float2 Coord : TEXCOORD0, out
case 5: // Screen
OutputColor0 = (Src + Dest) - (Src * Dest);
break;
case 6: // Lerp
OutputColor0 = lerp(Src, Dest, _Lerp_Weight);
break;
default:
OutputColor0 = Dest;
break;
Expand Down

0 comments on commit b367809

Please sign in to comment.