Search Unity

Vertex Color Shader Turns Transparent Help

Discussion in 'Shaders' started by xjjon, Jul 22, 2016.

  1. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    613
    vertexpaitnedtree.png

    I am having trouble creating my shader to vertex paint this tree properly. I have vertex painted this tree in 3DS MAX with two colors using Vertex Paint map and then exported .FBX

    I am a novice at writing shaders but after some time I have gotten it so the colors show, except they are florescent transparent when viewed in game.

    Here is my simple shader:

    Code (csharp):
    1.  
    2.  
    3. Shader "Vertex Shader" {
    4.    Properties{
    5.      _MainTex("Base (RGB)", 2D) = "white" {}
    6.    }
    7.      SubShader{
    8.      Tags{ "Queue" = "Geometry" "IgnoreProjector" = "False" "RenderType" = "Opaque" }
    9.      LOD 200
    10.  
    11.      CGPROGRAM
    12. #pragma surface surf Lambert alpha
    13.  
    14.  
    15.    struct Input {
    16.      
    17.      float4 color: Color;
    18.    };
    19.  
    20.    void surf(Input IN, inout SurfaceOutput o) {
    21.      
    22.      o.Albedo = IN.color.rgb;
    23.      o.Alpha = IN.color.a;
    24.    }
    25.    ENDCG
    26.    }
    27.      FallBack "Diffuse"
    28. }
    29.  
    30.  
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    If you don't want it to be transparent, remove the word "alpha" from line 12
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Or set it to 1 to be sure there is no residual data