A Much Simpler UIToolkit Shader (Unity)

A much simpler, even slightly more efficient, shader that works with Prime31’s UIToolkit (for Unity). This shaders removes the alpha test (an expensive operation on iDevices), replaces tint colour with a simple main colour (allows you to control a sprite’s alpha), and uses premultiplied alpha in the source texture. Premultiplied alpha’s help to reduce colour bleeding giving you a better visual result, are slightly less computationally expensive, and are supported by TexturePacker.

You may reuse or distribute this code in any way without either notification or credit.

Shader "Custom/UI Premultiplied Alpha"
		_Color( "Main Color", Color ) = ( 1, 1, 1, 1 )
		_MainTex( "UI Texture", 2D ) = "white" {}

		Tags { "Queue" = "Transparent" }
		Blend One OneMinusSrcAlpha
		ColorMask RGB
		Cull Off
		Lighting Off
		ZWrite On

			Bind "Vertex", vertex
			Bind "TexCoord", texcoord

					combine texture * constant ConstantColor[_Color]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: