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
    CellSize defines pixelated area size on texture.
    e.g texture with dimension 512x512, and cellsize 256 and 128
    TE.png
    If on texture with dimension with 512x512 you need to have 4x4 'pixels' (note texture size does not change, just pixelated area) CellSize must 4 times smaller (in this case it will be 512 / 4 = 128) than original textures dimension.
    From generated texture you have to manually read required pixels as API you are asking is not implemented.

    But it will be easier to use only Resize method and specify only required final dimension of the texture. You end up with your desired 2D array of pixels:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. using VacuumShaders.TextureAdjustments;
    4.  
    5. public class Test : MonoBehaviour
    6. {
    7.  
    8.     public Texture2D sourceTexture;
    9.  
    10.     void Start()
    11.     {
    12.         Adjust_Resize resize = new Adjust_Resize();
    13.  
    14.         //Setting resize type for 'RESIZE_TYPE.Pixel' for manually controlling final width/height values.
    15.         resize.resizeType = Adjust_Resize.RESIZE_TYPE.Pixel;
    16.        
    17.         resize.width = 16;
    18.         resize.height = 16;
    19.  
    20.         //If enabled 'resize.height' parameter will be calculated automatically
    21.         resize.lockAspectRatio = false;
    22.  
    23.  
    24.  
    25.         //Resized texture will be saved here
    26.         Texture2D newTexture = null;
    27.  
    28.         //Apply resize
    29.         resize.Apply(sourceTexture, ref newTexture);
    30.  
    31.         //Change filter mode on final texture to have more 'pixelated' look
    32.         newTexture.filterMode = FilterMode.Point;
    33.     }
    34. }
    35.  


    VacuumShaders - Facebook Twitter YouTube
     
  2. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thank you very much, so i applied above approach however when i do read pixels i get different color values (slightly) even though they are the same colors. I also noticed that your library is closed source so i cant get the color values during pixelate is being applied. So how should i deal with this problem?
    Thanks
     
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Update 2:

    I treid resizing method, but resized image doesnt look like the pixelated version i can see in preview. Im using your code with only following difference
    resize.width = destinationTexture.width / (int) InputCellSlider.value;
    resize.height = destinationTexture.height / (int) InputCellSlider.value;

    Please advise
     
  4. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Update 3:
    I'd really appreciate if you could return a 2D Array which contains all those Cell values, this will not just be effiecnt but exactly the same as i see in preview.
    I cant tell you how much this is important to me.
    Thanks
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    All texture adjustments are calculated using shaders, not source .dll. There is no math or some calculation algorithms inside .dll.
    Pixelate and Resize are two different effects and their results will be different.
    Using Resize was just suggestion as what you are asking for is not implemented. And will not be, as such methods are completely out of the scope of this asset.



    VacuumShaders - Facebook Twitter YouTube
     
  6. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Its a shame you cant provide a 2D Array which contains color values of each cell.
    Thanks
     
    Last edited: Apr 6, 2018
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984


    v2018.1 released:
    • New improved editor window.
    • Added Linear color space support (experimental).
    • Added LUT adjustment.
    • Added filter mode and transparency view for editor preview texture.
    • Improved Pixelation adjustment with grid control.

    Note, Linear color space should work by default without any interaction from the user side, but if encounter any problems just let me know.



    VacuumShaders - Facebook Twitter YouTube
     
  8. syaped_unity

    syaped_unity

    Joined:
    Mar 29, 2018
    Posts:
    11
  9. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  10. syaped_unity

    syaped_unity

    Joined:
    Mar 29, 2018
    Posts:
    11
    Thank you. Does the dilate/edgepadding require an alpha channel to work?
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Yes, alpha channel is mandatory.



    VacuumShaders - Facebook Twitter YouTube
     
  12. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @Arkhivrag
    How can i lower the number of colors in a texture? for example if an image has 256 colors, i can lower to 200 or 180 or 100 etc
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    There is no Indexed Color tool.
    Added to a wish-list.



    VacuumShaders - Facebook Twitter YouTube
     
    jGate99 likes this.
  14. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Last edited: May 8, 2018
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    jGate99 likes this.
  16. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    @Arkhivrag
    I noticed 2 recent updates with these new adjustments, can we expect in "Indexed Color tool" in next update. If not then a rough idea?
    Thanks
     
  17. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Why pixelate effect's cell is not perfectly square? can we provide cell size in width height so we can get the expected cell shape ?
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Indexed Color tool is added to a wish list. Currently can not say how and when it will be added.


    Cell is exactly the perfect square. Will add custom width/height control in the next update.



    VacuumShaders - Facebook Twitter YouTube
     
    jGate99 likes this.
  19. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Its not, thats the funny thing, sometimes its perfectly square and sometime its like that
     

    Attached Files:

  20. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Can you provide more details?
    Is it editor issue or run-time API use? Can you send me source texture and what Pixelate settings are you using.



    VacuumShaders - Facebook Twitter YouTube
     
  21. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Its the runtime api, what i do is show a texture from webcam and trigger it from Start
    So first time when i run the app , it shows texture like that. however if during runtime i close webcam and select some other texture then it appears fine, if go again to webcam (during same session) it also show webcam texture square.

    which means, issue happens at start only once.
     
  22. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Unity version and Color space?



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: May 13, 2018
  23. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    It's 2018.1 with Gamma.
     
  24. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    Please provide a way to toggle those border lines in pixelate on and off.
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Try new update v2018.5



    VacuumShaders - Facebook Twitter YouTube
     
  26. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
    It was due to damn WebCam, Your plugin is fine. Sorry.

    Another issue is, earlier i was able to know the number of columns and rows, now my old code is not working any more
    int totalRows = Mathf.CeilToInt(copyTexture.width / pixelate.pixelCountHorizontal
    );
    int totalColumns = Mathf.CeilToInt(copyTexture.height / pixelate.
    pixelCountVertical
    );


    another question, do you have any plans for Disintegration effect?
     
    Last edited: May 27, 2018
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Is it texture adjustment effect? May be some examples?



    VacuumShaders - Facebook Twitter YouTube
     
  28. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    60
  29. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
  30. Jelmersb

    Jelmersb

    Joined:
    Jul 12, 2016
    Posts:
    66
    EDIT: I think I solved it from an older post from you :)
    I added screenShot.Apply();
    before the rest and for some reason I don't understand, it now works :)

    ------------original post-----------

    Hi,

    I get a gray image after implementing the asset:
    declarations:
    Code (CSharp):
    1.     public Texture2D screenShot;
    2.     Texture2D adjustedScreenShot;
    3.     public Adjust_Crop crop = new Adjust_Crop();
    part of my code:
    Code (CSharp):
    1.  byte[] bytes;
    2.         if (cropAndResize)
    3.         {
    4.  
    5.             //doesn't work
    6.             crop.Apply(screenShot, ref adjustedScreenShot);
    7.             bytes = adjustedScreenShot.EncodeToJPG(50);
    8.         }
    9.         else
    10.         {
    11.             //no changes, works
    12.             bytes = screenShot.EncodeToJPG(50);
    13.         }
    14.         File.WriteAllBytes(myDataPath, bytes);
    I also included the crop shader under project settings > graphics

    So when I resize, I get a gray image, when I don't resize all works. What could be wrong?
     
    Last edited: Jul 24, 2018
  31. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hello Arkhivrag !
    Resize Pro last update (with black texture fixed on mobile) is not incorporated into Texture Adjustments. Is it possible to do so ?

    Thank you very much !
     
    Last edited: Oct 16, 2018
  32. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Working on fix.



    VacuumShaders - Facebook Twitter YouTube
     
  33. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @Arkhivrag ,

    Does this work on Mesh and Sprite textures in runtime? How often to call if not on Update()?
     
  34. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    This plugin works with all Texture2D objects. Sprite textures - Yes, meshes - No.



    VacuumShaders - Facebook Twitter YouTube
     
    Duffer123 likes this.
  35. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
  36. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    The asset looks intriguing, and may fill a need I have. Does it handle resizing/scaling while preserving the aspect ratio of the original image?
     
  37. Arkhivrag

    Arkhivrag

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



    VacuumShaders - Facebook Twitter YouTube
     
  38. oukaitou

    oukaitou

    Joined:
    Jan 10, 2014
    Posts:
    18
    Hello

    Just want to know is it possible to support ETC/ETC2 compression? (Such as EncodeToETC)
    I can't find any information about compressing textures with GPU so I just want to ask about the possibility....
     
  39. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    If you mean run-time compression, then no.



    VacuumShaders - Facebook Twitter YouTube
     
  40. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    any plans for adding kaleidoscope effects?
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Had no plans about kaleidoscope effect before. I need to make research about that effect first.



    VacuumShaders - Facebook Twitter YouTube
     
    jGate99 likes this.
  42. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    as you have already added complex filters in adjustments, then doing kaleidoscope'd not be an issue for you. keeping my fingers crossed for this.
    thanks
     
  43. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    another request, not sure if its related to texture adjustments

    a function that takes a texture, number of rows n columns, and then return array of textures where each index [cell] is that sub texture. this function will cut the big textures into small parts
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Some kind of multi-crop?



    VacuumShaders - Facebook Twitter YouTube
     
  45. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    yes, please check this picture,
    with those cropped pieces, we plugin users'd be able to develop pieces related games such as

    images.jpeg
     
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    For that effect you really do not need texture splitting. Each texture will require unique material ==> increase draw calls.
    But multi-crop feature is still bookmarked for the next updates.



    VacuumShaders - Facebook Twitter YouTube
     
    jGate99 likes this.
  47. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    reason i want multicrop is so i can use it with unity ugui's raw image, then i want to apply seperate material on each texture.
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Split adjustment will be added in the next week update.

    For run-time use Texture2D class will have new Split() extension:
    Code (CSharp):
    1. Texture2D sourceTexture;
    2.  
    3. Texture2D[] newTextures = sourceTexture.Split(4, 5);
    upload_2018-12-7_23-44-43.png



    VacuumShaders - Facebook Twitter YouTube
     
    jGate99 likes this.
  49. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thanks for the update.

    Is there any plans for simplify colours or minimize colours?
    which we can use with pixelate effects

    PS: Happy Christmas
     
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,984
    Currently no. Added to a wishlist.
    But this week update will include some new interesting adjustments.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Mar 24, 2020
    jGate99 likes this.