Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Feature Request Feathered Sprite Mask / Uniform transparency on multiple sprite renderer group

Discussion in '2D' started by rarac, Aug 3, 2022.

  1. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    I write this post not asking for these features, just wondering if they are possible to be added into unity or if there are any plans at all to add them in the future ( even if it means it may take years )

    Feature 1: Feathered Sprite Mask:

    As the title says just the sprite mask feature but with masking 50% of the sprite if the pixels on the mask are 50% transparent, i think its self explanatory.

    Feature 2: Merging a bunch of sprite renderers into a group and being able to change the transparency on that group in a uniform way:

    if you overlay 3 circles opaque in a triangle shape and then change the opacities it will look like it was a venn diagram instead of keeping its past solid shape, just now transparent, in other words each sprite renderer has its own transparency and will bleed to each other unless you merge them with code into 1 single sprite renderer.

    there are workarounds right now to fix these but they are messy, you have to use shaders, i was wondering if there was some sort of quality of life on these features eventually planned for the future, or if the architectures in place simply are not worth meddling with to try to deploy these features in the near or far future. Anyway appreciate your time reading.
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    1. "Masking" as a concept in Unity (SpriteMask, RectMask, etc) uses the Stencil Buffer, in which a pixel can either be on or off. A soft alpha mask is absolutely possible but will not work with the built-in masking systems. A dithered mask is another option (using a dither pattern texture to feather the edge instead of alpha). Otherwise google "unity soft alpha mask" to find out what your options are (tutorials, plugins, etc).

    2. Probably the easiest way to do that is to render the sprites with a camera into a RenderTexture, and then replace the sprites with the single new texture and fade it.

    There is a demo package of that approach posted from January: https://forum.unity.com/threads/how...n-sprite-renderer-image.1233103/#post-7856314
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,102
    I did it by "photographing" the combined sprites (no alpha), then rendering the final result with alpha.

    See enclosed package.
     

    Attached Files:

  4. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    i know there are workarounds, probably for 1. then its a no go, would require totally different approach.
    For 2 it seems like it will be a lot of hassle to integrate. using like 1000 render textures prob wont be the best way either
     
  5. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    You can most likely keep reusing the same render texture, unless you really need multiple at the same time. Once you render the image to the render texture, you can create new textures from the data and save them to disk if you need them in future sessions. Then just use the same render texture again for the next one.