I use animation group in atlas and load to texture of a GUI node. On Windows, it’s ok but when viewing on Android app it looks shaky. What could cause this issue?
I see that not only this animation, some of images are also distorted on Android, for example:
Is that a shader effect on the logo? My guess would then be that you are seeing a precision issue. There is no guarantee that lowp or mediump has the same precision on Windows and Android for instance.
It may be that you are generating an atlas with size of ( 8192 x 4096 ). Android is most likely stuggling to display that large of a texture. I would try to limit the atlas max 4096x4096px and check results. Most pc GPU’s can handle very large textures and thats why its displaying fine on PC build.
One thing I would try is to remove every other frame reducing the texture size in half. The results may surprise be very similar to the current look without loosing much in animation.
I will try to see. If that’s true then I just wonder why the texture loaded but not displayed correctly in position or dimension. Any way to fix by Defold for that issue (just in case)
Thanks! material stuff are still kind of mystery to me…
Is using highp cost more resources?
For me accuration is more important, so I will choose it.
Btw, is there a way to use the custom material as the default for all GUI component?
Here is instruction about how to change the precision of shaders from mediump to highp for GUI elements in Defold, you’ll need to follow a series of steps:
Copy the Built-in GUI Material:
Navigate to the builtins/materials/ directory in your Defold project.
Find the gui.material file. This is the default material file used by GUI components.
Copy this file and paste it into your project directory, preferably in a folder named materials or something similar.
Create Custom Shader Programs:
Along with the gui.material file, you will also need the vertex and fragment shader programs. These are typically named gui.vp (vertex program) and gui.fp (fragment program).
Copy these shader files from the builtins/materials/ directory into your project directory, preferably into a materials/shaders folder.
Rename them to avoid confusion with the built-in shaders, e.g., custom_gui.vp and custom_gui.fp.
Modify Shader Precision:
Open both the custom_gui.vp and custom_gui.fp files in a text editor.
In each shader file, locate the lines that define precision for texcoord related variables at the top of the file. It will look something like this: attribute mediump vec2 texcoord0;, varying mediump vec2 var_texcoord0; etc
Change mediump to highp for higher precision. For example, change to attribute highp vec2 texcoord0;, varying highp vec2 var_texcoord0; etc
Save your changes.
Update the Custom GUI Material:
Open your copied gui.material file.
Update the paths to the vertex and fragment programs to point to your custom shader files (custom_gui.vp and custom_gui.fp).
Save the gui.material file.
Apply the Custom GUI Material to GUI Components:
Open the GUI scene file where you want to use the high precision shaders.
In the Outline panel, select the root node of your GUI.
In the Properties panel, find the Material field. It will be set to the default gui.material.
Click the folder icon next to the Material field and select your custom gui.material file.
Test Your Changes:
Run your game to see the changes in effect.
By default, Defold opts for lower precision (mediump) in shaders due to a balanced trade-off between performance and visual fidelity. Lower precision shaders are typically faster and more power-efficient, making them well-suited for mobile devices where resources are more limited. Higher precision (highp) shaders, while offering improved visual quality for certain graphical effects, can significantly impact performance and battery life on these devices. Therefore, it’s crucial to carefully consider the use of high precision shaders and conduct thorough testing across all intended platforms to ensure an optimal balance between performance and visual quality.
In your case, when working with large 8K texture atlases, the use of higher precision (highp) shaders becomes particularly important. For such textures, mediump precision might not suffice to accurately address and render the textures, leading to visual artifacts or imprecision in graphical representation.