Preserve Code Plugin Test

Just installed a plugin that declares that it will preserve code formatting… let’s see how well it works with some shader programming…


Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord2 : TEXCOORD1;
fixed4 color : COLOR;
};

struct v2f
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord2 : TEXCOORD1;
fixed4 color : COLOR;
};

sampler2D _MainTex;
sampler2D _DetailTex;
float4 _MainTex_ST;
float4 _DetailTex_ST;
float4 _DetailTex_TexelSize;
fixed4 _Color;
fixed _Strength;

v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.texcoord2 = TRANSFORM_TEX(v.texcoord2 * _DetailTex_TexelSize.xy, _DetailTex);
o.color = v.color;
return o;
}

half4 frag (v2f i) : COLOR
{
half4 col = i.color;
fixed4 detail = tex2D(_DetailTex, i.texcoord2);
col.rgb = lerp(col.rgb, col.rgb * detail.rgb, detail.a * _Strength);
col.a *= tex2D(_MainTex, i.texcoord).a;
col = col * _Color;
clip (col.a - 0.01);
return col;
}
ENDCG
}

Seems to work pretty well, but I ended up editing the HTML & pasting the code in that view. I’ll see how it goes over the next few weeks.

Leave a Reply