Jump to content

AdvancedDynamicTexture creation taking a long time


Meher
 Share

Recommended Posts

Hi all,

We have an application being build using babylonjs in which we are using an advanceddynamictexture to show a text block. We use the following line of code to create the texture:

let textElementTexture: BABYLON.GUI.AdvancedDynamicTexture =
                            BABYLON.GUI.AdvancedDynamicTexture.CreateForMesh(baseMeshforTextBlock);

We also have a refresh key which updates the current scene and redraws the meshes again. We observed that refresh takes a long time due to the text blocks. On profiling further we found out that the above line of code takes around 35ms during the initial scene creation but when we do the refresh, the same line of code takes around 1900ms. We are not sure why there's this huge increase in time. Can someone help us understand this or provide any further guidance to figure out what's causing this?

Thanks in advance.

Link to comment
Share on other sites

Hi Sebavan,

We created a repro similar to the issue we are seeing. You can find it at: https://www.babylonjs-playground.com/#0AZUVK#5. This prints the time it takes to add the text to the console. You can use 'r' key to refresh which will basically add the text again. We observed another thing that as you keep pressing 'r', the time also keeps increasing.

From our investigations, it seems like as the complexity of the scene increases, the time it takes also increases proportionately. The scene we have is pretty complex and we believe that's what is causing the rapid increase. But, we're still not able to explain why it's increasing in the first place.

Link to comment
Share on other sites

@Sebavan, thanks for the update. But there is one other issue in this. If you reduce the number of boxes in the playground demo from 10,000 (to say 10), the time also decreases. This clearly goes to show that the total number of objects in the scene is affecting the time taken for creating this object. This really will be an issue in our case since our scene is pretty heavy and as a result, it's taking around 1.8s to add the label. Is there any way to avoid this issue or to optimize the time?

Link to comment
Share on other sites

Hello, the reason why it is slow is because the system needs to go through all submeshes after you added a texture to make sure the shaders are flagged as dirty.

You can turn this mechanism off like that: http://doc.babylonjs.com/how_to/optimizing_your_scene#blocking-the-dirty-mechanism

 

Demo: https://www.babylonjs-playground.com/#0AZUVK#15 (see line #39)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...