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

Textures can only be exported from disk, not from memory and not at runtime in a build (FTV-281) (USDU-233) #122

Closed
hybridherbst opened this issue Aug 6, 2019 · 2 comments

Comments

@hybridherbst
Copy link
Contributor

I was just looking into why runtime texture export fails and found that basically there is none implemented! ShaderExporterBase has an #ifdef UNITY_EDITOR around the relevant parts and then just throws an exception if someone tries that at runtime with a comment on it that says "too many things can go wrong (can't encode compressed textures, etc)".

Note that this is incorrect, as numerous exporters (FBX, GLTF etc) show - you can always blit a compressed texture into an uncompressed one, and get that out as proper file. Even texture arrays can be unpacked if need be.

Also, there's a bug - the code there only works for textures on disk, not textures that only live in memory. It fails with exceptions when trying to export textures that aren't actual files on disk (e.g. texture assets that are subassets, textures created in memory, ...).

Note that this will also fail if the texture on disk is in a format Unity understands fine but USD doesn't (like, PSD).

Would be great if USD-Unity-SDK would support all textures and ideally give a choice of which ones to export - from disk or from memory.

@hybridherbst
Copy link
Contributor Author

I started work on this in https://github.com/prefrontalcortex/usd-unity-sdk.

Some things to discuss so far:

  • USD allows for tif embedding, so these could be read from disk directly, while USDZ only allows PNG and JPG. Thus, ShaderExporterBase would need to know whether we're currently exporting USD or USDZ to choose the right path.
  • reading back normals needs some extra handling, namely converting back from G16A16 to R8G8B8 so we can store the texture in tangent space / object space
  • exported texture filenames need to be unique
  • we should keep a dict of which textures have already been converted for which purpose and re-use the results to not duplicate data

@mfe mfe added the bug label Aug 22, 2019
@mfe mfe changed the title Textures can only be exported from disk, not from memory and not at runtime in a build Textures can only be exported from disk, not from memory and not at runtime in a build (FTV-281) Aug 22, 2019
@etienne-unity etienne-unity added JIRA and removed JIRA labels Aug 11, 2022
@etienne-unity etienne-unity changed the title Textures can only be exported from disk, not from memory and not at runtime in a build (FTV-281) Textures can only be exported from disk, not from memory and not at runtime in a build (FTV-281) (USDU-233) Aug 17, 2022
@vickycl
Copy link
Collaborator

vickycl commented Jul 25, 2023

Hello! We've moved this feature request to our Roadmap for better internal tracking. If you head over to the Roadmap you can add more detail about your use case (on the 'USD Import ticket') for this feature to help us prioritize as we hope to be able to work on this in the future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants