Babylon Native custom shader texture sampler inverted in iOS?

In our Babylon React Native app I have a shader in a custom material plugin that uses a texture sampler to lookup vertex color, but the vertical texture coordinate seems to get inverted when the app is built for iOS compared to Android. Anyone know why this might be the case and if there’s a workaround or trick?

I should mention, I’m not using the mesh texture coords, I’m calculating a texCoord.V in the shader based on a number I pass in.

@BabylonNative

It makes sense. texture look up in inverted in V between opengl/webgl and all the other APIs.
The trick used in BN is to flip the texture sampling. It looks like this inversion is not done per vertex shader.

So, you should be able to repro the issue with babylonnative. Then, when you do, check that replacing this line :

with

ShaderCompiler::BgfxShaderInfo shaderInfo = m_shaderCompiler.Compile(ProcessSamplerFlip(ProcessShaderCoordinates(vertexSource)), ProcessSamplerFlip(fragmentSource));

should fix the problem.
If it does, you can do a PR and I’ll take care to update BRN

1 Like

Thanks @Cedric

I’ve never modified BN source but I’ll give it a go :crossed_fingers:

IMHO, it’s easier to test/debug with BN. There are not so many layers and you can debug more easily.
Ping me if you have an issue building it.

1 Like

Hi @inteja
Any news on this front?

Sorry no not yet. I haven’t had an opportunity this sprint to test it out. Until I can, I just added a temporary workaround sending an inverted texCoord.V to the shader if iOS.

1 Like