2017-09-12 8 views
1

Je semble avoir quelques problèmes avec l'ordre de son dessin ou quelque chose comme ça.Le canal alpha ne fonctionne pas correctement sur le vertex shader

Im utilisant des couleurs de vertex.

Si je place à nouveau l'alpha des sommets inférieurs à 1, je reçois toujours ce problème de tirage au sommet des piliers.

Si je mets la file d'attente opaque, il rend correctement, mais l'alpha rend en blanc (qui serait attendu que pas transparents dans la file d'attente opaque)

Shader "Custom/VertexColors2" { 
    Properties { 
     _Color ("Color", Color) = (0,0,0,0) 
     _MainTex ("Albedo (RGB)", 2D) = "white" {} 
     _GridTex ("Grid Texture", 2D) = "white" {} 
     _Glossiness ("Smoothness", Range(0,1)) = 0.5 
     _Metallic ("Metallic", Range(0,1)) = 0.0 
    } 
    SubShader { 
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 

     CGPROGRAM 
     #pragma surface surf Standard alpha 
     #pragma target 3.5 

     sampler2D _MainTex; 
     sampler2D _GridTex; 

     struct Input { 
      float2 uv_MainTex; 
      float4 color : COLOR; 
      float3 worldPos; 
     }; 

     half _Glossiness; 
     half _Metallic; 
     fixed4 _Color; 

     void surf (Input IN, inout SurfaceOutputStandard o) { 
      fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 

      float2 gridUV = IN.worldPos.xz; 
      gridUV.x *= 1/(4 * 8.66025404); 
      gridUV.y *= 1/(2 * 15.0); 
      fixed4 grid = tex2D(_GridTex, gridUV); 

      o.Albedo = c.rgb * IN.color * grid; 
      o.Metallic = _Metallic; 
      o.Smoothness = _Glossiness; 
      o.Alpha = IN.color.a; 
     } 
     ENDCG 
    } 
    FallBack "Standard" 
} 

Picture of the draw issue

Répondre

0

Je fini par ajouter une passer avant le début de la CG et il semble faire ce que je veux qu'il fasse, a encore besoin d'un peu plus de peaufinage cependant.

Shader "Custom/VertexColors2" { 
    Properties { 
     _Color ("Color", Color) = (0,0,0,0) 
     _MainTex ("Albedo (RGB)", 2D) = "white" {} 
     _GridTex ("Grid Texture", 2D) = "white" {} 
     _Glossiness ("Smoothness", Range(0,1)) = 0.5 
     _Metallic ("Metallic", Range(0,1)) = 0.0 
    } 
    SubShader { 
     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque"} 
     LOD 200 

     Pass { 
      Cull Off 
      Blend One OneMinusSrcAlpha 
     } 
      ZWrite Off 

      CGPROGRAM 
      #pragma surface surf Standard fullforwardshadows alpha:blend 
      #pragma target 3.5 

      sampler2D _MainTex; 
      sampler2D _GridTex; 

      struct Input { 
       float2 uv_MainTex; 
       float4 color : COLOR; 
       float3 worldPos; 
      }; 

      half _Glossiness; 
      half _Metallic; 
      fixed4 _Color; 

      void surf (Input IN, inout SurfaceOutputStandard o) { 
       fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 

       float2 gridUV = IN.worldPos.xz; 
       gridUV.x *= 1/(4 * 8.66025404); 
       gridUV.y *= 1/(2 * 15.0); 
       fixed4 grid = tex2D(_GridTex, gridUV); 

       o.Albedo = c.rgb * IN.color * grid; 
       o.Metallic = _Metallic; 
       o.Smoothness = _Glossiness; 
       o.Alpha = IN.color.a; 
      } 
      ENDCG 
    } 
    FallBack "Diffuse" 
} 

enter image description here