Search Unity

► Texture Adjustments ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, May 20, 2015.

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: Apr 5, 2022
    Devil_Inside and theANMATOR2b like this.
  2. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Looks interesting.
    So, as far as I understood, at run-time all the adjustments are applied in real-time through shaders, while in the editor it allows you to save a texture?
    Also, I think it would be a great idea to be able to select a color range that you want to apply hue-shift to. Will this be possible?
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Run-time API uses RenderTexture to calculate everything using shaders on the GPU.
    Editor does the same. +You can save results in a separate texture(PNG) file.
    Hue-shift using color range is not included. I'll add it to a 'wish list'.



    VacuumShaders - Facebook Twitter YouTube
     
  4. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    I'm still not quite sure how the RunTime part works and what is the performance hit when using it.
    Does it work on mobile? Do you have a RenderTexture as a full-screen image effect?
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    RenderTexture does not mean full-screen image, it is a 'texture' allocated on the GPU and its purpose is to handle runtime computations. It has highest performance comparing to the CPU textures (that's why image effects use them).

    If mobile supports render texture than you can use plugins run-time API. You can check it: http://docs.unity3d.com/ScriptReference/SystemInfo-supportsRenderTextures.html
    Otherwise you can use shaders.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Jun 10, 2015
  6. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Update v1.1 released
    • Added GPU accelerated texture resize support.
    • Added overlay texture support.
    • Editor and run-time API check if system supports RenderTextures before applying adjustments to avoid Unity freezing.
    • Fixed shader error - Unmatched #endif (on gles3)
    • Unity 5.1 standard shader GUI support.


    Note:
    GPU accelerated texture resize comparison with CPU version available on wiki.unity3d.com
    Resizing 8192 texture to 512 (example texture) on i7 2.40GHz with GTX 660M
    GPU accelerated conversion time - 0.007sec
    CPU version (wiki.unity3d.com) - 0.654sec
    -------------------------------------------------------------------------
    Texture Adjustments version is about x100 faster!



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Jun 11, 2015
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: Jun 11, 2015
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: Jun 11, 2015
  9. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: Jun 12, 2015
  10. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: Jun 12, 2015
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  12. wegtsd

    wegtsd

    Joined:
    Oct 18, 2012
    Posts:
    9
    Hello, I have some problems with your plugin

    I use it for scale runtime generated atlases. Why I can not set specific options for destanation texture like use mipmaps or not?

    When I scale texture with no mipmaps to texture with no mipmaps I get texture with mipmaps counr 5!
     
    Last edited: Jun 18, 2015
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    I forgot about mipmaps :rolleyes:, tomorrow I'll release update to fix that.



    VacuumShaders - Facebook Twitter YouTube
     
  14. wegtsd

    wegtsd

    Joined:
    Oct 18, 2012
    Posts:
    9
    Oh, thanks :)
     
  15. wegtsd

    wegtsd

    Joined:
    Oct 18, 2012
    Posts:
    9
    Can I ask you a question? Can I get method like:

    CopyAndScale(ref byte[] texture1, ref byte[] texture2, int destWidth, int destHieght)

    It would be perfect! My problem is I create texture from bytes bigger size that I need and then scale it.
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Update v1.2 released
    • Texture resize functions support generating mipmap option, filter mods and bypassing sRGB sampling.



    VacuumShaders - Facebook Twitter YouTube
     
  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Bytes array scaling can not be accelerated on the GPU, you will have to manually convert them to textures.



    VacuumShaders - Facebook Twitter YouTube
     
  18. wegtsd

    wegtsd

    Joined:
    Oct 18, 2012
    Posts:
    9
    Yes, but I can reduce memory usage.

    If I create texture manually (atlases in my case), I need create texture from byte array, then rescale it, and then delete destanation texture. So in one monent I will have two textures in memory, that's my problem.
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    I'll have to do exactly the same inside function:
    1. Convert bytes to texture
    2. Send it to GPU for scaling
    3. Convert received texture to bytes array.
    So adding your requested function will save you just two lines of code, nothing more, neither performance nor memory.



    VacuumShaders - Facebook Twitter YouTube
     
  20. wegtsd

    wegtsd

    Joined:
    Oct 18, 2012
    Posts:
    9
    In this case yes, I don't need to save two line of code.

    But if you can scale byte array, without sending it to GPU and converting to texture, I can save memory for creating big texture from bytes. I'm talking about some alternative function.

    It will be a very good:)
     
  21. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Looks interesting.
     
  22. oliver-jones

    oliver-jones

    Joined:
    Nov 8, 2010
    Posts:
    25
    Hello, is it possible to use 'Resize' at runtime?
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    All options provided by editor can be used in runt-time, including resize.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Jul 2, 2015
  24. nepomuko

    nepomuko

    Joined:
    Mar 17, 2014
    Posts:
    24
    is it possible to set certain parameters of the rgb levels as a variable in the editor in order to control it with Playmaker in runtime?
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Levels can be controlled together for all 3 channels or separately one by one. Everything can be done inside editor and in run-time.
    As for Playmaker I do not have it and do not use it.



    VacuumShaders - Facebook Twitter YouTube
     
  26. Paynaldo

    Paynaldo

    Joined:
    Aug 14, 2014
    Posts:
    4
    Hey, this looks like a fantastic plug-in. I've a bit of a nube, so just to be clear...

    1. I'd buy this if it meant I didn't have to make .png variations of my sprite sheets in different hues. Will your plug in generate a separate image, or will it save me memory by just changing the original image at runtime?

    2. Will this work with the sprite/diffuse shader?

    Thanks, looks awesome :)
    Stephen
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Update v1.3 released.
    • Added sprite shaders.


    1. Both editor and run-time api create new adjusted textures, without modifying original. If you want to get rid of the source texture you can delete it in editor or use Destroy function during run-time to free allocated memory.
    2. Just added :)



    VacuumShaders - Facebook Twitter YouTube
     
  28. IndiumIndeed

    IndiumIndeed

    Joined:
    Jun 17, 2014
    Posts:
    6
    Could you, please, include some license with the package?
     
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Standard AS license.



    VacuumShaders - Facebook Twitter YouTube
     
  30. oliver-jones

    oliver-jones

    Joined:
    Nov 8, 2010
    Posts:
    25
    Hello,

    I'm trying to change the Brightness/Contrast of an image dynamically (run-time) via the API 'static public Texture2D BrightnessContrast' - Works fine on Mac/PC, but when I deploy and test on iOS, I get this error in Xcode:

    NullReferenceException

    at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <filename unknown>:0

    at VacuumShaders.TextureAdjustments.Adjust.BrightnessContrast (UnityEngine.Texture2D _srcTexture, Single _brightness, Single _contrast, Single _redCoeff, Single _greenCoeff, Single _blueCoeff) [0x00000] in <filename unknown>:0

    at ImageBehaviours+$AdjustColour$784+$.MoveNext () [0x00000] in <filename unknown>:0

    UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)

    $:MoveNext()

    Any advise would much be appreciated. Thanks.
     
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  32. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Just updated ReadMe.pdf doc file with that info.
    If project is using Texture Adjustments run-time API than GraphicsSettings (Edit/Project Settings/Graphics) must include Adjustments.shader (Assets/VacuumShaders/Texture Adjustments/Shaders/cginc/ Adjustments.shader) in Always Include Shaders array.



    VacuumShaders - Facebook Twitter YouTube
     
  33. oliver-jones

    oliver-jones

    Joined:
    Nov 8, 2010
    Posts:
    25
    Hi, thanks for that.

    I'm not getting that error now, but the colour adjustment isn't applied. And after a couple attempts it crashes the iOS device due to memory warning.

    Please advise.
     
  34. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Texture Adjustments run-time script generates texture every time you use it. For example calling Hue function returns new adjusted texture, if you do not need previous one you can destroy it to free memory.
    Advice, use adjustment functions not on every update, but only if some adjusting variable changes.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Sep 14, 2015
  35. electricseed

    electricseed

    Joined:
    Sep 23, 2012
    Posts:
    17
    Do you offer a method to crop images as well (e.g. top-left point, bottom-right point)? Resize is nice, but i need to cut out a middle square part of the texture i'm resizing. (I'll be using the runtime-api)
     
  36. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Texture crop feature is not included.



    VacuumShaders - Facebook Twitter YouTube
     
  37. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    Is this supported on Android and iOS? I am transmitting a texture from server to client and would like to use Texture Adjustment package to scale the texture to match clients width and height.

    I have bought the package but would like to confirm if iOS and Android is supported before spending time integrating it.

    I do see that answer related to mobile is provided. Can you please provide some detail on how to use this in run time when receiving texture over network?
     
    Last edited: Oct 10, 2015
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    ReadMe file in Doc folder provides full info about API functions.



    VacuumShaders - Facebook Twitter YouTube
     
  39. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    Do you have a latest version of Readme? The one I got when I bought the asset today from asset store does not mention "GPU accelerated texture resize" at all. It only mentions following:


    Texture Adjustments contains editor tool, run-time API and shaders for texture tweaking:
     Levels control
     Hue / Saturation / Lightness
     Brightness / Contrast
     Changing color space (gamma, linear)
     Color Overlay (19 blending modes)
     Invert and alpha channel adjustment
     
  40. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Yes, texture resize functions are missed in ReadMe file. Here they are:
    1. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, bool _mipmap)
    2. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, bool _mipmap, FilterMode _filterMode);
    3. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, bool _mipmap, FilterMode _filterMode, bool _linear)
    4. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, int _newWidth, int _newHeight, bool _mipmap)
    5. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, int _newWidth, int _newHeight, bool _mipmap, FilterMode _filterMode)
    6. static public void CopyAndScale(ref Texture2D _srcTexture, ref Texture2D _dstTexture, int _newWidth, int _newHeight, bool _mipmap, FilterMode _filterMode, bool _linear)



    VacuumShaders - Facebook Twitter YouTube
     
  41. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    I tried this but CopyAndScale is not found in VacuumShaders.TextureAdjustments.

    The VacuumShaders.TextureAdjustments.dll in my package is dated 9/9/2015. Is there a later version of the script available with CopyAndScale?

    Can you please provide a sample script for run time api usage?
     
    Last edited: Oct 10, 2015
  42. rishi-ranjan

    rishi-ranjan

    Joined:
    Oct 7, 2015
    Posts:
    22
    Sorry missed the static class Adjust in the Readme. It works now.
     
  43. Babacool321

    Babacool321

    Joined:
    Feb 25, 2015
    Posts:
    8
    I have 3 questions :
    Does it work with a SpriteRenderer ?
    Compatible 5.21 ?
    Useable for Unity UI ?
     
    Last edited: Oct 11, 2015
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    It is compatible with 5.2.1 and has sprite shaders (added in v1.3).
    As for Unity UI. What do you mean?



    VacuumShaders - Facebook Twitter YouTube
     
  45. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    In several days will be available new update with Batch converter and new 500x faster run-time scripts (with standard Texture2D, scripts will work with RenderTextures too).

    Here is speed test for 1000 adjustments in loop (texture size 512x512)
    Convertion speed.png



    VacuumShaders - Facebook Twitter YouTube
     
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    New version will include selective color change and hue shift (for editor and run-time of course).





    VacuumShaders - Facebook Twitter YouTube
     
  47. hpzxk

    hpzxk

    Joined:
    Jul 13, 2014
    Posts:
    4
    hi, questions:
    1. if i use these for a 2D game, it must be unity 4 pro?
    2. how is the performance for 2D game on mobile?
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    1. Yes you need pro, but mainly - RenderTextures support.
    2. Performance is defined by amount of 'adjustments' you use. But after releasing new version (currently working on it) it will be about 500x faster.



    VacuumShaders - Facebook Twitter YouTube
     
  49. Babacool321

    Babacool321

    Joined:
    Feb 25, 2015
    Posts:
    8
    Hey,

    I want to use the shader to modify multiple sprites.
    But when I set them with the Sprite/HSL shader, and modify the value.
    All the sprites are modified.

    How can I set the value seperately for each sprites ?
     
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Do you use one material on multiple sprites?



    VacuumShaders - Facebook Twitter YouTube