Archive for September, 2013

Updated version of the Masking shader for NGUI

I did a shader before to mask a texture so that it doesn’t have to be rectangular. Turns out I was using an old version of NGUI, so when I updated (to version 2.65) my previous shader didn’t work anymore. Also Nicki Thomas Hansen made another shader so that you could use the masked texture inside a clipped panel. In doing so he also explained what NGUI was doing and how it was selecting the correct shader. So, based on his AlphaClip, I remade my shader so that it works on the new version of NGUI. Here is the code for it:

Shader "Unlit/Transparent Colored Masked"
{
	Properties
	{
		_MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
		_AlphaTex ("MaskTexture", 2D) = "white" {}
	}
 
	SubShader
	{
		LOD 100
 
		Tags
		{
			"Queue" = "Transparent"
			"IgnoreProjector" = "True"
			"RenderType" = "Transparent"
		}
 
		Cull Off
		Lighting Off
		ZWrite Off
		Fog { Mode Off }
		Offset -1, -1
		Blend SrcAlpha OneMinusSrcAlpha
 
		Pass
		{
			CGPROGRAM
				#pragma vertex vertexProgram
				#pragma fragment fragmentProgram
 
				#include "UnityCG.cginc"
 
				struct appdata_t
				{
					float4 vertex : POSITION;
					float2 textureCoordinate : TEXCOORD0;
					fixed4 color : COLOR;
				};
 
				struct vertexToFragment
				{
					float4 vertex : SV_POSITION;
					half2 textureCoordinate : TEXCOORD0;
					fixed4 color : COLOR;
				};
 
				sampler2D _MainTex;
				float4 _MainTex_ST;
				sampler2D _AlphaTex;
 
				vertexToFragment vertexProgram (appdata_t vertexData)
				{
					vertexToFragment output;
					output.vertex = mul(UNITY_MATRIX_MVP, vertexData.vertex);
					output.textureCoordinate = TRANSFORM_TEX(vertexData.textureCoordinate, _MainTex);
					output.color = vertexData.color;
					return output;
				}
 
				fixed4 fragmentProgram (vertexToFragment input) : COLOR
				{
					fixed4 computedColor = tex2D(_MainTex, input.textureCoordinate) * input.color;
					fixed4 alphaGuide = tex2D(_AlphaTex, input.textureCoordinate);
 
					if (alphaGuide.a < computedColor.a) computedColor.a = alphaGuide.a;
 
					return computedColor;
				}
			ENDCG
		}
	}
}

Funny how writing my previous post solved my future problem by someone else writing an answer post.
I will update the previous post so that it points to this post also.

UPDATE: I renamed all the variables to something readable, I thought it might be useful to understand what it is doing.

, , , , ,

No Comments


Kickstarter is my main new way to get games

I love Kickstarter. I think it is one of the best inventions from this decade. It gives the people a say in what gets made or not and that is a very powerful thing. So I decided that I would participate more to crowd funding. Notably in the video game area. Since I don’t really have time to get into huge games, the type of games usually found on Kickstarter are perfect for me. I’m going to try and buy most of my games from crowd funding.

Here are two games that I participated in:

The Fall

http://www.kickstarter.com/projects/189665092/the-fall-dark-story-driven-exploration-in-an-alien?ref=live

This seems to be made by one guy alone and it looks awesome. Just for that it was worth it to help it a bit. Also who wouldn’t want a deeper /dark metroid?

Sunless Sea

http://www.kickstarter.com/projects/failbetter/sunless-sea?ref=live

I liked the looks on this one, plus they said their inspiration was Don’t starve, FTL and roguelikes; that has to be good.

So there you have it, I think you should back those projects too, so that they are made more awesome. I will leave you with this tip, do not back too many projects at the same time, because you’ll get too many email updates from them.

, , ,

No Comments


What is coming for UI for Unity3D

As you might have guessed it from previous posts, I am currently building UI using NGUI in Unity3D. It is quite challenging to do everything I am used to with Flash. So when I saw this video from Unite 2013 by ArenMook, you can’t believe how happy I was. It solve mostly all the problems I have with doing 2D in Unity. Also I am pretty happy they didn’t go further with the OnGUI stuff, that was really awkward to use.

Here is the video (at the 10 minute mark is the very nice slide!):

 

Now all I am missing are Bitmap filters like blur, drop shadow and glow and you’ll find a pretty happy person in me!

, , , , ,

No Comments