W3C home > Mailing lists > Public > public-fxtf-archive@w3.org > February 2017

[fxtf-drafts] [filter-effects] Browsers don't match spec for feDisplacementMap

From: Amelia Bellamy-Royds via GitHub <sysbot+gh@w3.org>
Date: Sat, 25 Feb 2017 00:08:50 +0000
To: public-fxtf-archive@w3.org
Message-ID: <issues.opened-210190534-1487981329-sysbot+gh@w3.org>
AmeliaBR has just created a new issue for 
https://github.com/w3c/fxtf-drafts:

== [filter-effects] Browsers don't match spec for feDisplacementMap ==
The [spec for 
`feDisplacementMap`](https://drafts.fxtf.org/filters/#feDisplacementMapElement)
 says:

> This filter primitive uses the pixels values from the image from in2
 to spatially displace the image from in. This is the transformation 
to be performed:
>
>    P'(x,y) ← P( x + scale * (XC(x,y) - .5), y + scale * (YC(x,y) - 
.5))
>
>where P(x,y) is the input image, in, and P'(x,y) is the destination. 
XC(x,y) and YC(x,y) are the component values of the channel designated
 by the xChannelSelector and yChannelSelector. For example, to use the
 R component of in2 to control displacement in x and the G component 
of Image2 to control displacement in y, set xChannelSelector to "R" 
and yChannelSelector to "G".
>
> The displacement map, in2, defines the inverse of the mapping 
performed.
>
> The input image in is to remain premultiplied for this filter 
primitive. The calculations using the pixel values from in2 are 
performed using non-premultiplied color values.

If I'm reading that correctly, I would expect that, when 
`xChannelSelector` and `yChannelSelector` are R,G,or B:

- If the input map is solid white, the filtered graphic would be 
displaced in negative x&y directions by 0.5*scale.
- If the input map is solid black, the filtered graphic would be 
displaced in a positive x&y directions by 0.5*scale.
- If the input map is solid 50% gray (#888 if 
color-interpolation-filters is linearRGB), the filtered graphic would 
not be displaced at all.

If the input map is partially transparent, I'm not quite sure what 
should happen next.  It depends on whether "premultiplied" only 
applies to scaling the color channel range, or whether it also 
includes scaling by alpha.  If we do not scale the color channels by 
the alpha, then the alpha value should not have any effect unless the 
value of  `xChannelSelector` or `yChannelSelector` is `A`.  This is 
what I would expect as an author.

If you do scale the color channels by alpha, which I think is a more 
literal reading of the spec, then I would expect:

- 50% opaque white to have the same effect as 50% solid gray, i.e. no 
displacement.
- 50% opaque/50% gray input to have the same effect as 25% solid gray,
 aka positive displacement by 0.25*scale.
- fully transparent (0% opaque) input to have the same effect as solid
 black, i.e. positive displacement by 0.5*scale.

None of the browsers tested (Chrome 56, Firefox 53, and Edge 14) lead 
to any of these sets of expected results.

Solid black and white input are treated as expected in all browsers: 
displacement by half the scale factor, in opposing directions.  But a 
50% gray input in all browsers _does_ displace the image, halfway the 
distance of the displacement for a solid black input.

Chrome and Firefox treat a 50% transparent input the same as a solid 
input of the same color, but treat a completely transparent input the 
same as solid black.  MS Edge linearly scales the amount of 
displacement by the alpha of the input color.

[CodePen test case](http://codepen.io/AmeliaBR/pen/ZeYBZb/)

Please view or discuss this issue at 
https://github.com/w3c/fxtf-drafts/issues/113 using your GitHub 
account
Received on Saturday, 25 February 2017 00:08:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 November 2018 00:45:57 UTC