Description of the problem
When hardware acceleration is disabled, sprites are not displayed on Chrome.
Should see a big rubber duck the following examples, while it’s all black on Chrome without HA.
Three.js version
- Dev
- r118
Browser
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
No graphic card (e.g. virtualized environment) or hardware acceleration set to off on Chrome.
The root of the problem is this line:
sprite.scale
is actually aVector3
, so it expects 3 arguments, but you’re passing 2.That results in:
Then,
sprite.matrix
becomes[50, 0, 0, 0, 0, 50, 0, 0, NaN, NaN, NaN, 0, 0, 0, 0, 1]
.Seems like SwiftShader (the renderer used when hardware acceleration is disabled) breaks when passing NaNs.
I think the solution here is to implement more default parameters:
Another solution would be to try to do
this.scale = new Vector2()
in theSprite
constructor…@mrdoob I assume this is a vertex transform matrix, passed directly to the shaders as a uniform variable? For the API side, the following spec quote applies:
As for how they should be handled by GLSL shaders:
It’s not clear to me that SwiftShader “breaks” when passing it NaNs. It’s quite likely that it propagates NaNs in a more IEEE 754 recommended manner, while most GPUs treat them as zero, or inifinity, and this just-so-happens to produce a more desirable output. But it can fail at any time on GPUs or drivers that adhere more closely to IEEE 754. It would be great if someone could take a deeper look at where things start to deviate from expectations.
In any case, one should avoid NaNs to achieve reliable results.
@Mugen87 While this currently uses the OpenGL ES driver implementation, SwiftShader has a certified conformant Vulkan 1.1 implementation for the CPU. If something doesn’t work it’s not uncommon to be an application or engine bug. If a SwiftShader bug is suspected, please file an issue.