Welcome, Guest.
Username: Password: Remember me

TOPIC: Mesh Edges

Mesh Edges 2 months 3 days ago #1

Here is a shader that derives the edges of a mesh from the depth-buffer.
Might not work in every game, because depth-buffer access is needed.
And I guess the the depth-buffer needs to be stored in a format with sufficient precision.
Otherwise it looks weird.

MeshEdges.fx

Here are some samples:
The Witcher 3:


Hellblade:


The Evil Within 2:
(with a bit of cinematic-dof)


And one thing that makes this shader - at least in my estimation - particularly interesting:
While the game-engine changes the LOD of an object (or loads it) the depth-buffer 'freaks out' a bit which results in (visible) noise in that area.
So basically the shader 'highlights' LOD-changes. This is so cool.
The administrator has disabled public write access.
The following user(s) said Thank You: JBeckman, WalterDasTrevas, Exilium, Rudy102

Mesh Edges 2 months 3 days ago #2

Nice, I was trying some similar effects in games via a combination of shaders after seeing examples for Mirror's Edge and Evil Within 1 using high contrast black & white outlines but this seems far more versatile (And easier to setup.) plus it has other uses although from the last part there I guess a higher display resolution or similar is needed to make the edges precise enough. :)
(And depth buffer support of course.)

EDIT: Yeah just about the same after testing with the difference of using the depth buffer meaning it's more clean and precise but some things aren't in the depth buffer.

Going to be using this for a while and see how it behaves in different scenarios. Logarithmic or reversed depth is one thing and also certain shaders or effects causing some mild noise or patterns from testing in Shadow of the Tomb Raider and then Ni No Kuni 2 thus far. Good effect. :)

EDIT: The LOD transition sounds useful too, now to find a game with sufficient pop-in then and see how that shows up as with the shader running.
Last Edit: 2 months 3 days ago by JBeckman.
The administrator has disabled public write access.

Mesh Edges 2 months 2 days ago #3

My sugesstions:

- Could you edit this shader so we would be able to invert the image and get something more similar to some sort of a "fake" sketch? Like in this picture - www.mediafire.com/convkey/518f/8wl1dumcuycyf62zg.jpg?size_id=a
- I think that being able to change the color of these lines/ edges to something different than the default (white) could also look interesting (for example purple edges + black background).
The administrator has disabled public write access.

Mesh Edges 2 months 1 day ago #4

jas01 wrote:
My sugesstions:

- Could you edit this shader so we would be able to invert the image and get something more similar to some sort of a "fake" sketch? Like in this picture - www.mediafire.com/convkey/518f/8wl1dumcuycyf62zg.jpg?size_id=a
- I think that being able to change the color of these lines/ edges to something different than the default (white) could also look interesting (for example purple edges + black background).

Good ideas. You can now set custom background and line colors. And you can choose whether the background is a solid color or the backbuffer.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01, WalterDasTrevas

Mesh Edges 2 months 1 day ago #5

you know, this shader would be a great masking pass for sharpening shaders, since you definitely do NOT want to sharpen polygon edges.

at the same time, it's great for FXAA/SMAA as well, since this appears to be an excellent edge detector.
The administrator has disabled public write access.

Mesh Edges 2 months 1 day ago #6

moriz1 wrote:
you know, this shader would be a great masking pass for sharpening shaders, since you definitely do NOT want to sharpen polygon edges.

at the same time, it's great for FXAA/SMAA as well, since this appears to be an excellent edge detector.
the lumasharpen has been changed for enb at least to use depth buffer detection to lower or increase radios of the effect. Post aa like smaa already uses a edge detection method thats the point of anti aliasing.
The administrator has disabled public write access.

Mesh Edges 2 months 1 day ago #7

Kleio420 wrote:
moriz1 wrote:
you know, this shader would be a great masking pass for sharpening shaders, since you definitely do NOT want to sharpen polygon edges.

at the same time, it's great for FXAA/SMAA as well, since this appears to be an excellent edge detector.
the lumasharpen has been changed for enb at least to use depth buffer detection to lower or increase radios of the effect. Post aa like smaa already uses a edge detection method thats the point of anti aliasing.

Depth based FXAA would be cool because SMAA is not working in motion if I'm not wrong.
The administrator has disabled public write access.

Mesh Edges 2 months 1 day ago #8

moriz1 wrote:
you know, this shader would be a great masking pass for sharpening shaders, since you definitely do NOT want to sharpen polygon edges.
There already is. It's called filmicsharpening or anamorficsharpening and is found on these forums. I can't remember specific info, but I'll look it up if you want.
Last Edit: 2 months 1 day ago by Tojkar.
The administrator has disabled public write access.

Mesh Edges 2 months 12 hours ago #9

Is there a way to remove the entire white layer? I'd love to have a Borderlands style depth shader
The administrator has disabled public write access.

Mesh Edges 2 months 12 hours ago #10

sambow23 wrote:
Is there a way to remove the entire white layer? I'd love to have a Borderlands style depth shader
Nvm, figured it out
The administrator has disabled public write access.