Author Topic: Unwanted font transparency  (Read 9527 times)

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Unwanted font transparency
« on: November 27, 2013, 08:43:14 AM »
Hi, I'm struggling with this problem for too much time, please help.

I have three cameras in the scene with different dephts, the first one contains only UItexture on which WebCamTexture is shown (UIRoot1>firstCam>anchor etc). The second one is non-ngui camera with 3d object and the last one with biggest depht contains main ngui elements (UIRoot2>lastCam>anchor etc). The idea is to show this 3d object between video background and GUI, and it works fine. The problem is with labels (Dynamic font) in the main ngui tree(under last camera), where text appears semi-transparent when testing on Android device (its ok in editor).

I've tried changing materials for these labels, shaders, and some approaches from this forum but nothing helped me, so my question is what's the correct way of making font fully opaque over such background? And beside that, is it correct to modify text colors via UILabel widget color?

using 3.0.6 f3

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #1 on: November 27, 2013, 10:09:28 AM »
Can you post a pic? From your description what you're doing should be fine, but you should use a solid shader for your web cam texture such as Unlit/Texture.

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #2 on: November 27, 2013, 11:18:56 AM »
Funny thing is that screenshots differ from what can be seen on device screen. Here are two pieces of screenshots, first one with camera heading a wall and second with camera coverred with hand - there's no difference with text on them, however when looking on the screen during runtime it looks like camera view "shines through" font.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #3 on: November 27, 2013, 11:27:13 AM »
I've only seen this happen when rendering to texture. Are you?

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #4 on: November 28, 2013, 05:05:11 AM »
Well it's not UICamera being rendered to a texture, it's a simple script in UITexture gameobject:

  1.         video = new WebCamTexture();
  2.         video.Play();
  3.         gameObject.GetComponent<UITexture>().mainTexture = video;

If that's what you mean, is there more appropriate way to display video?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #5 on: November 28, 2013, 03:05:04 PM »
Interesting... I haven't looked at WebCamTexture. I'll check it out in a bit.

Is the web cam texture you're drawing in front or behind the label? Which shader is used by the label?

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #6 on: November 28, 2013, 06:31:54 PM »
it's behind the label which uses Unlit/Dynamic Font shader.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #7 on: November 28, 2013, 06:44:21 PM »
Learning something new here. Here's a quick test. Made a Texture, made a label on top of it. Attached the following script to the texture:
  1. using UnityEngine;
  2.  
  3. public class Test : MonoBehaviour
  4. {
  5.         WebCamTexture tex;
  6.  
  7.         void Start ()
  8.         {
  9.                 WebCamDevice[] devices = WebCamTexture.devices;
  10.                 tex = new WebCamTexture(devices[0].name, 512, 512);
  11.                 tex.Play();
  12.                 GetComponent<UITexture>().mainTexture = tex;
  13.         }
  14.  
  15.         void OnDestroy ()
  16.         {
  17.                 Destroy(tex);
  18.         }
  19. }

Result:

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #8 on: November 29, 2013, 06:11:48 AM »
Your test, displaying result on Xperia Mini Pro (SK17i) with Android 2.3.3 (nGUI 3.0.6 f3):

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #9 on: November 29, 2013, 06:36:34 AM »
another few samples with buttons behind, this time nGUI 3.0.6 f6:

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #10 on: November 29, 2013, 08:56:36 AM »
So does this only happen on your Xperia device?

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #11 on: November 29, 2013, 09:46:39 AM »
I think it was happening on other devices too, but propably after those nGUI fixes it occurs only on this Xperia. Maybe I will try to update it to Android 4 later and look again, but I wonder what's the problem now - incompatible shaders?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unwanted font transparency
« Reply #12 on: November 29, 2013, 09:49:56 AM »
Just a thought but did you make sure that your main camera's clear color's alpha is full 255? Unity starts it at 5 / 255 by default, which causes a problem with some mobile devices.

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #13 on: December 02, 2013, 09:51:39 AM »
I use Depth Only option, but full alpha background doesnt help either.

rize

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Unwanted font transparency
« Reply #14 on: December 04, 2013, 11:54:31 AM »
So it looks that in case of this device I have to make a workaround adjusting Camera's FOV  :-\