Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZoomBlurFilter problem on iOS device #170

Closed
jcyuan opened this issue Nov 2, 2018 · 3 comments
Closed

ZoomBlurFilter problem on iOS device #170

jcyuan opened this issue Nov 2, 2018 · 3 comments

Comments

@jcyuan
Copy link
Contributor

jcyuan commented Nov 2, 2018

Actually the same problem with #139 .
apply ZoomBlurFilter and change its strength, the result on iOS is wrong (works well on Android), it's displayed with some part turns white... see picture below:

aaaaa

@jcyuan
Copy link
Contributor Author

jcyuan commented Nov 2, 2018

the bottom of the picture is normal though...

@jcyuan
Copy link
Contributor Author

jcyuan commented Nov 3, 2018

I think I found the exact reason, it's probably caused by the sin, this function in different platform (chip) will have different results especially when call it with a big float number. so if a shader needs to use noise (random), you have to use a solution which can give you a predictable result.

I'm on this right now, will give my feedback soon.

@jcyuan
Copy link
Contributor Author

jcyuan commented Nov 4, 2018

It's confirmed that the problem is caused by the 'sin method. here I can only give suggestions that to use some libraries, but as you know I can't give a promise that they are the best ones with great performance etc...
what we need to do is to replace the random function with a safer one.

libraries:

https://github.com/ashima/webgl-noise
this one has both texture-using (random sampling) version or textureless version.

this is what the author says:

The new version by Ian McEwan of Ashima and myself does not use a texture but runs at around half the speed on typical desktop platforms with lots of texture bandwidth. On mobile platforms, the textureless version might be faster because texturing is often a significant bottleneck.

the random function actually is used for pixel interpolation with a random sample from the original picture if you set a very big value (say 10 or above) for the `strength' uniform.

see this picture:
blur pics

the first part is a sprite with a blur filter set strength to 10 and random pixel interpolation disabled, as you can see, some artifacts of rectangle shapes there.
to disable the random pixel interpolation just set the offset to 0 at zoom-blur.frag line 55:
float offset = 0.0; // random(vec3(12.9898, 78.233, 151.7182), 0.0);
and the second one is with the function enabled.

so the solution is simple:

  1. for the users who don't need a very big strength: directly remove the random function and set offset to 0 (even better performance), and make sure to always set strength with a number in a safe range (I tested 0 to 1.5 is ok for me), see the below picture, this one I set strength to 0.7 (I think this is ok for most people? )
    blur with strength = 0.7

  2. if you really need a high strength, take a look into the libraries above and integrate it into the shader to take the place of the old random function.

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

No branches or pull requests

1 participant