Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by LostInTheMachine · Apr 05, 2013 at 06:51 AM · iostexturemeshtextureimporter

Setting isReadable for a procedurally created texture asset

Hello all.

I'm having trouble discovering how to set the isReadable flag when creating a procedural asset.(mesh or texture)

In the following code, TextureImporter is null.

             AssetDatabase.CreateAsset(nodeDb.Texture.GetTexture(), Config.TexturesDirectory + "/Texture" + nodeDb.NodeIndex + ".asset");
             TextureImporter texImporter = AssetImporter.GetAtPath(Config.TexturesDirectory + "/Texture" + nodeDb.NodeIndex + ".asset") as TextureImporter;


If I can't get TextureImporter, how do I do this? An object is returned but is of (undocumented) type NativeFormatImporter which has an almost completely bare interface.

I built an application that extracts images from a database, compresses them(native to iOS) and saves them directly to the assets directory. When I load them onto the device it appears I'm using way(~2x) too much texture memory - like a copy in memory and for VRAM (yes I understand that VRAM is shared on iOS devices).

This is totally defeating my entire memory saving strategy and really quite bad for me. I just assumed I'd be able to retrieve a TextureImporter.

Perhaps something (hacky) could be done with NativeTexture pointers???

Can anyone please help? It appears a few have been frustrated when building procedural assets. Why not have the read/write flag in Texture? Please?

Any help much appreciated.

Scott

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LostInTheMachine · Apr 05, 2013 at 07:05 AM 0
Share

Just to put my issue into perspective, I am displaying geometry data containing roughly 1 million triangles and texture data of approx 16k x 16k (compressed PVRTC). Performance is not an issue but memory definitely is!

The target platform is an iPad 2. I really really can't afford 2 copies! :(

Scott

avatar image LostInTheMachine · Apr 06, 2013 at 01:43 AM 0
Share

I am of course running in "Editor" mode. I'm using the editor as a build environment - extracting and converting meshes/textures from a database to native assets. So I;ve created the most optimal size and performance characteristics for the assets but they take double the memory they should. :( If there were only one copy, memory usage should vary between 50-200$$anonymous$$b just for the in-memory texture/mesh assets. Clearly doubling that is bordering on disastrous when working on the iPad 2.

The tool has been built and delivered to he client. I've only recently discovered these issues but wasn't concerned knowing about the isReadable setting for the TextureImporter. I hadn't considered not getting a TextureImporter interface to my native texture.

This is when I miss coding in C++.

avatar image LostInTheMachine · Apr 08, 2013 at 12:35 AM 0
Share

Just for the record I have filed a bug report with Unity about this. Did I accidentally set a flag? (Only you see this)

I have a test scene with just textures (53$$anonymous$$b) and meshes(31$$anonymous$$b) - the usage numbers are from the iPad.

With nothing(no assets) loaded the baseline consumption for the app is ~30$$anonymous$$b.

I would expect total memory usage to be ~114$$anonymous$$b. The real total is 160$$anonymous$$b. A measly 46$$anonymous$$b overshoot.

The textures are compressed and they are native assets (because I created them procedurally). Being compressed means that I cannot read them(with ReadPixels) and also means there should NOT be a second copy in memory.

This is a big overspend for me as my project's raison detre was to reduce memory consumption.

Any help would be warmly received.

Scott

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by andrewgotow · Oct 29, 2016 at 03:51 PM

I know this is a very old topic, but I think I've discovered a solution.

I'm not sure when it was added, but in the current version of Unity (5.4), Texture2D.Apply now takes a second argument, "makeNoLongerReadable". With this set, the copy of the texture in system memory will be released.

Now, you can do this on procedural Texture2Ds, Texture3Ds, and Texture2DArrays.

 myTexture.Apply(true,true); // will generate mip-maps and free copy
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can anyone identify this texture/mesh quality problem? 2 Answers

Adding gravity and texture to newly added game objects 1 Answer

Texture atlases on iphone 3 Answers

Layered Textures/Materials 0 Answers

Why does Mesh.CreateVBO spike every few seconds on iOS Metal 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges