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

Perlin and simplex noises (fbm) gets abruptly cut off on Android devices. #1

Open
luigimannoni opened this issue May 15, 2021 · 10 comments
Labels
bug Something isn't working demo Issues related to the demo. help wanted Extra attention is needed

Comments

@luigimannoni
Copy link

As per title, looks like the lower heights for perlin and simplex noises gets all cutted off on mobile devices.

Ridge noise does not work at all (displays a black plane if I switch on 2d mode)

Using a OnePlus 6T with Android 10

Screenshot_20210515-084133~2
Screenshot_20210515-084149~2

@FarazzShaikh
Copy link
Owner

FarazzShaikh commented May 15, 2021

Can you provide your Browser name and version number please?

It works perfectly on my iPhone 12 iOS 14.5 with Safari.

7149EEB6-58AF-4B30-ADD1-FD1C6FBCECDE

👆 Ridge noise

3CA16C01-375C-49A6-8E20-619B5BDB0AF7

👆 Simplex Noise

edit: I have asked more people, OnePlus phones seems to cause this issue, whereas it works fine on Samsung phones. Very weird.

@luigimannoni
Copy link
Author

Sure: using Chrome/90.0.4430.210 on a stock ROM.

It's the first time I'm witnessing something like this happening, for example this noise shader works fine on the device https://www.shadertoy.com/view/Msf3WH

@FarazzShaikh
Copy link
Owner

I’ll investigate

@FarazzShaikh
Copy link
Owner

Can you try running a more complex shadertoy? Maybe this one: https://www.shadertoy.com/view/tsXBzM

@luigimannoni
Copy link
Author

Sure, here's the screenshot:

Screenshot_20210515-102224~2

Video capture: https://webm.red/view/X6pI.webm

@FarazzShaikh FarazzShaikh added bug Something isn't working help wanted Extra attention is needed labels May 15, 2021
@FarazzShaikh
Copy link
Owner

I do not own an android device. I will work with a friend to get this resolved.

However, in the meantime you can fork this repo and host the example locally, then access it with your phone, then try to change the resolution of the plane to something smaller. See if that fixes it?

@FarazzShaikh FarazzShaikh added the demo Issues related to the demo. label May 15, 2021
@FarazzShaikh
Copy link
Owner

We have narrowed it down to gln_sfbm in src/Simplex.glsl

float noiseVal = gln_simplex(p);

When turbulence is set to true, hence taking the absolute value of the noise, it renders fine. Seems to cause issues when turbulence is set to false.

Also, RIdge noise seems to work.

Device: Oneplus Nord, Android 12, Chrome

@luigimannoni
Copy link
Author

This comment comes a bit late, I've forked the repo and tested yesterday as you asked but with no luck.

Set the turbulence to false solves the issue on the phone but the ridge noise doesn't have, well, ridges anymore :/
I tried to replace the simplex noise shader function with other implementations I found on github and the internet but all of those display the same issue.

I found other people experienced the same issue here:

https://stackoverflow.com/questions/41142911/inaccurate-shader-precision-on-android-compared-to-webgl
https://stackoverflow.com/questions/38276744/perlin-noise-bugged-at-some-devices-android-glsl

However changing the precision to highp doesn't solve the problem, or I am editing the wrong file, unfortunately my knowledge of glsl is very limited and close to none, so I am not quite sure where/what to change.

@FarazzShaikh
Copy link
Owner

FarazzShaikh commented May 16, 2021

glNoise already uses high precision floats

const _Head = "precision highp float;\n" + _Common + "\n";

You can try changing this line to use mediump in place of highp and see if that fixes it just in case some android devices don’t support high precision floats.

Remember to rebuild the library after you edit the file with npm run build

If that doesn’t fix it then the issue might be with the FBM functions. Can you try replacing the fBm functions with another implementation you find online?

Thank you for helping out 😄

@FarazzShaikh
Copy link
Owner

Update: glNoise no longer specifies the precision. it is left to the user. However, this issue still seems to persist.

Will leave this open as I do not have a device that the bug affects.

@FarazzShaikh FarazzShaikh changed the title Perlin and simplex noises (fbm) gets abruptly cut off on mobile, ridge noise does not work Perlin and simplex noises (fbm) gets abruptly cut off on Android devices. Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working demo Issues related to the demo. help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants