Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS Support #219

Merged
merged 1 commit into from
Jan 7, 2024
Merged

Conversation

directedchaossoftware
Copy link
Contributor

@directedchaossoftware directedchaossoftware commented Sep 30, 2023

  • Adds iOS universal library paths to terrain.gdextension
  • Adds icon and project reference for iOS
  • Modifies terrain_3d_texture to allow

Reviewer Edit:
Fixes #218

@TokisanGames
Copy link
Owner

TokisanGames commented Sep 30, 2023

Thank you, I will review and test a bit more. We won't be defaulting the demo project to etc2, but we can document that it's needed for ios and android so people can setup their own files.

Unity recommends:
Desktop: BC7 or DXT1 (BC1) / DXT5 (BC3) (Godot only supports up to DXT5)
IOS: ASTC or ETC2
Android: ASTC or ETC2
https://docs.unity3d.com/Manual/class-TextureImporterOverride.html

And Android says ETC2, which covers 87% of devices. ETC1 doesn't support alpha so it's not an option. ASTC is 77% of devices. DXT1/5 virtually unsupported.
https://developer.android.com/guide/playcore/asset-delivery/texture-compression

This article says the following which suggests why you were able to use DDS/DXT files after enabling ETC2 in the project settings, even though the hardware doesn't support it. Somewhere it's likely being converted from DXT to ETC2:

Some game engines transcode the textures in memory if the format is not supported on the device. For example, consider a game bundled with ETC2 as the default format and no ETC1 support. Devices that support only ETC1 will still be able to run the game, but with slower loading times and performance. Refer to your game engine's documentation to verify if this transcoding is done and if it is acceptable for your use case. As an example, Unity decompresses the texture at runtime to a fallback format for older devices that don't support it.

@directedchaossoftware
Copy link
Contributor Author

Thanks for the help! In particular I don't know much about texture formats (compression etc.), I just tinker to get something working. It makes sense not to default the demo to etc2 (and you may want to change/remove the icon too?) -- there are more setup steps for mobile anyway. I went ahead and removed the etc2 project change. Let me know if you want something else to help get this in, but otherwise I'm quite happy to keep tinkering with this change in my project.

@TokisanGames
Copy link
Owner

FYI, I will work on this and get it in as part of 0.8.4, after I'm done with changing the control map format, adding holes, and merging in the shader rewriting I've been doing. I need to test etc2 / astc and the image formats.

You can remove the icon and squash your commits.

I'll need to write up a wiki page for Mobile and let people know they need to enable this setting in their project settings: textures/vram_compression/import_etc2_astc=true. And other steps from your issue #218.

I also need to create a github action to build IOS automatically.

I have an old iphone 7 w/ v15.7.9 and no mac. If I have github build it, is there a way I can export the demo from my windows pc and load it on my phone?

Thanks

@directedchaossoftware
Copy link
Contributor Author

Cool, I'm happy to try those things. I can sync/squash next week, but I think the icon is required to export to iOS. I don't know about github build, but I don't think you can build for iPhone from Windows. I think you need XCode on Mac OS and developer credentials.

@TokisanGames
Copy link
Owner

TokisanGames commented Nov 2, 2023

Ah, you don't want to merge. There's almost never a reason to use git merge. If you used the sync button on github desktop, that creates a merge commit and you shouldn't use it.

In the future, what you want to do is a rebase off of the latest commit as described in the godot pull request workflow.

git pull --rebase upstream main

https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html#updating-your-branch

However, what you want to do now is an interactive rebase and delete that merge commit. Then you might need to do the rebase above if it is still needed.

https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html#the-interactive-rebase

git rebase -i HEAD~3

3 for the three commits you have, change command in front of the merge commit to drop.

@TokisanGames
Copy link
Owner

TokisanGames commented Nov 6, 2023

I tested this today. I was delaying because I needed to test the && format != Image::FORMAT_RGBA8) and was working on other areas.

This change allows the user to insert PNGs that have not been imported according to the docs. By default PNGs are imported as "Lossless" and are straight RGBA8. However when used this way, they don't work very well, not with multiple textures in the array, and produce errors in the console, so we can't allow that.

When PNGs are properly imported as VRAM Compressed, Godot reports it as DXT5, and a DXT5 s3tc.ctex file is created.

$ file project/.godot/imported/rock030_alb_ht.png-ac17816f8b127f0c153387663d699b8f.s3tc.ctex
Godot 4 texture v1: 1024 x 1024, 10 mipmaps, DXT5

If the import etc2 is selected in the project settings, it also makes an etc2.ctex file. Both the DXT5 and ETC2 file exist in the .godot/imported folder.

$ file project/.godot/imported/rock030_alb_ht.png-ac17816f8b127f0c153387663d699b8f.etc2.ctex
Godot 4 texture v1: 1024 x 1024, 10 mipmaps, ETC2_R11S

Godot has a format for this: FORMAT_ETC2_R11S = 27. Does this work in that format validation when using a PNG w/ VRAM Compressed?

There's also a variety of other options. I assume you can't get a console on ios. But you could load an exported PNG file and display the format on screen in the UI if 27 doesn't work.

With etc2 enabled in the project settings, when I double-click the png, the DXT5 file displays in the inspector. The etc2 file must only be used on export. So yes, we can leave it on in the project settings as it won't affect desktop at all. In the documentation we can let them know etc2 must be enabled in project settings and on export.

I exported a windows PCK file as a zip and looked for rock028* (from DDS). There are no ctex files for it. There are only dds files because they don't get imported(converted). So there is no DXT5 -> ETC2 conversion. Since DXT doesn't work on mobiles, that's why you got a checkered display.

I exported an IOS pck as zip and looked for my rock030 (from PNGs). The PNGs are gone from the textures folder, and the s3tc.ctex files are gone from the import. What we do have are .etc2.ctex files in import.

So mobile games need to use PNG imported as VRAM Compressed. Not DDS. Please test to make sure format 27 works for the validator.


The only thing that's confusing for me is how you got the DXT5 grass texture to show up in your screenshot? Did you convert the DDS file to another format in photoshop? It is not RGBA8, so why does your console report it as 5?

Your export .pck is a zip file. What rock028* files do you have in .godot and in the file system? If it's just the rock028_alb_ht.dds then I'm totally confused how. I expect there should be an etc2.ctex file and a PNG version of the file or something in there.

This was referenced Nov 17, 2023
- Adds iOS universal library paths to terrain.gdextension
- Adds icon and project reference for iOS
- Modifies terrain_3d_texture to allow
@TokisanGames
Copy link
Owner

I updated this PR:

Thanks for all of the testing before to produce this PR.

We need more testing on IOS now that these PRs are in.

@TokisanGames TokisanGames merged commit e9e4d7b into TokisanGames:main Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add iOS Support
2 participants