- Home /
Alpha the edges of an Object
Hello all,
So I'll start off by saying that I don't know a TON about shaders so some things I read online, without a code snippet, seem to be too cryptic for me. I'm working on that. In the meantime, I thought I'd post the question here to see if anyone could help or point me in the right direction.
The effect that I'm going for is to take an arbitrarily shaped object and alpha the edges out. I only have access to the vertex positions so I can't use things like Normals to get the object bounds. See image.
I've been doing some digging and it seems that the best bet is to somehow use the Stencil Buffer to get the bounds of the object in a pixel shader. But I can't find any resources online on how to adjust the Stencil Buffer. Or convert it to a screen texture resource or something.
My questions are: 1. Is there a way to do this with a stencil buffer? 2. If not, is there a way to use the previous Pass's render in a subsequent Pass that I can do my calculations on?
Thanks for any help/insight, Alex
I would have suggested using the rim-shading technique to adjust the alpha.
http://docs.unity3d.com/$$anonymous$$anual/SL-SurfaceShaderExamples.html (4th one down)
$$anonymous$$ainly the lines:
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = _RimColor.rgb * pow (rim, _RimPower);
@Namey5 Thank you for the response. Unfortunately, I only have access to vertex positions because they are co$$anonymous$$g in from a Structured Buffer that I can't change. I also can't seem to calculate the normals correctly in the Vertex function ... The normals come through faceted and I need them smooth. So using a Fresnel effect won't work for me. Which is why I thought doing it the pixel shader may yield better results.
Your answer
![](https://koobas.hobune.stream/wayback/20220612074511im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Post effect shader similar to "Shannara Chronicles" intro's edge smoke effect 0 Answers
About shader! 0 Answers
COLORMASK & writing to multiple render targets In Deferred doesn't work as expected in DX9 1 Answer
Chromakey shader for movie textures? 2 Answers
Unity Fog Shader with Alpha Change 0 Answers