Comment 29 for bug 1406458

Revision history for this message
Jaspervdg (jaspervdg) wrote :

As Alvin Penner mentioned, the purpose of the code is explicitly to produce a vector of length 1, setting the gradient to zero does not accomplish this goal (the length is then zero). Also, the vectors should be uniformly distributed around the sphere, so setting the gradient to some arbitrary fixed value like (1,0) or (0,1) is also not really a suitable solution. The "default" way of solving this problem is called rejection sampling and basically consists of just trying until you get it "right", this works because it does not change the relative frequencies of values other than those that are thrown away. (To some extent, as Perlin recognized in later work, it would be even easier/better to just use a fixed SET of well-distributed vectors, but that is not really an option here, as it would break backwards compatibility.)

Anyway, given that the original behaviour was without a doubt unintentional, I went ahead and committed a (small) patch using rejection sampling. I tried it on the example given above, and the problem indeed disappeared. I also verified that normal feTurbulence rendering was not broken, by trying the example given in the spec (which still renders exactly as it should).