Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jun 6, 2023
1 parent c3b76f7 commit 86bd940
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions shaders/cshade/cAutoExposure.fx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ uniform bool _Debug <
ui_type = "radio";
> = false;

CREATE_TEXTURE(LumaTex, int2(256, 256), RGBA8, 9)
CREATE_TEXTURE(LumaTex, int2(256, 256), R16F, 9)
CREATE_SAMPLER(SampleLumaTex, LumaTex, LINEAR, CLAMP)

/*
Expand Down Expand Up @@ -90,7 +90,7 @@ float4 PS_Blit(VS2PS_Quad Input) : SV_TARGET0
{
Tex = Expand(Tex);
Tex.x /= ASPECT_RATIO;
Tex = (Tex * _Scale) + _Offset;
Tex = (Tex * _Scale) + float2(_Offset.x, -_Offset.y);
Tex = Contract(Tex);
}

Expand All @@ -100,7 +100,7 @@ float4 PS_Blit(VS2PS_Quad Input) : SV_TARGET0
// OutputColor0.rgb = Output the highest brightness out of red/green/blue component
// OutputColor0.a = Output the weight for temporal blending
float Delay = 1e-3 * _Frametime;
return float4(Color.rgb, 1.0);
return float4(Color.rgb, saturate(Delay * _SmoothingSpeed));
}

float3 PS_Exposure(VS2PS_Quad Input) : SV_TARGET0
Expand All @@ -111,10 +111,19 @@ float3 PS_Exposure(VS2PS_Quad Input) : SV_TARGET0

if (_Debug)
{
float2 Pos = (Expand(Input.Tex0) - _Offset) * BUFFER_SIZE_0;
float Factor = 256.0 * (BUFFER_SIZE_0.y * (1.0 / 256.0));
bool Mask = all(step(abs(Pos), Factor * _Scale));
return lerp(ExposedColor.rgb, Color.rgb * 0.5, Mask).rgb;
// Unpack screen coordinates
float2 Pos = (Expand(Input.Tex0) - float2(_Offset.x, -_Offset.y)) * BUFFER_SIZE_0;
float Factor = BUFFER_SIZE_0.y * _Scale;

// Create the needed mask
bool Dot = all(step(abs(Pos), Factor * 0.1));
bool Mask = all(step(abs(Pos), Factor));

//
float3 Color1 = ExposedColor.rgb;
float3 Color2 = lerp(Dot * 2.0, Color.rgb, Mask * 0.5);

return lerp(Color1, Color2, Mask).rgb;
}
else
{
Expand Down

0 comments on commit 86bd940

Please sign in to comment.