Using a customised version of a 'x-ray' shader from the excellent 'Makin Stuff Look Good' series I need to simply fade or mask it out(would prefer to fade) thru code. Can any shader gurus help? Code (csharp): Shader "XRay Shaders/Diffuse-XRay-Replaceable" { Properties { _Color("Main Color", Color) = (1,1,1,1) _EdgeColor("XRay Edge Color", Color) = (0,0,0,0) _MainTex("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "Queue" = "Geometry-1" "RenderType" = "Opaque" "XRay" = "ColoredOutline" } LOD 200 //ADDED Stencil { Ref 1 Comp Always Pass Replace //ZFail Keep ZFail Replace } //END CHANGE CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; fixed4 _Color; struct Input { float2 uv_MainTex; }; void surf(Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } Fallback "Legacy Shaders/VertexLit" }
Add the keyword alpha to the #pragma surface line then set the color value's alpha from script. https://docs.unity3d.com/Manual/SL-SurfaceShaders.html https://docs.unity3d.com/ScriptReference/Material-color.html