Search Unity

► Resize Pro ◄

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

  1. system-idle

    system-idle

    Joined:
    Dec 13, 2013
    Posts:
    26
    Hi, I would like to downsize webcamTexture feed before running through CV for face detection.
    Would Resize Pro be fast enough to do this in the Update function?

    Kind regards
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    ResizePro sends Texture2D object data to GPU for resizing then reading it back. Even process is very fast, there may be delays if using in every Update function.
    For run-time tasks as you describe better use RenderTexture.



    VacuumShaders - Facebook Twitter YouTube
     
  3. AlexDjenkov

    AlexDjenkov

    Joined:
    Nov 8, 2016
    Posts:
    2
    Hi there,
    I'm considering the ResizePro plugin, but by far I'm not sure if it will work with my case. I'm capturing a Texture2D in dimension (0,0, 512, 512) is it possible to upscale that to (0, 0, 1024, 1024) for example or that will cost me a lot of quality in the final output image?

    Thanks
     
    Last edited: Nov 6, 2019
  4. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Not "a lot".



    VacuumShaders - Facebook Twitter YouTube
     
  5. ideaengine

    ideaengine

    Joined:
    Jul 8, 2014
    Posts:
    9
    I'm using ResizePro to take a 1920x1080 RGBA32 Texture2d image and scale it down to a thumbnail. However, I am finding that if I scale it to the desired size (160x90) the Texture2d becomes solid grey with some transparency. If I sent the thumbnail size to 1440 or larger, it works fine. Any suggestions?
     
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Unity version?
    Render Pipeline?
    Project Color Space?
    OS? (PC or Mac)?
    Build Target?
    Does problem exists in editor or run-time?
    Does initial source texture exist in project as file or it is somehow generated or downloaded before resizing?



    VacuumShaders - Facebook Twitter YouTube
     
  7. ideaengine

    ideaengine

    Joined:
    Jul 8, 2014
    Posts:
    9
    Hi - here are specifics for the above. As mentioned, scaling to around 75% original size works, but smaller results in a grey texture2d

    The source image is grabbed from an mp4 video (AVPro asset from RenderHeads) at runtime. The raw frame grab looks ok when unaffected. Only when resizing does it seem to be a problem.

    The issue appears in the Editor and at Runtime.

    Unity 2019.3.6f1
    macOS 10.15.3
    Default render pipeline
    Color Space Gamma
    Build Target macOS

    The image attached shows 3 different situations.

    Thanks for your help!
     

    Attached Files:

  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Problem may be in grabbed image. Unfortunately I don not have AVPro asset and can not even make assumption what may be 'wrong' there. Is grabbed image Texture2D or RenderTexture.
    Can you try create temporary Texture2D using Graphics.Blit method from grabbed image and use resize on it. Then remove unwanted files.



    VacuumShaders - Facebook Twitter YouTube
     
  9. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    Hi there, I'm trying to resize big images but receiving blurry image when resizing from 4032x3024 to 50x50

    tex.ResizePro(50, 50, out Texture2D dstTexture)-



    If I use TextureScale.Bilinear, I get-



    But if I take the source image and resize on windows Paint, I'll get this result-
     
    Last edited: Sep 28, 2020
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    ResizePro does not work with original texture files, but with Unity Texture2D objects.
    When you import texture file into Unity project, it gets compressed and adjusted by Unity. Inside texture import settings you can find settings affecting Texture2D object: FilterMode, ResizeAlgorithm, Format, Compression, Mipmap, Texture Type. Those settings define how your original texture file is formatted and then imported into Unity as Texture2D object.
    Try adjusting those settings and find which one gives better result.

    Windows Paint and other image processing software work with original, uncompressed and not modified texture files and their results always will be different than ResizePro as data it works with is already modified and changed by Unity.

    Additionally, ResizePro uses Bilinear filter mode.



    Amazing Assets - YouTube Facebook Twitter
     
  11. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    There's no problem with the imported file,
    What I'm saying is that Resize Pro makes the Texture blurry,
    If I import the same texture to Unity and upload it to my server (without using your plugin)- the file is fine- good quality almost as imported.
    But if I import it and use tex.ResizePro(50, 50, out Texture2D dstTexture) the file becomes very blurry.
    BTW, using TextureScale.Bilinear makes it a bit better

    Also, "Windows Paint and other image processing software work with original, uncompressed and not modified" I didn't say that I use the original file on windows paint, I took the file after it was imported from Unity and uploaded to my server....
     
    Last edited: Sep 28, 2020
  12. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Texture file imported into Unity is not modified or compressed - it is original and it remains same all the time. Compressed and adjusted becomes Unity Texture2D object created from that file, it exists only in engine environment and that is data ResizePro works with. Texture import settings defines compression and 'simplification' of a Texture2D object. So resizing texture in external texture processing software always will produce better result then using ResizePro. Because 1) Texture is compressed by Unity (to create Texture2D object), then 2) ResizePro sends it to a GPU for resizing, 3) GPU using bilinear filter resizes this data, 4) ResizePro reads back this data into new Texture2D object and finally 5) object is encoded by Unity to texture file. That's how ResizePro works.

    In your case texture can become slightly blurry as it is resized down 80 times, that's effect (may be downside) of a GPU accelerated resizing. Adjusting texture import settings for original file can affect above result.



    Amazing Assets - YouTube Facebook Twitter
     
  13. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    165
    When I take the compressed Texture2D , and use EncodeToJPG on it, and send that compressed texture to an external software the result is amazing.
    When I take the compressed Texture2D and resize it with ResizePro I get a blurry result.

    My import setting is through code for loading a pic from mobile library and it's TextureFormat.RGB24.

    Anyway what I'm saying is that I was hoping your plugin can resize textures with good results.
     
  14. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello We are interested in Your Tool, The problem is that we have like a lot of .png .tiff textures in project We would like to convert it to .jpg but without loosing references to actual materials. Is that possible? Cause simple convert from .png to .jpg we could do in Photoshop but then prefabs will still use old .png textures. Let me know. Regards
     
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Yes, tool can overwrite existing files and references will not be lost, if resultant files are saved in original JPG, PNG or TGA formats.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Jan 27, 2022
  16. goyaniharsh3939

    goyaniharsh3939

    Joined:
    Apr 20, 2020
    Posts:
    3
    Hii,
    I am struggling as I am new to texture2d stuff that's why I am using Resizepro however as we can decrease quality in the editor window, I am wondering how can I decrease Image's Quality in runtime.
    Actually in my app user can upload images to the database and therefore if the data size of the image will more then it would be bad for me. That's why I just want to convert the image to JPG and then after decreasing its quality I want to upload that image in my Database. So if it is possible to decrease quality like editor in runtime please show me a way to do this.
     
  17. goyaniharsh3939

    goyaniharsh3939

    Joined:
    Apr 20, 2020
    Posts:
    3
    For instance I want to set Quality to 20.
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  19. Mr-Citizen

    Mr-Citizen

    Joined:
    Feb 20, 2021
    Posts:
    6
    I've been trying to first convert a webcam frame into a texture2D, then resize that texture2D using the following code:
    Code (CSharp):
    1. public Texture2D GetTexture2DFromWebcamTexture(WebCamTexture webCamTexture)
    2. {
    3.     // Create new texture2d
    4.     Texture2D tx2d = new Texture2D(_webcamTexture.width, _webcamTexture.height);
    5.     // Gets all color data from web cam texture and then Sets that color data in texture2d
    6.     tx2d.SetPixels(webCamTexture.GetPixels());
    7.     // Applying new changes to texture2d
    8.     tx2d.Apply();
    9.     // Resize texture
    10.     Texture2D resized = null;
    11.     tx2d.ResizePro(640, 640, out resized);
    12.     // Clear memory
    13.     Destroy(tx2d);
    14.     return resized;
    15. }
    Only, Unity gives giving me this error message:
    error CS1501: No overload for method 'ResizePro' takes 3 arguments


    I've looked through all the posts on this thread and I can't see why
    tx2d.ResizePro(640, 640, out resized)
    is a problem.

    I've also tried it as
    tx2d.ResizePro(640, 640);
    to just resize the tx2d, but that didn't work either. Same error, but saying it doesn't take two arguments.
     
    Last edited: Mar 3, 2022
  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Check Manual file for correct API.



    Amazing Assets - YouTube Facebook Twitter
     
  21. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  23. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Hi @Arkhivrag

    Can the conversion also replace the original textures in the materials, or do the resized textures need to be manually added to the materials individually?
     
  24. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Textures are not replaced.
    Worth to add that feature too.
     
    LichenShare likes this.
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    In new version v2023.2 now it is possible to replace textures with their generated resized equivalents in Materials, Prefabs and Unity scene files.
    Editor tool will automatically create backup copies of the modified asset files, in the case of something goes wrong and texture replacing in asset fails and damages source file.
     
  26. MariuszD

    MariuszD

    Joined:
    Jan 8, 2016
    Posts:
    9
    Hello! Great asset, really helped with keeping texture sizes within our needs.

    Got a question though - each time we do a Resize we're getting locked with "Collecting dependencies" that scans the entire project, is there any way to bypass this?
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    What version of Unity and ResizePro are you using?
    ResizePro doesn’t include any such code that may trigger “collecting dependencies”. If new resized textures are generated inside project folder, Unity will import them, but only them and not the others.
     
  28. MariuszD

    MariuszD

    Joined:
    Jan 8, 2016
    Posts:
    9
    I'm on Unity 2021.3.19f1 and ResizePro 2023.3. We mainly use overriding textures instead of creating new ones, maybe that could be the problem?
     
  29. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Hi @Arkhivrag

    Is it possible, for example, to batch process maps using JPG as the output, but using PNG for maps that require it to preserve transparency, etc.? I always end up using PNG as the global output in Resize Pro, but a lot of the maps could be a lot smaller as JPG, such as albedo, AO, etc. If this is not currently possible, is there a chance of it becoming a future addition? Thank you.
     
  30. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    So you need all textures to be converted to JPG, but those ones that have alpha channel be converted to PNG?
    Not sure it can be made, but will check.
     
    lod3 likes this.
  31. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Saw your latest release of Resize Pro. Thank you for adding the alpha check @Arkhivrag!
     
  32. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Actually, how do I use the new feature?
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Available in the Batch mode only, when the save format is JPG:
    upload_2024-3-29_20-46-15.png
     
  34. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    I probably overlooked something obvious, but just tried this and everything was processed as PNG. Attached my settings.
     

    Attached Files:

    • 01.png
      01.png
      File size:
      35 KB
      Views:
      10
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    If texture has alpha channel it is saved in PNG, otherwise in JPG.
    If you have files without alpha channel that by mistake are saved in PNG, let me check those files.
     
  36. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Hi @Arkhivrag

    I found my issue but need guidance.I'd like to process a single root folder filled with separate texture folders, and have Resize Pro replace the existing textures with the new ones in their current folder. Currently, you can only set a source and target directory. This ends up placing all maps into a single folder as a result.
     
    Last edited: Mar 30, 2024
  37. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Purpose of Batch Mode was to export generated files from Unity and currently has no feature to do what you ask for.
    I will check how to add it too.
     
    lod3 likes this.
  38. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Good morning @Arkhivrag ! Any luck with this?
     
  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    It will be included in the next update. Just busy updating other assets.
     
  40. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    That's awesome! Looking forward to it :)
     
  41. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    @Arkhivrag Hello! Thank you for the latest update! Works as expected, with the only bug I see being Save Alpha not respecting Max Resolution. So all my 4K alphas processed at 4K rather than 1K as set (opaque materials respect it).
     
  42. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Not sure about bug, no such problem at my side.
    Can you share screenshots of ImportSettings of your 4k texture and ResizePro editor window settings you are using.
     
  43. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Hello! Absolutely. I attached 3 images. Resize Pro settings, pre and post image map sizes and dimensions. For context all input maps are 4K png files. The issue actually appears to be the opposite of what I had theorized. It appears that all maps are processed correctly, but only the alpha textures are replaced where the original 4K versions of opaque textures like Albedo, AO, etc. are being left behind with the newly processed maps. This is what what caused the confusion on my end. Is this a bug, or am I not using the correct settings? Please advise!
     

    Attached Files:

  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Export those 4 textures as .unitypackage and send me.
    upload_2024-4-22_22-44-38.png
     
  45. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679