Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: soulburner on November 22, 2014, 05:34:52 AM

Title: Can you please add new Outline8 effect? (code inside)
Post by: soulburner on November 22, 2014, 05:34:52 AM
Hi there!

I'm making a pixelart game and I need to make a good outline for my pixel fonts. I know that I can bake outline in the font texture, but I don't want to make it static. I want to change outline color, etc.

So, the best way for me is to use your outline effect. But the bad thing is that it make only 4 copies of the label in 4 directions. That looks really bad on fonts of 1-pixel width. So, I've made a version that makes 8 copies in 8 directions (not only diagonals, but vertical/horizontal too).

I've attached the screenshot to illustrate what I need.

So, please, can you add it to the NGUI build so I will not need to modify NGUI every time I update? :)

Code is below and is pretty simple:


UILabel.OnFill()

  1.                         if ((effectStyle == Effect.Outline) || (effectStyle == Effect.Outline8))
  2.                         {
  3.                                 offset = end;
  4.                                 end = verts.size;
  5.  
  6.                                 ApplyShadow(verts, uvs, cols, offset, end, -pos.x, pos.y);
  7.  
  8.                                 offset = end;
  9.                                 end = verts.size;
  10.  
  11.                                 ApplyShadow(verts, uvs, cols, offset, end, pos.x, pos.y);
  12.  
  13.                                 offset = end;
  14.                                 end = verts.size;
  15.  
  16.                                 ApplyShadow(verts, uvs, cols, offset, end, -pos.x, -pos.y);
  17.                         }
  18.  
  19.                         if (effectStyle == Effect.Outline8)
  20.                         {
  21.                                 offset = end;
  22.                                 end = verts.size;
  23.  
  24.                                 ApplyShadow(verts, uvs, cols, offset, end, -pos.x, 0);
  25.  
  26.                                 offset = end;
  27.                                 end = verts.size;
  28.  
  29.                                 ApplyShadow(verts, uvs, cols, offset, end, pos.x, 0);
  30.  
  31.                                 offset = end;
  32.                                 end = verts.size;
  33.  
  34.                                 ApplyShadow(verts, uvs, cols, offset, end, 0, pos.y);
  35.  
  36.                                 offset = end;
  37.                                 end = verts.size;
  38.  
  39.                                 ApplyShadow(verts, uvs, cols, offset, end, 0, -pos.y);
  40.                         }
  41.  
Title: Re: Can you please add new Outline8 effect? (code inside)
Post by: ArenMook on November 22, 2014, 01:09:23 PM
Sure, I can add this code. Just keep in mind, this is really bad for fillrate. You are effectively drawing to the same pixels 9 times. You will get significantly better performance by baking this effect into your font.
Title: Re: Can you please add new Outline8 effect? (code inside)
Post by: soulburner on November 24, 2014, 07:51:21 AM
Thanks a lot!

Sure, I understand performance issues, but I'm ok with it.