may i ask can this effect be achieved? I tried many built-in materials but it didn't work My understanding is transparency + gradient shader I've been stuck with a simple question all night
Here's a simple shader that will do that for you. Just add it to a new material and assign a gradient texture to it (with an alpha channel.) Between lines 11 and 16 are the different forms of transparency you can use. Currently it's using traditional transparency which is what your example image is using. Although you might want to comment that line out and try some of the other modes, which might look better. (Only the first two; traditional transparency and premultiplied transparency require an alpha channel in the texture. The other modes use colour to determine the blend of the pixel.) Code (CSharp): Shader "TMCShaderQuarantine/SimpleUnlitTransparent" { Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Tags { "Queue" = "Transparent" } Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency //Blend One OneMinusSrcAlpha // Premultiplied transparency //Blend One One // Additive //Blend OneMinusDstColor One // Soft additive //Blend DstColor Zero // Multiplicative //Blend DstColor SrcColor // 2x multiplicative Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _MainTex; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.uv); return col; } ENDCG } } }
Hia, I have a question. Using this code returns this error: Parse error: syntax error, unexpected $end. Any Ideas?
You have probably missed one of the curly brackets at the end. When you copy the code make sure copy it all and paste it in its entirety into the shader.