Smooth shading is not working in Babylon React-Native

Hello all,

I tried to use “forceSharedVertices” in BabylonJS to make meshes “smooth-shared”.

By the way, it made the app crashes every time when I try.

Could you please take a look at it to fix & resolve the issue?

Demo video:

Babylon Playground: https://www.babylonjs-playground.com/#2LIJBQ#108

Thanks in advance

Github repo: GitHub - railsjack/babylon-native-demo

cc @srzerbetto @bghgary

1 Like

@babylon , I will take a look at it!

2 Likes

@srzerbetto Thanks so much. I will wait for you.

Just as an update on this. It seems the native engine is failing to handle smooth shading for meshes with empty index buffers. We are currently working on a fix for it.

@srzerbetto Thanks for your update.
FYI, looking at this code, I found that it’s not handled if the index buffers are empty.

Yes, but this code does not check for currentIndices.length == 0. However, despite that, it is currently working fine on the web, so I’m trying to understand what the web engine is doing at render time that allows it to render properly.

That’s a good idea.
Just for your information, as shown in my screencast, it throws in cloneObject of React-Native’s JSI.
So, I thought it might be because of some Javascript code to clone objects in forceSharedVertices.

@srzerbetto , How are you?
Any update on this?

@babylon , we have a fix for this issue, and it is currently on a PR for Babylon Native.

Fix crash on smooth shading for meshes with no index buffers. by SergioRZMasson · Pull Request #1109 · BabylonJS/BabylonNative (github.com)

Once the PR gets merged, we will propagate it to Babylon React Native and it should be on the next release.

2 Likes

Thanks @srzerbetto
I will wiat.

@babylon , the PR was merged into master. We were actually able to fix it on Babylon.js instead of Babylon Native, so it should be on the next week’s release of babylonjs/core package (5.17.0).

Let me know if you continue to have any issues after updating your project.

@srzerbetto Thanks so much. I will check it soon.

@srzerbetto

By the way, I have 2 questions.

  1. Can I use it with these versions?
    @babylonjs/react-native”: “^1.1.1”,
    @babylonjs/react-native-iosandroid-0-64”: “^1.1.1”,

  2. Do I need to check it next week? (maybe Monday?)

Hello @srzerbetto
I tried to updated this package but it was seems slower than before.
I was using 5.6.1 and updated to 5.17.1 but seems slower.
Can you please let me know how to do this on JS side?

Hi @babylon , how are you doing?

The fix should get the smooth shading to work. If I understand correctly, previously it was crashing right? Is it working now?

I would also update the package @babylonjs/react-native to version 1.2.0.