Search Unity

Transparent blocks are black instead of transparent!

Discussion in 'Shaders' started by ciprianb, Jul 18, 2014.

  1. ciprianb

    ciprianb

    Joined:
    Oct 11, 2013
    Posts:
    32
    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?
    Code (CSharp):
    1. Shader "Custom/light" {
    2. Properties
    3. {
    4.     _Color ("Main Color", Color) = (1,1,1,1)
    5.     _Tx1 ("Texture 1", 2D) = "white" {}
    6.     _Tx2 ("Texture 2", 2D) = "white" {}
    7.     _Tx3 ("Texture 3", 2D) = "white" {}
    8.     _Tx4 ("Texture 4", 2D) = "white" {}
    9.     _Tx5 ("Texture 5", 2D) = "white" {}
    10.     _Tx6 ("Texture 6", 2D) = "white" {}
    11.     _Tx7 ("Texture 7", 2D) = "white" {}
    12.     _Tx8 ("Texture 8", 2D) = "white" {}
    13.     _Tx9 ("Texture 9", 2D) = "white" {}
    14.     _Tx10 ("Texture 10", 2D) = "white" {}
    15.     _Tx11 ("Texture 11", 2D) = "white" {}
    16.     _Tx12 ("Texture 12", 2D) = "white" {}
    17.     _Tx13 ("Texture 13", 2D) = "white" {}
    18.     _Tx14 ("Texture 14", 2D) = "white" {}
    19.     _Tx15 ("Texture 15", 2D) = "white" {}
    20.     _Tx16 ("Texture 16", 2D) = "white" {}
    21.     _Tx17 ("Texture 17", 2D) = "white" {}
    22.     _Tx18 ("Texture 18", 2D) = "white" {}
    23.     _Tx19 ("Texture 19", 2D) = "white" {}
    24.     _Tx20 ("Texture 20", 2D) = "white" {}
    25.     _Tx21 ("Texture 21", 2D) = "white" {}
    26.     _Tx22 ("Texture 22", 2D) = "white" {}
    27.     _Tx23 ("Texture 23", 2D) = "white" {}
    28.     _Tx24 ("Texture 24", 2D) = "white" {}
    29.     _Tx25 ("Texture 25", 2D) = "white" {}
    30.     _Tx26 ("Texture 26", 2D) = "white" {}
    31.     _Tx27 ("Texture 27", 2D) = "white" {}
    32.     _Tx28 ("Texture 28", 2D) = "white" {}
    33.     _Tx29 ("Texture 29", 2D) = "white" {}
    34.     _Tx30 ("Texture 30", 2D) = "white" {}
    35.     _Tx31 ("Texture 31", 2D) = "white" {}
    36.     _Tx32 ("Texture 32", 2D) = "white" {}
    37.     _Tx33 ("Texture 33", 2D) = "white" {}
    38.     _Tx34 ("Texture 34", 2D) = "white" {}
    39.     _Tx35 ("Texture 35", 2D) = "white" {}
    40.     _Tx36 ("Texture 36", 2D) = "white" {}
    41.     _Tx37 ("Texture 37", 2D) = "white" {}
    42.     _Tx38 ("Texture 38", 2D) = "white" {}
    43.     _Tx39 ("Texture 39", 2D) = "white" {}
    44.     _Tx40 ("Texture 40", 2D) = "white" {}
    45.     _Tx41 ("Texture 41", 2D) = "white" {}
    46.     _Tx42 ("Texture 42", 2D) = "white" {}
    47.     _Tx43 ("Texture 43", 2D) = "white" {}
    48.     _Tx44 ("Texture 44", 2D) = "white" {}
    49.     _Tx45 ("Texture 45", 2D) = "white" {}
    50.     _Tx46 ("Texture 46", 2D) = "white" {}
    51.     _Tx47 ("Texture 47", 2D) = "white" {}
    52.     _Tx48 ("Texture 48", 2D) = "white" {}
    53.     _Tx49 ("Texture 49", 2D) = "white" {}
    54.     _Tx50 ("Texture 50", 2D) = "white" {}
    55.     _Tx51 ("Texture 51", 2D) = "white" {}
    56.     _Tx52 ("Texture 52", 2D) = "white" {}
    57.     _Tx53 ("Texture 53", 2D) = "white" {}
    58.     _Tx54 ("Texture 54", 2D) = "white" {}
    59.     _Tx55 ("Texture 55", 2D) = "white" {}
    60.     _Tx56 ("Texture 56", 2D) = "white" {}
    61.     _Tx57 ("Texture 57", 2D) = "white" {}
    62.     _Tx58 ("Texture 58", 2D) = "white" {}
    63.     _Tx59 ("Texture 59", 2D) = "white" {}
    64.     _Tx60 ("Texture 60", 2D) = "white" {}
    65.     _Tx61 ("Texture 61", 2D) = "white" {}
    66.     _Tx62 ("Texture 62", 2D) = "white" {}
    67.     _Tx63 ("Texture 63", 2D) = "white" {}
    68.     _Tx64 ("Texture 64", 2D) = "white" {}
    69. }
    70.  
    71. SubShader {
    72.     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
    73.     LOD 200
    74.  
    75. Blend One Zero
    76. CGPROGRAM
    77. #pragma surface surf Lambert
    78. #pragma target 3.0  
    79.  
    80.  
    81. sampler2D _Tx1;
    82. sampler2D _Tx2;
    83. sampler2D _Tx3;
    84. sampler2D _Tx4;
    85. sampler2D _Tx5;
    86. sampler2D _Tx6;
    87. sampler2D _Tx7;
    88. sampler2D _Tx8;
    89. sampler2D _Tx9;
    90. sampler2D _Tx10;
    91. sampler2D _Tx11;
    92. sampler2D _Tx12;
    93. sampler2D _Tx13;
    94.  
    95. fixed4 _Color;
    96.  
    97.  
    98. struct Input {
    99.     float2 uv_Tx1;
    100.     float2 uv2_Tx2;
    101. };
    102.  
    103. void surf (Input IN, inout SurfaceOutput o) {
    104.     float blockID = IN.uv2_Tx2.x;
    105.     fixed4 c=0;
    106.     if (blockID>13.5) return;
    107.     if ((blockID>=0.99) && (blockID<1.01))
    108.     {
    109.     c = tex2D(_Tx1, IN.uv_Tx1) * _Color;
    110.     o.Albedo = c.rgb;
    111.     return;
    112.     }
    113.     if ((blockID>=1.99) && (blockID<2.01))
    114.     {
    115.     c = tex2D(_Tx2, IN.uv_Tx1) * _Color;
    116.     o.Albedo = c.rgb;
    117.     return;
    118.     }
    119.     if ((blockID>=2.99) && (blockID<3.01))
    120.     {
    121.     c = tex2D(_Tx3, IN.uv_Tx1) * _Color;
    122.     o.Albedo = c.rgb;
    123.     return;
    124.     }
    125.     if ((blockID>=3.99) && (blockID<4.01))
    126.     {
    127.     c = tex2D(_Tx4, IN.uv_Tx1) * _Color;
    128.     o.Albedo = c.rgb;
    129.     return;
    130.     }
    131.     if ((blockID>=4.99) && (blockID<5.01))
    132.     {
    133.     c = tex2D(_Tx5, IN.uv_Tx1) * _Color;
    134.     o.Albedo = c.rgb;
    135.     return;
    136.     }
    137.     if ((blockID>=5.99) && (blockID<6.01))
    138.     {
    139.     c = tex2D(_Tx6, IN.uv_Tx1) * _Color;
    140.     o.Albedo = c.rgb;
    141.     return;
    142.     }
    143.     if ((blockID>=6.99) && (blockID<7.01))
    144.     {
    145.     c = tex2D(_Tx7, IN.uv_Tx1) * _Color;
    146.     o.Albedo = c.rgb;
    147.     return;
    148.     }
    149.     if ((blockID>=7.99) && (blockID<8.01))
    150.     {
    151.     c = tex2D(_Tx8, IN.uv_Tx1) * _Color;
    152.     o.Albedo = c.rgb;
    153.     return;
    154.     }
    155.     if ((blockID>=8.99) && (blockID<9.01))
    156.     {
    157.     c = tex2D(_Tx9, IN.uv_Tx1) * _Color;
    158.     o.Albedo = c.rgb;
    159.     return;
    160.     }
    161.     if ((blockID>=9.99) && (blockID<10.01))
    162.     {
    163.     c = tex2D(_Tx10, IN.uv_Tx1) * _Color;
    164.     o.Albedo = c.rgb;
    165.     return;
    166.     }
    167.     if ((blockID>=10.99) && (blockID<11.01))
    168.     {
    169.     c = tex2D(_Tx11, IN.uv_Tx1) * _Color;
    170.     o.Albedo = c.rgb;
    171.     return;
    172.     }
    173.     if ((blockID>=11.99) && (blockID<12.01))
    174.     {
    175.     c = tex2D(_Tx12, IN.uv_Tx1) * _Color;
    176.     o.Albedo = c.rgb;
    177.     return;
    178.     }
    179.     if ((blockID>=12.99) && (blockID<13.01))
    180.     {
    181.     c = tex2D(_Tx13, IN.uv_Tx1) * _Color;
    182.     o.Albedo = c.rgb;
    183.     return;
    184.     }
    185.  
    186. }
    187. ENDCG
    188.  
    189. Blend One One
    190. CGPROGRAM
    191. #pragma surface surf Lambert
    192. #pragma target 3.0  
    193.  
    194.  
    195. sampler2D _Tx14;
    196. sampler2D _Tx15;
    197. sampler2D _Tx16;
    198. sampler2D _Tx17;
    199. sampler2D _Tx18;
    200. sampler2D _Tx19;
    201. sampler2D _Tx20;
    202. sampler2D _Tx21;
    203. sampler2D _Tx22;
    204. sampler2D _Tx23;
    205. sampler2D _Tx24;
    206. sampler2D _Tx25;
    207. sampler2D _Tx26;
    208.  
    209. fixed4 _Color;
    210.  
    211.  
    212. struct Input {
    213.     float2 uv_Tx14;
    214.     float2 uv2_Tx15;
    215. };
    216.  
    217. void surf (Input IN, inout SurfaceOutput o) {
    218.     float blockID = IN.uv2_Tx15.x;
    219.     //fixed4 c = tex2D(_Tx1, IN.uv_MainTex) * _Color;
    220.     fixed4 c=0;
    221.     if (blockID>26.5) return;
    222.     if (blockID<13.5) return;
    223.     if ((blockID>=13.99) && (blockID<14.01))
    224.     {
    225.     c = tex2D(_Tx14, IN.uv_Tx14) * _Color;
    226.     o.Albedo = c.rgb;
    227.     return;
    228.     }
    229.     if ((blockID>=14.99) && (blockID<15.01))
    230.     {
    231.     c = tex2D(_Tx15, IN.uv_Tx14) * _Color;
    232.     o.Albedo = c.rgb;
    233.     return;
    234.     }
    235.     if ((blockID>=15.99) && (blockID<16.01))
    236.     {
    237.     c = tex2D(_Tx16, IN.uv_Tx14) * _Color;
    238.     o.Albedo = c.rgb;
    239.     return;
    240.     }
    241.     if ((blockID>=16.99) && (blockID<17.01))
    242.     {
    243.     c = tex2D(_Tx17, IN.uv_Tx14) * _Color;
    244.     o.Albedo = c.rgb;
    245.     return;
    246.     }
    247.     if ((blockID>=17.99) && (blockID<18.01))
    248.     {
    249.     c = tex2D(_Tx18, IN.uv_Tx14) * _Color;
    250.     o.Albedo = c.rgb;
    251.     return;
    252.     }
    253.     if ((blockID>=18.99) && (blockID<19.01))
    254.     {
    255.     c = tex2D(_Tx19, IN.uv_Tx14) * _Color;
    256.     o.Albedo = c.rgb;
    257.     return;
    258.     }
    259.     if ((blockID>=19.99) && (blockID<20.01))
    260.     {
    261.     c = tex2D(_Tx20, IN.uv_Tx14) * _Color;
    262.     o.Albedo = c.rgb;
    263.     return;
    264.     }
    265.     if ((blockID>=20.99) && (blockID<21.01))
    266.     {
    267.     c = tex2D(_Tx21, IN.uv_Tx14) * _Color;
    268.     o.Albedo = c.rgb;
    269.     return;
    270.     }
    271.     if ((blockID>=21.99) && (blockID<22.01))
    272.     {
    273.     c = tex2D(_Tx22, IN.uv_Tx14) * _Color;
    274.     o.Albedo = c.rgb;
    275.     return;
    276.     }
    277.     if ((blockID>=22.99) && (blockID<23.01))
    278.     {
    279.     c = tex2D(_Tx23, IN.uv_Tx14) * _Color;
    280.     o.Albedo = c.rgb;
    281.     return;
    282.     }
    283.     if ((blockID>=23.99) && (blockID<24.01))
    284.     {
    285.     c = tex2D(_Tx24, IN.uv_Tx14) * _Color;
    286.     o.Albedo = c.rgb;
    287.     return;
    288.     }
    289.     if ((blockID>=24.99) && (blockID<25.01))
    290.     {
    291.     c = tex2D(_Tx25, IN.uv_Tx14) * _Color;
    292.     o.Albedo = c.rgb;
    293.     return;
    294.     }
    295.     if ((blockID>=25.99) && (blockID<26.01))
    296.     {
    297.     c = tex2D(_Tx26, IN.uv_Tx14) * _Color;
    298.     o.Albedo = c.rgb;
    299.     return;
    300.     }
    301.  
    302. }
    303. ENDCG
    304.  
    305. Blend One One
    306. CGPROGRAM
    307. #pragma surface surf Lambert
    308. #pragma target 3.0  
    309.  
    310.  
    311. sampler2D _Tx27;
    312. sampler2D _Tx28;
    313. sampler2D _Tx29;
    314. sampler2D _Tx30;
    315. sampler2D _Tx31;
    316. sampler2D _Tx32;
    317. sampler2D _Tx33;
    318. sampler2D _Tx34;
    319. sampler2D _Tx35;
    320. sampler2D _Tx36;
    321. sampler2D _Tx37;
    322. sampler2D _Tx38;
    323. sampler2D _Tx39;
    324.  
    325. fixed4 _Color;
    326.  
    327.  
    328. struct Input {
    329.     float2 uv_Tx27;
    330.     float2 uv2_Tx28;
    331. };
    332.  
    333. void surf (Input IN, inout SurfaceOutput o) {
    334.     float blockID = IN.uv2_Tx28.x;
    335.     //fixed4 c = tex2D(_Tx1, IN.uv_MainTex) * _Color;
    336.     fixed4 c=0;
    337.     if (blockID>39.5) return;
    338.     if (blockID<26.5) return;
    339.     if ((blockID>=26.99) && (blockID<27.01))
    340.     {
    341.     c = tex2D(_Tx27, IN.uv_Tx27) * _Color;
    342.     o.Albedo = c.rgb;
    343.     return;
    344.     }
    345.     if ((blockID>=27.99) && (blockID<28.01))
    346.     {
    347.     c = tex2D(_Tx28, IN.uv_Tx27) * _Color;
    348.     o.Albedo = c.rgb;
    349.     return;
    350.     }
    351.     if ((blockID>=28.99) && (blockID<29.01))
    352.     {
    353.     c = tex2D(_Tx29, IN.uv_Tx27) * _Color;
    354.     o.Albedo = c.rgb;
    355.     return;
    356.     }
    357.     if ((blockID>=29.99) && (blockID<30.01))
    358.     {
    359.     c = tex2D(_Tx30, IN.uv_Tx27) * _Color;
    360.     o.Albedo = c.rgb;
    361.     return;
    362.     }
    363.     if ((blockID>=30.99) && (blockID<31.01))
    364.     {
    365.     c = tex2D(_Tx31, IN.uv_Tx27) * _Color;
    366.     o.Albedo = c.rgb;
    367.     return;
    368.     }
    369.     if ((blockID>=31.99) && (blockID<32.01))
    370.     {
    371.     c = tex2D(_Tx32, IN.uv_Tx27) * _Color;
    372.     o.Albedo = c.rgb;
    373.     return;
    374.     }
    375.     if ((blockID>=32.99) && (blockID<33.01))
    376.     {
    377.     c = tex2D(_Tx33, IN.uv_Tx27) * _Color;
    378.     o.Albedo = c.rgb;
    379.     return;
    380.     }
    381.     if ((blockID>=33.99) && (blockID<34.01))
    382.     {
    383.     c = tex2D(_Tx34, IN.uv_Tx27) * _Color;
    384.     o.Albedo = c.rgb;
    385.     return;
    386.     }
    387.     if ((blockID>=34.99) && (blockID<35.01))
    388.     {
    389.     c = tex2D(_Tx35, IN.uv_Tx27) * _Color;
    390.     o.Albedo = c.rgb;
    391.     return;
    392.     }
    393.     if ((blockID>=35.99) && (blockID<36.01))
    394.     {
    395.     c = tex2D(_Tx36, IN.uv_Tx27) * _Color;
    396.     o.Albedo = c.rgb;
    397.     return;
    398.     }
    399.     if ((blockID>=36.99) && (blockID<37.01))
    400.     {
    401.     c = tex2D(_Tx37, IN.uv_Tx27) * _Color;
    402.     o.Albedo = c.rgb;
    403.     return;
    404.     }
    405.     if ((blockID>=37.99) && (blockID<38.01))
    406.     {
    407.     c = tex2D(_Tx38, IN.uv_Tx27) * _Color;
    408.     o.Albedo = c.rgb;
    409.     return;
    410.     }
    411.     if ((blockID>=38.99) && (blockID<39.01))
    412.     {
    413.     c = tex2D(_Tx39, IN.uv_Tx27) * _Color;
    414.     o.Albedo = c.rgb;
    415.     return;
    416.     }
    417. }
    418. ENDCG
    419.  
    420.  
    421. Blend One One
    422. CGPROGRAM
    423. #pragma surface surf Lambert
    424. #pragma target 3.0  
    425.  
    426.  
    427. sampler2D _Tx40;
    428. sampler2D _Tx41;
    429. sampler2D _Tx42;
    430. sampler2D _Tx43;
    431. sampler2D _Tx44;
    432. sampler2D _Tx45;
    433. sampler2D _Tx46;
    434. sampler2D _Tx47;
    435. sampler2D _Tx48;
    436. sampler2D _Tx49;
    437. sampler2D _Tx50;
    438. sampler2D _Tx51;
    439. sampler2D _Tx52;
    440.  
    441. fixed4 _Color;
    442.  
    443.  
    444. struct Input {
    445.     float2 uv_Tx40;
    446.     float2 uv2_Tx41;
    447. };
    448.  
    449. void surf (Input IN, inout SurfaceOutput o) {
    450.     float blockID = IN.uv2_Tx41.x;
    451.     fixed4 c=0;
    452.     if (blockID>52.5) return;
    453.     if (blockID<39.5) return;
    454.     if ((blockID>=39.99) && (blockID<40.01))
    455.     {
    456.     c = tex2D(_Tx40, IN.uv_Tx40) * _Color;
    457.     o.Albedo = c.rgb;
    458.     return;
    459.     }
    460.     if ((blockID>=40.99) && (blockID<41.01))
    461.     {
    462.     c = tex2D(_Tx41, IN.uv_Tx40) * _Color;
    463.     o.Albedo = c.rgb;
    464.     return;
    465.     }
    466.     if ((blockID>=41.99) && (blockID<42.01))
    467.     {
    468.     c = tex2D(_Tx42, IN.uv_Tx40) * _Color;
    469.     o.Albedo = c.rgb;
    470.     return;
    471.     }
    472.     if ((blockID>=42.99) && (blockID<43.01))
    473.     {
    474.     c = tex2D(_Tx43, IN.uv_Tx40) * _Color;
    475.     o.Albedo = c.rgb;
    476.     return;
    477.     }
    478.     if ((blockID>=43.99) && (blockID<44.01))
    479.     {
    480.     c = tex2D(_Tx44, IN.uv_Tx40) * _Color;
    481.     o.Albedo = c.rgb;
    482.     return;
    483.     }
    484.     if ((blockID>=44.99) && (blockID<45.01))
    485.     {
    486.     c = tex2D(_Tx45, IN.uv_Tx40) * _Color;
    487.     o.Albedo = c.rgb;
    488.     return;
    489.     }
    490.     if ((blockID>=45.99) && (blockID<46.01))
    491.     {
    492.     c = tex2D(_Tx46, IN.uv_Tx40) * _Color;
    493.     o.Albedo = c.rgb;
    494.     return;
    495.     }
    496.     if ((blockID>=46.99) && (blockID<47.01))
    497.     {
    498.     c = tex2D(_Tx47, IN.uv_Tx40) * _Color;
    499.     o.Albedo = c.rgb;
    500.     return;
    501.     }
    502.     if ((blockID>=47.99) && (blockID<48.01))
    503.     {
    504.     c = tex2D(_Tx48, IN.uv_Tx40) * _Color;
    505.     o.Albedo = c.rgb;
    506.     return;
    507.     }
    508.     if ((blockID>=48.99) && (blockID<49.01))
    509.     {
    510.     c = tex2D(_Tx49, IN.uv_Tx40) * _Color;
    511.     o.Albedo = c.rgb;
    512.     return;
    513.     }
    514.     if ((blockID>=49.99) && (blockID<50.01))
    515.     {
    516.     c = tex2D(_Tx50, IN.uv_Tx40) * _Color;
    517.     o.Albedo = c.rgb;
    518.     return;
    519.     }
    520.     if ((blockID>=50.99) && (blockID<51.01))
    521.     {
    522.     c = tex2D(_Tx51, IN.uv_Tx40) * _Color;
    523.     o.Albedo = c.rgb;
    524.     return;
    525.     }
    526.     if ((blockID>=51.99) && (blockID<52.01))
    527.     {
    528.     c = tex2D(_Tx52, IN.uv_Tx40) * _Color;
    529.     o.Albedo = c.rgb;
    530.     return;
    531.     }
    532. }
    533. ENDCG
    534.  
    535.  
    536. [B]Blend SrcAlpha One
    537.  
    538. CGPROGRAM
    539. #pragma surface surf Lambert alpha
    540. #pragma target 3.0  
    541.  
    542.  
    543. sampler2D _Tx53;
    544. sampler2D _Tx54;
    545. sampler2D _Tx55;
    546. sampler2D _Tx56;
    547. sampler2D _Tx57;
    548. sampler2D _Tx58;
    549. sampler2D _Tx59;
    550. sampler2D _Tx60;
    551. sampler2D _Tx61;
    552. sampler2D _Tx62;
    553. sampler2D _Tx63;
    554. sampler2D _Tx64;
    555. sampler2D _Tx65;
    556.  
    557. fixed4 _Color;
    558.  
    559.  
    560. struct Input {
    561.     float2 uv_Tx53;
    562.     float2 uv2_Tx54;
    563. };
    564.  
    565. void surf (Input IN, inout SurfaceOutput o) {
    566.     float blockID = IN.uv2_Tx54.x;
    567.     if (blockID>64.5) return;
    568.     if (blockID<52.5) return;
    569.     fixed4 c=0.5;
    570.     if ((blockID>=52.99) && (blockID<53.01))
    571.     {
    572.     c = tex2D(_Tx53, IN.uv_Tx53) * _Color;
    573.     o.Albedo = c.rgb;
    574.     return;
    575.     }
    576.     if ((blockID>=53.99) && (blockID<54.01))
    577.     {
    578.     c = tex2D(_Tx54, IN.uv_Tx53) * _Color;
    579.     o.Albedo = c.rgb;
    580.     return;
    581.     }
    582.     if ((blockID>=54.99) && (blockID<55.01))
    583.     {
    584.     c = tex2D(_Tx55, IN.uv_Tx53) * _Color;
    585.     o.Albedo = c.rgb;
    586.     return;
    587.     }
    588.     if ((blockID>=55.99) && (blockID<56.01))
    589.     {
    590.     c = tex2D(_Tx56, IN.uv_Tx53) * _Color;
    591.     o.Albedo = c.rgb;
    592.     return;
    593.     }
    594.     if ((blockID>=56.99) && (blockID<57.01))
    595.     {
    596.     c = tex2D(_Tx57, IN.uv_Tx53) * _Color;
    597.     o.Albedo = c.rgb;
    598.     return;
    599.     }
    600.     if ((blockID>=57.99) && (blockID<58.01))
    601.     {
    602.     c = tex2D(_Tx58, IN.uv_Tx53) * _Color;
    603.     o.Albedo = c.rgb;
    604.     return;
    605.     }
    606.     if ((blockID>=58.99) && (blockID<59.01))
    607.     {
    608.     c = tex2D(_Tx59, IN.uv_Tx53) * _Color;
    609.     o.Albedo = c.rgb;
    610.     return;
    611.     }
    612.     if ((blockID>=59.99) && (blockID<60.01))
    613.     {
    614.     c = tex2D(_Tx60, IN.uv_Tx53) * _Color;
    615.     o.Albedo = c.rgb;
    616.     return;
    617.     }
    618.     if ((blockID>=60.99) && (blockID<61.01))
    619.     {
    620.     c = tex2D(_Tx61, IN.uv_Tx53) * _Color;
    621.     o.Albedo = c.rgb;
    622.     return;
    623.     }
    624.     if ((blockID>=61.99) && (blockID<62.01))
    625.     {
    626.     c = tex2D(_Tx62, IN.uv_Tx53) * _Color;
    627.     o.Albedo = c.rgb;
    628.     return;
    629.     }
    630.     if ((blockID>=62.99) && (blockID<63.01))
    631.     {
    632.     c = tex2D(_Tx63, IN.uv_Tx53) * _Color;
    633.     o.Albedo = c.rgb;
    634.     return;
    635.     }
    636.     if ((blockID>=63.99) && (blockID<64.01))
    637.     {
    638.     c = tex2D(_Tx64, IN.uv_Tx53) * _Color;
    639.     o.Albedo = c.rgb;
    640.     return;
    641.     }
    642.    
    643.     o.Alpha=0.5;[/B]
    644.  
    645. }
    646. ENDCG
    647.  
    648. }
    649. }
    650.  
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Your surface shaders do not support transparency. You need to add the alpha parameter to your surface shader directive.
     
  3. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Besides that, this doesn't seem a very efficient way to do this. Why not switch the material (=texture) on the required blocks when needed. That allows you to use a way less complex shader. GPU's are not very good at if statements.