- Home /
How would I add transparency to an outline shader?
I am trying to just add a transparent/alpha effect on the Bumped Outline shader found here: Outline Silhouette Shader
My mesh is an owl and I need a transparent shader for the wings. Here is an example of what it looks like with just the Transparent/Bumped Diffuse shader:
And here is what it looks like with the Outline/Silhouette Bumped shader:
As you can see, the outline shader works great, but the wings should be transparent to avoid having that white filler between the feathers. I have messed with shaders a little, but am still not all that familiar with them so I'm having trouble trying to figure this out. Any help would be appreciated. Thanks.
Answer by cakeslice · Nov 29, 2016 at 08:37 PM
In that case, replace this line (in the first "surf" function):
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * _Color;
with this:
float4 tex = tex2D(_MainTex, IN.uv_MainTex).rgba;
if (tex.a < .1f)
clip(-1);
o.Albedo = tex * _Color;
What clip does is discard the current pixel if the texture alpha (tex.a) is lower than .1f
You can use another value instead of .1f if you want. This technique is called alpha cutout and doesn't need blending.
That's perfect! Thank you so much! If you change your comment to an answer I'll mark it as correct.
Answer by cakeslice · Nov 29, 2016 at 08:16 AM
Hi, I tested that shader and I can change the alpha using the "OutlineColor" property, is that what you're looking for?
No. That changes the visibility of the outline. However the parts of the mesh that should be transparent will still be fully solid white even if the outline alpha is at zero. I am going to need to alter the shader somehow to let it accommodate transparency. Thanks for the suggestion though.
Your answer
Follow this Question
Related Questions
Outline Shader with objects inside 0 Answers
Shader Transperency issue 1 Answer
Getting transparency issue on android build 1 Answer
Don't render an Area behind a plane 0 Answers
Combining two Outline Shaders 1 Answer