Ideas for having a shader fade/feather the edges of a mesh to transparent, fresnel-like

Hi, I’m trying to pull of a visual look in a URP shader, where I’ll have these very soft edges that give a kind of ‘cloudy’ look to a mesh, regardless of what geometry it has.
9281710--1300423--upload_2023-9-8_10-46-3.png
I want to basically say “fade whatever the edges of the mesh are in terms of whats on screen”, like I did here really quickly in ps.

The first thing I tried was to use a fresnel node to fade out the alpha, and that seemed to be ‘it’, but of course


Since its fresnel and it deals w/ the normals of the faces, it only really works perfectly for a sphere, and not whatever mesh I throw at it, especially something more simliar to a cube

I also tried to follow a few tutorials for a fullscreen highlight effect that renders the objects and blurs them like this (

) one, given that it might’ve had a similar effect so as long as I kept the mesh a single color (which wasn’t a guarantee, but I wanted to try it anyways)
9281710--1300435--upload_2023-9-8_10-53-55.png
9281710--1300438--blurrededge.png

and at some angles it looks pretty good, but even with my solid unlit meshes I couldn’t really completely prevent it from just looking like a glowing version of the object, and honestly I’m kind of not enthusiastic about using an effect like this because I have less control over the falloff, and more importantly it doesn’t scale with distance as it deals w/ the whole screen/rendertexture.

I’m just putting this out there in hopes that someone else was trying to get this kind of effect and asking if anyone had any other ideas on how to achieve this.

Of the few other forum posts of people looking for effects like this I also saw suggestions to have a normal map of a much smoother version of the object on each mesh and to somehow sample that for the fresnel, and actually I have yet to try that one ( I know beggars can’t be choosers, but I was really hoping to not need any textures to get the effect :confused: )

There are few option I can imagine:

  1. a. Render your model into render texture with depth
    b. Postprocess it to have this falloff on borders
    c. Render it into scene as camera facing billboard with DepthWrite from pixel shader (using depth from step a)

  2. a. Render your model into render texture 1/4 or 1/8 of frame buffer size
    b. postprocess it with shader (Blit) change color of all rendered pixel to white
    c. blur it slightly
    d. set it as global shader variable
    e. sample it from normal rendered texture using normalized screen space you will have color from black to white that say you distance to the edge so you can apply transparency. Multiply this distance to the edge by current rendering z position to have different width of effect on different distances.

@JesOb thanks for the response. I wasn’t sure about how to go about #1, but I did try

this, and it works like a charm regardless of geometry just like I asked, just with two main caveats; this is the old and new one side by side, I tried to use pow nodes to get the edge ‘falloff’ as close to the fresnel version as possible.
9282565--1300630--oldnew.png

the problems both have to do with the blur step
9282565--1300633--metabally.png
9282565--1300639--spill.png
when objects both using the shader that sample the global texture get too close or touch each other, the blur causes them to kind of spill into each other I think. Its kind of a neat, almost metaball-y effect, but its not ideal for what I’m using them for
And the second is
9282565--1300636--overlapartifact.png
when objects not using the shader occlude it, the ‘cutout’ made on the global texture gets blown up with the blur, and creates this extra empty space.

But thanks for the idea : ), I’m getting closer I think

you need to render each such model into separate RenderTexture and process separately then add processed RT not as global texture but to material of corresponding mesh

It is more perf heavy but will work :slight_smile:
Everything else will be on optimization phase :slight_smile: