Skip to content

Conversation

@bacondither
Copy link
Contributor

No description provided.

iryoku/smaa pull request 11: Fix incorrect calculation of
local contrast adaption in color edge detection
Raise max limits for settings according to comments in SMAA.fxh
- FXAA_LINEAR_LIGHT, run FXAA in linear or gamma corrected light
- Fix luma pass gamma correction mismatch
float4 FXAALumaPass(float4 vpos : SV_Position, noperspective float2 texcoord : TEXCOORD) : SV_Target
{
float4 color = tex2D(ReShade::BackBuffer, texcoord.xy);
color.a = sqrt(dot(color.rgb*color.rgb, float3(0.299, 0.587, 0.114)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the square of the color?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lightness/luma weights should be multiplied with the color in linear light to be correct. It can be done in gamma light with some error but the speed difference is negligible.

Before, color was decoded with sRGB gamma and then encoded in the alpha channel with 1/2.0 gamma, resulting in slight error in lightness. Now its decoded with 2.0 gamma and encoded with 1/2.0 gamma.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I see. Didn't realize the change in the line right above.

// Calculate left-left and top-top deltas:
float3 Cleftleft = SMAASamplePoint(colorTex, offset[2].xy).rgb;
t = abs(C - Cleftleft);
t = abs(Cleft - Cleftleft);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this change does. It reduces the distance between the two samples the delta is calculated of, but why?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it helps but this is the commit for that particular change with explanation. :)
iryoku/smaa#11

Copy link
Contributor Author

@bacondither bacondither Sep 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under luma edge detection the Calculate left-left and top-top deltas are computed with left & leftleft and top & toptop pixels ( line 730 ). But for the Color Edge Detection it uses the center pixel instead of the left and top one.

Both ways cant be correct! Im not so sure anymore which one is correct, perhaps I should send a mail to Jorge Jimenez and ask politely.

@crosire crosire merged commit 17189f4 into crosire:master Sep 20, 2017
crosire added a commit that referenced this pull request Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants