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,
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 ?
updateDynamicTexture does have a allowGPUOptimization parameter which is by default false. You could experiment with overwriting the ADT’s update method to call updateDynamicTexture with this parameter set to true, and see if that makes a difference.
You can try limiting the update calls to something like 10/second. This will result in a less responsive GUI but your framerate overall will be improved.
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?