Search Unity

► Resize Pro ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, May 3, 2016.

  1. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    It doesn't throw any errors, just ends up with an empty image, yet with Gamma lighting, it works fine.
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Did you include Assets\VacuumShaders\Resize Pro\Shaders\BlitCopy.shader to the build?



    VacuumShaders - Facebook Twitter YouTube
     
  3. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    345
    My mistake... I hadn't specified the last parameter which tells it that it's Linear.
    TextureResizePro.ResizePro(photoTaken, 720, 1280, false, true);
     
  4. Maarten_AryzonTeam

    Maarten_AryzonTeam

    Joined:
    Sep 29, 2016
    Posts:
    13
    Hi,

    I'm trying to get your plugin to work on iOS and I think I have tried every option though nothing seems to work. I'm getting the same result as when I hadn't added the BlitCopy shader to the graphics settings in the Editor play mode: a dark grey / black texture. It works perfectly fine in the editor in play mode. I added it to the graphics settings and even tried including it in a material on an object in the scene to make sure it would build the shader.

    I tried both resize methods, direct resize and with the 'out' parameter. I tried setting the linear to true as well, didn't work either, though I'm thinking this should not give a black texture anyway.

    I'm using Unity 2018.2.0f2 on iOS 11.3 / 11.4, using Metal and running with ARKit
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    iOS has limit on texture resolution to 4k and as a result Unity will fail to work with such textures, ResizePro as well.



    VacuumShaders - Facebook Twitter YouTube
     
    theolagendijk likes this.
  6. theolagendijk

    theolagendijk

    Joined:
    Nov 12, 2014
    Posts:
    117
    Hi @kachelaar ,

    are you working with image files larger then the iOS texture limit of 4k? If so, first use a native iOS plugin to do the image resizing ( <= 4k ) and then apply the image file as a texture.
     
    Arkhivrag likes this.
  7. Maarten_AryzonTeam

    Maarten_AryzonTeam

    Joined:
    Sep 29, 2016
    Posts:
    13
    Thanks for your response. I didn't know that but I don't think that's the problem. I'm loading files from disk which do work when I'm not using the plugin. Once I use the plugin the object renders black. I wrote a native plugin though I would like to keep it cross platform for easier maintenance.
     
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    ResizePro has two methods for image resizing, first one will fail if texture is not marked Read/Write Enabled inside TextureImporter or is not in RGBA32 format. Use the second method, it accepts all type of textures.



    VacuumShaders - Facebook Twitter YouTube
     
  9. Maarten_AryzonTeam

    Maarten_AryzonTeam

    Joined:
    Sep 29, 2016
    Posts:
    13
    Like I said earlier I tried both methods. I'm currently using a native resizing implementation so it's not a big issue. Perhaps it's something in the way Unity handles shaders since 2018.2. Is there anything else I can try? Else I will leave it for now.
     
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Does it work with normal textures.
    In normal texture I mean textures that are initially inside project/build and do not go through any resize or generate plugin. Problem may be in those plugins not saving texture correctly.
    I have just tested with Unity 2018.2.5 and everything works at my side.
    If still have problem contact me: vacuumshaders@gmail.com



    VacuumShaders - Facebook Twitter YouTube
     
  11. dashmoon

    dashmoon

    Joined:
    Aug 22, 2018
    Posts:
    2
    Hi, I've sent you an email with some questions =)
     
  12. MohamedMoghazi

    MohamedMoghazi

    Joined:
    May 12, 2015
    Posts:
    1
    Would you please share an example with www load image and resize, I can only get black empty image return ?

    Thanks
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Code from Unity documentation:
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6.  
    7. using VacuumShaders.TextureExtensions;
    8.  
    9. public class NewBehaviourScript : MonoBehaviour {
    10.  
    11.     public string url = "https://docs.unity3d.com/uploads/Main/ShadowIntro.png";
    12.     public Texture2D newT = null;
    13.  
    14.     IEnumerator Start()
    15.     {
    16.         Texture2D tex;
    17.         tex = new Texture2D(4, 4, TextureFormat.DXT1, false);
    18.         using (WWW www = new WWW(url))
    19.         {
    20.             yield return www;
    21.             www.LoadImageIntoTexture(tex);
    22.  
    23.             tex.ResizePro(32, 32, out newT);
    24.  
    25.             GetComponent<Renderer>().material.mainTexture = newT;
    26.         }
    27.     }
    28. }
    29.  
    30.  
    Tested on PC and Android. Everything works.
    Note, on Monday there will be update to fix some texture resize problem on iOS, may be it will help you too.



    VacuumShaders - Facebook Twitter YouTube
     
  14. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hello Arkhivrag,
    As MohamedMoghazi, there is a black texture on IOS when using ResizePro.
    I noticed that it's working correctly with an Iphone 5, but from Iphone 6, it returns a black texture which is really annoying for my project which is online...
    Did you find something ?

    Thanks
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    There was a little bug on iOS that is already fixed in v2018.3
    As for www textures, I was not able to reconstruct 'black image' issue at my side.
    Are textures bigger than 4K? iOS does not work with such big textures and Unity will generate empty Texture2D object.



    VacuumShaders - Facebook Twitter YouTube
     
  16. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hey,
    I was using your exemple "Code from Unity documentation" a few messages up for testing and the image is far below 4K.
    But I tried with the "Texture Adjustments" plugin. Is resize pro up to date with it ?
     
  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Texture Adjustments works and ResizePro does not?
    Can you caontact me using vacuumshaders@gmail.com



    VacuumShaders - Facebook Twitter YouTube
     
  18. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hey,
    No I mean I just tried with "Texture Adjustments" and I was wondering if it was up to date with the last ResizePro version (v2018.3) ?
    I will contact you tonight when I have my computer :)
     
  19. Ibukii

    Ibukii

    Joined:
    Jun 23, 2016
    Posts:
    45
    Hi, can i check if this plugin does this:

    Width: 1000, Height: 500, the cropping results in a 500x500 image from the image centre.

    Edit: I bought your plugin and it works great. However the output when i call Resize is rotated 90 degrees to the left. Any fixes?
     
    Last edited: Oct 15, 2018
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Only resize.
    Crop and other transformations are available in Texture Adjustments plugin.







    VacuumShaders - Facebook Twitter YouTube
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Have never heard about such problem.
    What Unity version do you use? What is build target?
    Any kind of info to reconstruct your issue will be helpful.



    VacuumShaders - Facebook Twitter YouTube
     
  22. Ibukii

    Ibukii

    Joined:
    Jun 23, 2016
    Posts:
    45
    The rotation is due to the exif image information. it's sorted on our end. Thank you :)
     
  23. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    Hi there, just bought the asset and it works pretty well! Nice job! Quick question, though. Is there some way to have ResizePro handle the preserving of aspect ratios when downsizing? For example, I have a small 60x80 area that I am resizing images into. But it is not preserving aspect ratio, so they get stretched out.

    Also, I think the docs need to be updated. Instead of calling ResizePro(), I had to do TextureResizePro.ResizePro().

    Thanks in advance for any guidance!
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Editor tool has all possible aspect ratio controllers, but with run-rime API you control width and height manually.

    Use VacuumShaders.TextureExtensions namespace in your scripts and Texture2D class object will have ResizePro method attached.



    VacuumShaders - Facebook Twitter YouTube
     
  25. MercurialKid

    MercurialKid

    Joined:
    Aug 30, 2018
    Posts:
    22
    Hi - couple of pre sales questions, please. I've given the forum posts a cursory glance, but wanted to ask two questions.

    1.Does the ResizePro work in the latest version of 2018 Unity?
    2. I want to resize screen captures, taken from with the ScreenCapture.CaptureScreen( which I'm storing in the StreamingAssets folder in my game. These are stored as PNG. I want to load them from file during runtime, and resize and store them back to file. Will ResizePro help me with this?

    Thanks
     
  26. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    1. Tested with Unity 2018.2.5f1. Works.
    2. ResizePro works with Texture2D object. If texture is loaded correctly into Unity Engine, it will be resized.



    VacuumShaders - Facebook Twitter YouTube
     
  27. AdamKane

    AdamKane

    Joined:
    Dec 3, 2012
    Posts:
    134
    Is there a non-dll version available? Moving dlls around doesn't play nicely with Unity Collaborate, so we try to avoid them when possible.
     
  28. AdamKane

    AdamKane

    Joined:
    Dec 3, 2012
    Posts:
    134
    Is there a version which doesn't require being at the asset root folder? That's incompatible with my team's project structure convention.
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Just submitted update v2018.4, it has no restriction for root folder.



    VacuumShaders - Facebook Twitter YouTube
     
  30. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    349
    Hi, I would like to do a batch resize of my textures and replace the existing ones, is this something possible or I need to replace the old textures with the new ones by hand?
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    If new generated texture has the same name (mostly has), same extension (ResizePro editor tool encodes textures in PNG and JPG formats) and same location, then source texture file will be overwritten.



    VacuumShaders - Facebook Twitter YouTube
     
  32. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    349
    ahh yeah, will just go on and do that by hand, it is mentioned about a plug in that is needed for tga, but the link doesn't redirected to a valid location, could you point me the correct one?
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Plugin name is Encode To TGA



    VacuumShaders - Facebook Twitter YouTube
     
  34. CastryGames

    CastryGames

    Joined:
    Oct 1, 2014
    Posts:
    77
    it has some support to do the resize directly from the bytes [] of the image.
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Plugin works with Unity Texture2D class objects only. No byte[] resizing.



    VacuumShaders - Facebook Twitter YouTube
     
  36. Lemonua

    Lemonua

    Joined:
    Mar 16, 2017
    Posts:
    7
    Hi. Can i use this asset if i want to make two builds - one with original textures and second woth half-size texture? And how to do it properly?
     
  37. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    You can resize Texture2D objects inside editor or in run-time (with simple ResizePro method).



    VacuumShaders - Facebook Twitter YouTube
     
  38. WolveX

    WolveX

    Joined:
    May 31, 2016
    Posts:
    49
    Hello,
    Please have a look at the attached project, it is not working correctly on some devices, tested on Samsung Galaxy Note 3 (Android 5.0) and Samsung Grand Prime Duos (Android 5.0.2)
    The resizing is not working correctly, it show a gray image instead of the image I am using
     

    Attached Files:

  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Is VacuumShaders\Resize Pro\Shaders\BlitCopy.shader included in the Always Included Shaders array of Graphics Settings?

    Included API contains 2 methods for texture resize.
    • First one is for textures that are marked as Read/Write enabled in editor.
    • Second method creates new resized texture without modifying source texture, as it may be locked in memory and can not be resized directly. Try this last method.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Aug 3, 2019
  40. WolveX

    WolveX

    Joined:
    May 31, 2016
    Posts:
    49
    Thank you for your reply, please have a look at the attached project in my first post, the same project is working on Note 5 but not working on Note 3

    If you can send me a test project or apk to test it directly on my Note 3 it will be very helpful.

    Thanks
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Plugin is not hardware dependent, it may be some issues with you device.
    Send me asset purchase invoice on vacuumshaders@gmail.com and I can send source code, so you can easily track the problem down at your side.



    VacuumShaders - Facebook Twitter YouTube
     
  42. EdgarSantos

    EdgarSantos

    Joined:
    Nov 11, 2013
    Posts:
    27
    Hi.

    We're using Unity 2018.4.2f1 with the latest version of this plugin and we're having 2 serious issues:

    Using this code:
    Code (CSharp):
    1. protected async Task<SoftwareBitmap> GenerateResizedSoftwareBitmap(Texture2D source, int reqWidth, int reqHeight)
    2.     {
    3.         Debug.Log("Tex format 1: " + source.format.ToString()); // prints RGBA32
    4.  
    5.         byte[] sourceBytes = source.EncodeToPNG();
    6.         await SaveBytes("sourceBytes.png", sourceBytes); // saves original texture correctly
    7.      
    8.         Texture2D resizedSource;
    9.         source.ResizePro(reqWidth, reqHeight, out resizedSource, false);
    10.  
    11.         Debug.Log("Tex format 2: " + resizedSource.format.ToString()); // prints ARGB32
    12.  
    13.         byte[] resizedBytes = resizedSource.EncodeToPNG();
    14.         await SaveBytes("resizedBytes.png", resizedBytes); // this is a reqWidth, reqHeight gray texture (?)
    15. }
    1. ResizePro is returning a Texture2D with (205,205,205,205) in all pixels. We tried waiting for the End of frame to do this but it didn't fix it. Any idea on what does this mean? (since the 205 in all channels looks so specific)
    2. The return texture of ResizePro always return ARGB32 even though the source texture is RGBA32. Is there anyway to specify the return texture format? We can't deal with ARGB32 since we're converting this to a SoftwareBitmap in the next step of the pipeline...

    Any help would be greatly appreciated.
    Thanks.
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    1. Does resize work in common method, without async await ? Does included editor resize tool work?
    2. You can easily change texture format, here is example.



    VacuumShaders - Facebook Twitter YouTube
     
  44. EdgarSantos

    EdgarSantos

    Joined:
    Nov 11, 2013
    Posts:
    27
    Hi.

    1. The resize in the editor seems to work. Regarding async/await, I can't really get around using that (we are already using other code that needs to be run in async mode to prevent blocking main thread).
    2. The problem with re-converting texture format is that it reduces the performance - changing the format on resize forces an otherwise unnecessary conversion. After all, the objective of using ResizePro is to improve performance. Not only that, but the final re-conversion will run on CPU, which negates even more the benefits of ResizePro.

    Thank you for your reply.
     
    Last edited: Aug 9, 2019
  45. EdgarSantos

    EdgarSantos

    Joined:
    Nov 11, 2013
    Posts:
    27
    Hi again,

    1. Just did some further testing and, apparently, waiting for 1 frame before doing the ResizePro is making it work correctly. This is not the most critical (16ms) so #2 is where we would see the biggest improvement .

    2. As explained in previous post, returning the texture in the same format as the input (or even allowing the output format to be specified as parameter) would bring the most performance improvement.
    For reference, on Hololens 1, resize+flip 150x150 to 416x416 takes:
    ~200ms for our CPU-only resize+flip
    ~205ms for ResizePro resize+flip with the (hopefully unnecessary) texture format conversion
    ~25ms for ResizePro resize+flip

    As you can see, on Hololens, the additional reconversion is extremely slow and negates the amazing speedup of ResizePro

    Do you think that you could implement this in a next version of ResizePro?

    Thank you for your help.
     
    Last edited: Aug 9, 2019
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Try new version v2019.3
    You can choose several formats for generated resized texture, allowed during reading texture data from GPU.



    VacuumShaders - Facebook Twitter YouTube
     
  47. EdgarSantos

    EdgarSantos

    Joined:
    Nov 11, 2013
    Posts:
    27
    Hi,

    Thank you so much for that, that's exactly what we needed.

    We still have some textures that are not working correctly. We're getting "partial" results of the resize only:
    upload_2019-8-12_12-13-34.png

    Any idea on what this could be?
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    More details would be helpful. When does it happen, again inside async await method?
    Seems you are trying to resize (read) texture in the middle of rendering process, when GPU is busy with current frame rending.
    Note, texture is send to GPU for resizing and then it is read back again by CPU, all process is controlled by Unity Engine, you can not interrupt it or will end up with such results.



    VacuumShaders - Facebook Twitter YouTube
     
  49. EdgarSantos

    EdgarSantos

    Joined:
    Nov 11, 2013
    Posts:
    27
    Hi.

    Yes, it's inside async await but we did a very simple sample with async await and that actually works.
    So I guess that's not the issue.
    The sample has a static texture in the build, and generates a new one that is resized. This works properly.

    Regarding our real code, what you said makes sense but I don't really now if and how to avoid "interrupting" the resize process.
    What is being done:
    1. Get frame from sensor (getting an image from the camera feed basically, as opposed to having a static pre-existent picture)
    2. Clip that frame using "GetPixels" and "SetPixels" to a new texture2D
    3. Resize the new texture2D

    Any idea on what could be causing the issue?

    Thank you for all your help.
     
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,981
    Do not use ResizePro with async await methods. I do not see any other solutions.
    As I wrote above GPU read/write is out of my control(from script side) and completely controlled by Unity Engine.



    VacuumShaders - Facebook Twitter YouTube