Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

SDF Toolkit - Now Released

Discussion in 'Works In Progress - Archive' started by Jasper-Flick, Mar 26, 2015.

  1. nicloay

    nicloay

    Joined:
    Jul 11, 2012
    Posts:
    540
    not an issue if it's just an emulator problem. If it works on the device I'm ok with that.
     
  2. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Practically all modern OpenGL ES 2+ devices support derivatives. If you specifically want to target ancient hardware, you'll have to use a material with manual smoothing and without supersampling. Supersampling isn't a great idea for mobiles anyway, as it's costly.
     
  3. nicloay

    nicloay

    Joined:
    Jul 11, 2012
    Posts:
    540
    No. the problem was that this was the most latest api (25) where I faced this problem, not the old devices. You can try it by yourself. Enable virtualisation in bios then in android studio run AVD manager and create new device with latest android API. and then just make a build for android as you do when your device is conecte through USB but in this case build will go to the emulator.
     
  4. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    Is there any I can use some shader as a UI mask?
     
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    You can use the contour to shape the form of a material, but it doesn't work with Unity's UI masking. The Mask component uses the stencil buffer, using raw image alpha as a binary mask. Contours can work with a custom soft masking approach, but you'd have to set that up yourself.
     
  6. Malkyne

    Malkyne

    Joined:
    Nov 18, 2009
    Posts:
    39
    I was already using TextMesh Pro (which uses the same technique) for my text in a particular project, and I thought I might try this out, to see if it will do the same great thing for some larger icons that I didn't want to move into an icon font, since I wasn't really using them inline, anywhere.

    I was able to get some very nice results from this, for clean, simple icon outlines at many sizes. That part worked great, with no problems.

    However, since it seems to ignore the Image Color, I haven't been able to figure out a way to independently vary the colors of icons that use the same material. I don't really want a separate draw call for every single icon color I might want to use on the screen at once. Did I miss a sneaky trick to make this work, or is it just not supported, at this time?
     
  7. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Sprite coloring in Unity's UI is done via vertex colors. You can enable vertex colors for the first and/or second contour via the checkboxes on the albedo material property lines in the material inspector. You can also just use the albedo texture.
     
  8. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Just a quick question: Does it work with 3D, i.e. highlighting edges by a certain angle treshold?
     
  9. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    It works with SDF textures. It isn't a post-processing effect.
     
  10. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    Screenshot_2.png I just got a whole bunch of errors when importing the package into Unity2018.1.5.
     
  11. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    The errors are caused by breaking changes to Unity's lighting macros for additive lights for the default pipeline. If you're not using forward rendering with additional lights, you can ignore the errors, or ideally remove the additive light passes from the shaders. I'm working on a fix.
     
  12. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    Hey there,

    I recently purchased SDF Toolkit and want to try and convert the SDF to read from the textures red channel so that I can use BC4 single(Red) channel compression. Is there a reason why the toolkit isnt already doing this?
     
  13. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Compression doesn't work well with SDF contour rendering. Block Compression quantizes and linearizes the gradient in 4x4 blocks, which destroys details and curves. Your best bet is to stick with an 8-bit single-channel texture. As you don't need huge maps, alpha8 textures don't take much space, especially when not using mip maps. You can see the quality drop BC causes by using DXT5 compression with an alpha texture.