Hi,
I built myself a funny shader which renders one texture for each type of block on a mesh.
This is the shader. The end part of it should render the transparent blocks, but they render black instead of transparent.
What am I doing wrong?
Shader "Custom/light" {
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_Tx1 ("Texture 1", 2D) = "white" {}
_Tx2 ("Texture 2", 2D) = "white" {}
_Tx3 ("Texture 3", 2D) = "white" {}
_Tx4 ("Texture 4", 2D) = "white" {}
_Tx5 ("Texture 5", 2D) = "white" {}
_Tx6 ("Texture 6", 2D) = "white" {}
_Tx7 ("Texture 7", 2D) = "white" {}
_Tx8 ("Texture 8", 2D) = "white" {}
_Tx9 ("Texture 9", 2D) = "white" {}
_Tx10 ("Texture 10", 2D) = "white" {}
_Tx11 ("Texture 11", 2D) = "white" {}
_Tx12 ("Texture 12", 2D) = "white" {}
_Tx13 ("Texture 13", 2D) = "white" {}
_Tx14 ("Texture 14", 2D) = "white" {}
_Tx15 ("Texture 15", 2D) = "white" {}
_Tx16 ("Texture 16", 2D) = "white" {}
_Tx17 ("Texture 17", 2D) = "white" {}
_Tx18 ("Texture 18", 2D) = "white" {}
_Tx19 ("Texture 19", 2D) = "white" {}
_Tx20 ("Texture 20", 2D) = "white" {}
_Tx21 ("Texture 21", 2D) = "white" {}
_Tx22 ("Texture 22", 2D) = "white" {}
_Tx23 ("Texture 23", 2D) = "white" {}
_Tx24 ("Texture 24", 2D) = "white" {}
_Tx25 ("Texture 25", 2D) = "white" {}
_Tx26 ("Texture 26", 2D) = "white" {}
_Tx27 ("Texture 27", 2D) = "white" {}
_Tx28 ("Texture 28", 2D) = "white" {}
_Tx29 ("Texture 29", 2D) = "white" {}
_Tx30 ("Texture 30", 2D) = "white" {}
_Tx31 ("Texture 31", 2D) = "white" {}
_Tx32 ("Texture 32", 2D) = "white" {}
_Tx33 ("Texture 33", 2D) = "white" {}
_Tx34 ("Texture 34", 2D) = "white" {}
_Tx35 ("Texture 35", 2D) = "white" {}
_Tx36 ("Texture 36", 2D) = "white" {}
_Tx37 ("Texture 37", 2D) = "white" {}
_Tx38 ("Texture 38", 2D) = "white" {}
_Tx39 ("Texture 39", 2D) = "white" {}
_Tx40 ("Texture 40", 2D) = "white" {}
_Tx41 ("Texture 41", 2D) = "white" {}
_Tx42 ("Texture 42", 2D) = "white" {}
_Tx43 ("Texture 43", 2D) = "white" {}
_Tx44 ("Texture 44", 2D) = "white" {}
_Tx45 ("Texture 45", 2D) = "white" {}
_Tx46 ("Texture 46", 2D) = "white" {}
_Tx47 ("Texture 47", 2D) = "white" {}
_Tx48 ("Texture 48", 2D) = "white" {}
_Tx49 ("Texture 49", 2D) = "white" {}
_Tx50 ("Texture 50", 2D) = "white" {}
_Tx51 ("Texture 51", 2D) = "white" {}
_Tx52 ("Texture 52", 2D) = "white" {}
_Tx53 ("Texture 53", 2D) = "white" {}
_Tx54 ("Texture 54", 2D) = "white" {}
_Tx55 ("Texture 55", 2D) = "white" {}
_Tx56 ("Texture 56", 2D) = "white" {}
_Tx57 ("Texture 57", 2D) = "white" {}
_Tx58 ("Texture 58", 2D) = "white" {}
_Tx59 ("Texture 59", 2D) = "white" {}
_Tx60 ("Texture 60", 2D) = "white" {}
_Tx61 ("Texture 61", 2D) = "white" {}
_Tx62 ("Texture 62", 2D) = "white" {}
_Tx63 ("Texture 63", 2D) = "white" {}
_Tx64 ("Texture 64", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
Blend One Zero
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _Tx1;
sampler2D _Tx2;
sampler2D _Tx3;
sampler2D _Tx4;
sampler2D _Tx5;
sampler2D _Tx6;
sampler2D _Tx7;
sampler2D _Tx8;
sampler2D _Tx9;
sampler2D _Tx10;
sampler2D _Tx11;
sampler2D _Tx12;
sampler2D _Tx13;
fixed4 _Color;
struct Input {
float2 uv_Tx1;
float2 uv2_Tx2;
};
void surf (Input IN, inout SurfaceOutput o) {
float blockID = IN.uv2_Tx2.x;
fixed4 c=0;
if (blockID>13.5) return;
if ((blockID>=0.99) && (blockID<1.01))
{
c = tex2D(_Tx1, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=1.99) && (blockID<2.01))
{
c = tex2D(_Tx2, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=2.99) && (blockID<3.01))
{
c = tex2D(_Tx3, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=3.99) && (blockID<4.01))
{
c = tex2D(_Tx4, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=4.99) && (blockID<5.01))
{
c = tex2D(_Tx5, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=5.99) && (blockID<6.01))
{
c = tex2D(_Tx6, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=6.99) && (blockID<7.01))
{
c = tex2D(_Tx7, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=7.99) && (blockID<8.01))
{
c = tex2D(_Tx8, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=8.99) && (blockID<9.01))
{
c = tex2D(_Tx9, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=9.99) && (blockID<10.01))
{
c = tex2D(_Tx10, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=10.99) && (blockID<11.01))
{
c = tex2D(_Tx11, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=11.99) && (blockID<12.01))
{
c = tex2D(_Tx12, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=12.99) && (blockID<13.01))
{
c = tex2D(_Tx13, IN.uv_Tx1) * _Color;
o.Albedo = c.rgb;
return;
}
}
ENDCG
Blend One One
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _Tx14;
sampler2D _Tx15;
sampler2D _Tx16;
sampler2D _Tx17;
sampler2D _Tx18;
sampler2D _Tx19;
sampler2D _Tx20;
sampler2D _Tx21;
sampler2D _Tx22;
sampler2D _Tx23;
sampler2D _Tx24;
sampler2D _Tx25;
sampler2D _Tx26;
fixed4 _Color;
struct Input {
float2 uv_Tx14;
float2 uv2_Tx15;
};
void surf (Input IN, inout SurfaceOutput o) {
float blockID = IN.uv2_Tx15.x;
//fixed4 c = tex2D(_Tx1, IN.uv_MainTex) * _Color;
fixed4 c=0;
if (blockID>26.5) return;
if (blockID<13.5) return;
if ((blockID>=13.99) && (blockID<14.01))
{
c = tex2D(_Tx14, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=14.99) && (blockID<15.01))
{
c = tex2D(_Tx15, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=15.99) && (blockID<16.01))
{
c = tex2D(_Tx16, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=16.99) && (blockID<17.01))
{
c = tex2D(_Tx17, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=17.99) && (blockID<18.01))
{
c = tex2D(_Tx18, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=18.99) && (blockID<19.01))
{
c = tex2D(_Tx19, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=19.99) && (blockID<20.01))
{
c = tex2D(_Tx20, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=20.99) && (blockID<21.01))
{
c = tex2D(_Tx21, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=21.99) && (blockID<22.01))
{
c = tex2D(_Tx22, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=22.99) && (blockID<23.01))
{
c = tex2D(_Tx23, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=23.99) && (blockID<24.01))
{
c = tex2D(_Tx24, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=24.99) && (blockID<25.01))
{
c = tex2D(_Tx25, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=25.99) && (blockID<26.01))
{
c = tex2D(_Tx26, IN.uv_Tx14) * _Color;
o.Albedo = c.rgb;
return;
}
}
ENDCG
Blend One One
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _Tx27;
sampler2D _Tx28;
sampler2D _Tx29;
sampler2D _Tx30;
sampler2D _Tx31;
sampler2D _Tx32;
sampler2D _Tx33;
sampler2D _Tx34;
sampler2D _Tx35;
sampler2D _Tx36;
sampler2D _Tx37;
sampler2D _Tx38;
sampler2D _Tx39;
fixed4 _Color;
struct Input {
float2 uv_Tx27;
float2 uv2_Tx28;
};
void surf (Input IN, inout SurfaceOutput o) {
float blockID = IN.uv2_Tx28.x;
//fixed4 c = tex2D(_Tx1, IN.uv_MainTex) * _Color;
fixed4 c=0;
if (blockID>39.5) return;
if (blockID<26.5) return;
if ((blockID>=26.99) && (blockID<27.01))
{
c = tex2D(_Tx27, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=27.99) && (blockID<28.01))
{
c = tex2D(_Tx28, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=28.99) && (blockID<29.01))
{
c = tex2D(_Tx29, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=29.99) && (blockID<30.01))
{
c = tex2D(_Tx30, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=30.99) && (blockID<31.01))
{
c = tex2D(_Tx31, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=31.99) && (blockID<32.01))
{
c = tex2D(_Tx32, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=32.99) && (blockID<33.01))
{
c = tex2D(_Tx33, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=33.99) && (blockID<34.01))
{
c = tex2D(_Tx34, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=34.99) && (blockID<35.01))
{
c = tex2D(_Tx35, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=35.99) && (blockID<36.01))
{
c = tex2D(_Tx36, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=36.99) && (blockID<37.01))
{
c = tex2D(_Tx37, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=37.99) && (blockID<38.01))
{
c = tex2D(_Tx38, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=38.99) && (blockID<39.01))
{
c = tex2D(_Tx39, IN.uv_Tx27) * _Color;
o.Albedo = c.rgb;
return;
}
}
ENDCG
Blend One One
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _Tx40;
sampler2D _Tx41;
sampler2D _Tx42;
sampler2D _Tx43;
sampler2D _Tx44;
sampler2D _Tx45;
sampler2D _Tx46;
sampler2D _Tx47;
sampler2D _Tx48;
sampler2D _Tx49;
sampler2D _Tx50;
sampler2D _Tx51;
sampler2D _Tx52;
fixed4 _Color;
struct Input {
float2 uv_Tx40;
float2 uv2_Tx41;
};
void surf (Input IN, inout SurfaceOutput o) {
float blockID = IN.uv2_Tx41.x;
fixed4 c=0;
if (blockID>52.5) return;
if (blockID<39.5) return;
if ((blockID>=39.99) && (blockID<40.01))
{
c = tex2D(_Tx40, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=40.99) && (blockID<41.01))
{
c = tex2D(_Tx41, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=41.99) && (blockID<42.01))
{
c = tex2D(_Tx42, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=42.99) && (blockID<43.01))
{
c = tex2D(_Tx43, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=43.99) && (blockID<44.01))
{
c = tex2D(_Tx44, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=44.99) && (blockID<45.01))
{
c = tex2D(_Tx45, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=45.99) && (blockID<46.01))
{
c = tex2D(_Tx46, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=46.99) && (blockID<47.01))
{
c = tex2D(_Tx47, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=47.99) && (blockID<48.01))
{
c = tex2D(_Tx48, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=48.99) && (blockID<49.01))
{
c = tex2D(_Tx49, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=49.99) && (blockID<50.01))
{
c = tex2D(_Tx50, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=50.99) && (blockID<51.01))
{
c = tex2D(_Tx51, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=51.99) && (blockID<52.01))
{
c = tex2D(_Tx52, IN.uv_Tx40) * _Color;
o.Albedo = c.rgb;
return;
}
}
ENDCG
[B]Blend SrcAlpha One
CGPROGRAM
#pragma surface surf Lambert alpha
#pragma target 3.0
sampler2D _Tx53;
sampler2D _Tx54;
sampler2D _Tx55;
sampler2D _Tx56;
sampler2D _Tx57;
sampler2D _Tx58;
sampler2D _Tx59;
sampler2D _Tx60;
sampler2D _Tx61;
sampler2D _Tx62;
sampler2D _Tx63;
sampler2D _Tx64;
sampler2D _Tx65;
fixed4 _Color;
struct Input {
float2 uv_Tx53;
float2 uv2_Tx54;
};
void surf (Input IN, inout SurfaceOutput o) {
float blockID = IN.uv2_Tx54.x;
if (blockID>64.5) return;
if (blockID<52.5) return;
fixed4 c=0.5;
if ((blockID>=52.99) && (blockID<53.01))
{
c = tex2D(_Tx53, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=53.99) && (blockID<54.01))
{
c = tex2D(_Tx54, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=54.99) && (blockID<55.01))
{
c = tex2D(_Tx55, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=55.99) && (blockID<56.01))
{
c = tex2D(_Tx56, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=56.99) && (blockID<57.01))
{
c = tex2D(_Tx57, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=57.99) && (blockID<58.01))
{
c = tex2D(_Tx58, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=58.99) && (blockID<59.01))
{
c = tex2D(_Tx59, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=59.99) && (blockID<60.01))
{
c = tex2D(_Tx60, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=60.99) && (blockID<61.01))
{
c = tex2D(_Tx61, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=61.99) && (blockID<62.01))
{
c = tex2D(_Tx62, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=62.99) && (blockID<63.01))
{
c = tex2D(_Tx63, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
if ((blockID>=63.99) && (blockID<64.01))
{
c = tex2D(_Tx64, IN.uv_Tx53) * _Color;
o.Albedo = c.rgb;
return;
}
o.Alpha=0.5;[/B]
}
ENDCG
}
}