I’m trying on thie PG https://playground.babylonjs.com/#C6V6UY#5 to implement a joystick controller to drive the avatar walking.
the joystick puck attach to a AdvancedDynamicTexture, when I touch and update the punk Ellipse, it triggers the update() function of _checkUpdate() in AdvancedDynamicTexture.js
I measure the execution time on the Iphone12pro, it takes 50ms for update() function,
I got two troubles here:
- where is the update() implementation, I cannot trace from the AdvancedDynamicTexture script.
- why it costs much time when update() is triggered, does it have any default settings to save the time?
thank you in advance for your help
Since AdvancedDynamicTexture inherits from DynamicTexture and has no overridden version of
update(), it’s probably using DynamicTexture’s version (dynamicTexture.ts, lines 149-159). This will then call
updateDynamicTexture, which is added using
prototype in engine.dynamicTexture.ts. Since there are two versions (WebGPU and WebGL?), I’m going to assume that the non-WebGPU version is being used.
As far as default settings to speed things up, I’m not really seeing anything that stands out to me (maybe you have an idea @sebavan or @Evgeni_Popov?)
The update might take a long time due to either the frequency of it being called or the size of the canvas you use for the dynamic texture ? Basically every time something happens you are drawing in a canvas 2d then copying it on the GPU to render full screen.
In case of controls like such I would advice to try and rely on WebGL only on maybe a second orthographic camera rendering only meshes looking like your shapes ?
Thank you for your reply, I tried allowGPUOptimization and different canvas size with different devicePixelRatio with setHardwareScalingLevel the time changes. The most obvious influence on the update might be the size of canvas. the PG call the CreateFullscreenUI and have higher resolution on the device, so is there any approach to minimize the CreateFullscreenUI texture size without decrease the resolution of the canvas?
Just an odd idea, but what about create for plane instead of FS and use a second camera. Would that avoid rendering the FS canvas because of the AdvancedTexture? I really don’t know but it might be worth giving it a try?
Hi just checking in, was your question answered? @RavenLee