2017-09-12 1 views
1

주문에 문제가있는 것처럼 보입니다.버텍스 쉐이더에서 알파 채널이 올바르게 작동하지 않습니다.

정점 색상을 사용하는 임.

하단 꼭지점의 알파를 1로 다시 설정하면 기둥 꼭대기에 그려지는 문제가 계속 발생합니다. 내가 제대로 렌더링 불투명 큐를 설정하면

그러나 알파 내가 추가 결국

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

답변

0

(불투명 한 큐에 더 투명으로 예상 할 수있는) 흰색으로 렌더링 cg가 시작하기 전에 패스하고 내가하고 싶은 것을하고있는 것처럼 보이지만 조금 더 조정할 필요가 있습니다.

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

관련 문제