unity3d - Alpha channel not working correctly on vertex shader -


i seem tobe having issues order drawning or that.

im using vertex colors.

if set alpha of bottom vertices 1 again still draw issue on top of pillars.

if set queue opaque renders correctly, alpha renders white (which expected no transparencies in opaque queue)

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 draw issue

i ended adding pass before cg starts , seem doing want do, still needs little more tweaking though.

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 1 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


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -