BGFX / Babylon Native bug when using float vertex buffer shader attribute?

@BabylonNative @Cedric @bghgary
I’m not entirely sure this is a bug, but it’s certainly a difference between Babylon.js and Babylon Native.

I was trying to get @roland’s cool new greased line code working in Babylon React Native, but it kept crashing with the following error (in Android):

After much trial and error investigation using one of the simplest of Roland’s tests (pbrDemo()), I was able to determine that attribute float side was the cause of the crash. This side vertex buffer is defined and populated in GreasedLine.ts:

It works after changing from a float to a vec2 throughout like so:

image

image

image

Sorry for the mess of screenshots above, but hopefully it conveys the issue.

Is this a known limitation of BGFX or a bug?

1 Like

It was not a known limitation but at the same time, I’m not really surprised. It’s an uncommon case with just 1 float attribute. It’s never been tested AFAIK.

I’m opening an issue for that. crash with 1-float attribute vertex stream · Issue #1175 · BabylonJS/BabylonNative · GitHub

3 Likes

Thanks @Cedric! Much appreciated.

1 Like

After doing some investigation on this, it turn out the problem is not the float vertex buffer. For some reason glslang does not parse a vector multiplication by a float correctly.

If “attribute float side” is used to create a vector “vec2 sideV = vec(side, side);” and than used for multiplying the other vectors it works properly.

I will do some more investigation to see if the was eventually fixed in a more recent version of glslang.

2 Likes

@srzerbetto sorry for the delayed response. I can confirm your solution works in our codebase, thanks!

2 Likes