Skip to content

Commit

Permalink
shaders/sampling: avoid duplicating scale factor
Browse files Browse the repository at this point in the history
This was accidentally included once per sample, as a result of the
anti-ringing code.

See-Also: #217
  • Loading branch information
haasn committed Nov 12, 2023
1 parent 79377cd commit c02c40c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/shaders/sampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static void describe_filter(pl_shader sh, const struct pl_filter_config *cfg,
static void polar_sample(pl_shader sh, pl_filter filter,
ident_t tex, ident_t lut, ident_t radius,
int x, int y, uint8_t comp_mask, ident_t in,
bool use_ar, float scale)
bool use_ar, ident_t scale)
{
// Since we can't know the subpixel position in advance, assume a
// worst case scenario
Expand Down Expand Up @@ -535,7 +535,7 @@ static void polar_sample(pl_shader sh, pl_filter filter,
@if (use_ar) { \
if (d <= ${const float: ar_radius}) { \
@for (c : comp_mask) { \
cc = vec2(${float: scale} * c[@c]); \
cc = vec2($scale * c[@c]); \
cc.x = 1.0 - cc.x; \
ww = cc + vec2(0.10); \
ww = ww * ww; \
Expand Down Expand Up @@ -590,9 +590,9 @@ bool pl_shader_sample_polar(pl_shader sh, const struct pl_sample_src *src,
}

uint8_t cmask;
float rx, ry, scale;
ident_t src_tex, pos, pt;
if (!setup_src(sh, src, &src_tex, &pos, &pt, &rx, &ry, &cmask, &scale, false, FASTEST))
float rx, ry, scalef;
ident_t src_tex, pos, pt, scale;
if (!setup_src(sh, src, &src_tex, &pos, &pt, &rx, &ry, &cmask, &scalef, false, FASTEST))
return false;

struct sh_sampler_obj *obj;
Expand All @@ -605,6 +605,7 @@ bool pl_shader_sample_polar(pl_shader sh, const struct pl_sample_src *src,
inv_scale = PL_MAX(inv_scale, 1.0);
if (params->no_widening)
inv_scale = 1.0;
scale = sh_const_float(sh, "scale", scalef);

struct pl_filter_config cfg = params->filter;
cfg.antiring = PL_DEF(cfg.antiring, params->antiring);
Expand Down Expand Up @@ -872,7 +873,7 @@ bool pl_shader_sample_polar(pl_shader sh, const struct pl_sample_src *src,
}

#pragma GLSL \
color = ${float:scale} / wsum * color; \
color = $scale / wsum * color; \
@if (use_ar) { \
@for (c : cmask) { \
ww = ar@c / wwsum@c; \
Expand Down

0 comments on commit c02c40c

Please sign in to comment.