Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by danielmterry · Dec 30, 2016 at 09:35 AM · androidtexturevrimageruntime

Loading 8192x8192 textures at runtime on android

I'm using 8192x8192 truecolor textures in my android project and they work fine when used normally, but now I'm trying to switch to load them at runtime from the streaming assets folder using WWW.LoadImageIntoTexture. (note: I'm doing this because when they are not in the streamingAssets folder the bundle is very large; each 20mb image becomes 256mb).

This works fine when the build platform is standalone but when I switch it to android and run it in the editor I just get a blue texture rather than my image (similar result when running on a device except it's black).

A simplified project with just a 20 line script and an image (20mb) is here: https://drive.google.com/file/d/0ByNPa9Pa1jJ8YVZ1TDdISzFpb3c/view?usp=sharing

Full Script:

public class OptimizationTests : MonoBehaviour {

 WWW localFile;

 void Start()
 {
     string path = "file://" + Application.dataPath + "/StreamingAssets" + "/8kimage.jpg";
     StartCoroutine("LoadTexture", path);
 }

 public IEnumerator LoadTexture(string absoluteImagePath)
 {
     Texture2D texture = new Texture2D(4, 4, TextureFormat.RGBAFloat, false);

     localFile = new WWW(absoluteImagePath);
     yield return localFile;

     localFile.LoadImageIntoTexture(texture);
     GetComponent<Renderer>().material.mainTexture = texture;
 }

}

Comment
Add comment · Show 6
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 tanoshimi · Dec 30, 2016 at 09:43 AM 0
Share

You need to use logcat to find out what's going on on the device but if you're planning to release this I'd recommend you reconsider your texture size - I own 4 Android test devices and I think only one of them will handle textures that large.

avatar image danielmterry · Dec 30, 2016 at 03:19 PM 0
Share

Thanks for the reply. It's not a device issue because it happens in the editor as well, but I have also looked at the logcat output and there is no additional info. 8k textures work on all devices I am supporting (it's a very limited subset).

avatar image Bunny83 danielmterry · Aug 31, 2018 at 03:36 PM 0
Share

Have you actually checked SystemInfo.maxTextureSize? Also note that most android devices don't have that much memory. Regardless of the supported texture size you may just run out of memory. $$anonymous$$y Nexus7 (first gen) only supports 2048 texture size.

avatar image QuincyC · Aug 31, 2018 at 01:55 PM 0
Share

I'm running into exactly the same problem in 2018, did you ever figure this out?

avatar image QuincyC QuincyC · Aug 31, 2018 at 03:49 PM 0
Share

Not sure if my problem was actually exactly the same, but I fixed it by instancing the material I was using.

$$anonymous$$y texture was nowhere near 8k though.

[1]: /storage/temp/123691-gpu-instancing.png

avatar image toddisarockstar · Sep 02, 2018 at 01:58 AM 0
Share

I agree with @tanoshimi there should be no reason you need a texture that big for android. im not sure if this helps but this has allways been the the way ive done it and it always worked for me:

     using System.IO;
 
 byte[] by = File.ReadAllBytes("filepath here");
     Texture2D paper = new Texture2D(2,2);        
             paper.LoadImage(by);

0 Replies

· Add your reply
  • Sort: 

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

7 People are following this question.

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

Related Questions

dynamic images for textures ar runtime 2 Answers

Changing terrain texture at runtime 1 Answer

Problem with texture swapping at runtime (Android only) 0 Answers

Passing texture to android plugin 0 Answers

Save a Texture2D for android 1 Answer


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