76
NGUI 3 Support / Re: UISprite not rendered to RenderTexture alpha while UITexture/UILabel are
« on: September 19, 2014, 06:38:19 PM »
: )
Yeah, I already pinned the issue down to premultiplied shaders not actually creating any alpha output. Standard transparent shaders used by UITexture work.
Can you tell me what am I losing quality wise if I were to switch to non-premultiplied shaders? Or it's only a matter of saving texture size (RGB vs RGBA) and being compliant with some mobile hardware?
Edit: Erm... yeah, it's not as simple as I thought. Changing the shader on the altas material has no effect. I guess I need to reimport it?
Edit 2: Okay, a big problem - a black sprite with 50% alpha writes 50% background color + 50% black into RGB of the render texture instead of 100% black, which kills the look of every single semi-transparent element.
Edit 3: This can be hidden if you can agree to only use one color for every semi-transparent UI element ever - by setting the clear color of the camera to that color, ensuring that RGB values rendered to texture will stay right. In my case, with black semi-transparent frame fills, that would be setting the camera clear color to black. But that's not ideal as I'd prefer camera clear color to be white, to avoid black leaking into predominantly white UI pixels.
Edit 4: I wonder if the issue can be resolved by creating a custom NGUI shader that writes proper transparency to alpha while refusing to actually display that transparency for the camera when there are no other pixels rendered using that shader underneath, rendering sprite color at full intensity in that case. That will lead to completely proper colors being fed to the RenderTexture, but doing so indiscriminately will kill any and all overlays, potentially leading to background sprites overwriting white text with black in render texture RGB, and other nasty issues. I'm not sure if it's possible to do right.
Yeah, I already pinned the issue down to premultiplied shaders not actually creating any alpha output. Standard transparent shaders used by UITexture work.
Can you tell me what am I losing quality wise if I were to switch to non-premultiplied shaders? Or it's only a matter of saving texture size (RGB vs RGBA) and being compliant with some mobile hardware?
Edit: Erm... yeah, it's not as simple as I thought. Changing the shader on the altas material has no effect. I guess I need to reimport it?
Edit 2: Okay, a big problem - a black sprite with 50% alpha writes 50% background color + 50% black into RGB of the render texture instead of 100% black, which kills the look of every single semi-transparent element.
Edit 3: This can be hidden if you can agree to only use one color for every semi-transparent UI element ever - by setting the clear color of the camera to that color, ensuring that RGB values rendered to texture will stay right. In my case, with black semi-transparent frame fills, that would be setting the camera clear color to black. But that's not ideal as I'd prefer camera clear color to be white, to avoid black leaking into predominantly white UI pixels.
Edit 4: I wonder if the issue can be resolved by creating a custom NGUI shader that writes proper transparency to alpha while refusing to actually display that transparency for the camera when there are no other pixels rendered using that shader underneath, rendering sprite color at full intensity in that case. That will lead to completely proper colors being fed to the RenderTexture, but doing so indiscriminately will kill any and all overlays, potentially leading to background sprites overwriting white text with black in render texture RGB, and other nasty issues. I'm not sure if it's possible to do right.