Sprites are not being rendered for ios14 and lower

Hello, community!
I noticed that spritesheet animations are broken on ios14 and lower.

BJS - [14:48:21]: Error: FRAGMENT SHADER ERROR: 0:8: Expression of type 'float' - precision can not be inferred and no default precision available
(anonymous function) — logger.ts:103
(anonymous function)
(anonymous function) — effect.ts:919
(anonymous function) — effect.ts:614
(anonymous function) — effect.ts:848
(anonymous function) — effect.ts:439
(anonymous function) — effect.ts:375
(anonymous function) — shaderProcessor.ts:42
(anonymous function) — shaderProcessor.ts:454
(anonymous function) — shaderProcessor.ts:37
C — effect.ts:366
(anonymous function) — effect.ts:401
(anonymous function) — effect.ts:659
e — effect.ts:398
(anonymous function) — thinEngine.ts:2830
e — spriteRenderer.ts:165
e — spriteManager.ts:284
createScene — Script Element 1:15
(anonymous function) — Script Element 1:36
(anonymous function)

Tested it using the Xcode simulator and on a real device. It doesn’t seem to be a WebGL version issue. I tried it on ios 16 with WebGL 1 and everything works fine there.

This is the original playground that doesn’t work https://playground.babylonjs.com/#YCY2IL#4

It seems like this line is an issue. core/src/Shaders/sprites.fragment.fx#L21

if (float(alphaTest) != 0.)

I moved type casting to a separate line and it fixed the issue.


Hi and welcome to the Community,
What a nice finding and then with the fix already on your first post.
Your contribution will be very welcomed here for everyone struggling with iOS (and we all do) @RaananW :wink:
Thanks again for sharing and have a great day :sunglasses:

Can’t wait for the PR :slight_smile:

:rocket::rocket::rocket: Fix for sprite rendering for ios 14 and lower by Vlad160 · Pull Request #13504 · BabylonJS/Babylon.js · GitHub


Thanks so much @Vlad160 !!!

1 Like