#Detect outside Edges with ShaderGraph

1 messages · Page 1 of 1 (latest)

pliant pond
#

Hi. Is there a way to detect the outside edges and add some kind of fading alpha the closer it is to the edge please? Like the red part shown in the image in the case of that cone, where it detects when it intersects with the cube and with the background

jade lava
#

A material shader can only render in the bounds of the mesh/triangles, it can't render outside of them.
Post processing/full screen shaders can render wherever, but you need to be able to detect where to render with some kind of mask or something.

So you either need to render the object twice(once with a bigger scale or stretching the vertices in the vertex shader), or create a custom post processing effect.
Basically, outlines are quite a complicated topic. Research it online for more details.

pliant pond
#

Oh okay. Well I meant like detect the edges, but paint inside the object itself

#

like I do not want to extend the mesh, I only need to make it so when a pixel of the mesh is close to the edge, its alpha drops

jade lava
pliant pond
#

the outline implementations I've found just move the vertex along the normal, or detect all edges of the object, including the ones that are inside the object, which I don't want

#

but I'll search more and see if there's some tutorials that make it with only the outside edges

#

thanks

jade lava
#

A mask way might be what you need then. Render the object in 2 passes. One into a mask or stencil buffer, the second one normally, read the mask/stencil in the current pixel and pixels around it(up to the radius of the fade). If a sample ends up outside the mask, the you're in the fade zone, make the pixel transparent based on the distance to that edge and max fade radius.