Mesh Edges

  • Daodan
  • Topic Author
More
5 years 7 months ago #1 by Daodan Mesh Edges was created by Daodan
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 following user(s) said Thank You: JBeckman, WalterDasTrevas, Exilium, Rudy102, PureEvilWindom

Please Log in or Create an account to join the conversation.

  • JBeckman
More
5 years 7 months ago - 5 years 7 months ago #2 by JBeckman Replied by JBeckman on topic Mesh Edges
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: 5 years 7 months ago by JBeckman.

Please Log in or Create an account to join the conversation.

  • jas01
More
5 years 7 months ago #3 by jas01 Replied by jas01 on topic Mesh Edges
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).

Please Log in or Create an account to join the conversation.

  • Daodan
  • Topic Author
More
5 years 7 months ago #4 by Daodan Replied by Daodan on topic Mesh Edges

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 following user(s) said Thank You: jas01, WalterDasTrevas

Please Log in or Create an account to join the conversation.

  • moriz1
More
5 years 7 months ago #5 by moriz1 Replied by moriz1 on topic Mesh Edges
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.

Please Log in or Create an account to join the conversation.

  • Kleio420
More
5 years 7 months ago #6 by Kleio420 Replied by Kleio420 on topic Mesh Edges

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.

Please Log in or Create an account to join the conversation.

  • klotim
More
5 years 7 months ago #7 by klotim Replied by klotim on topic Mesh Edges

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.

Please Log in or Create an account to join the conversation.

  • Tojkar
More
5 years 7 months ago - 5 years 7 months ago #8 by Tojkar Replied by Tojkar on topic Mesh Edges

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: 5 years 7 months ago by Tojkar.

Please Log in or Create an account to join the conversation.

  • sambow23
More
5 years 7 months ago #9 by sambow23 Replied by sambow23 on topic Mesh Edges
Is there a way to remove the entire white layer? I'd love to have a Borderlands style depth shader

Please Log in or Create an account to join the conversation.

  • sambow23
More
5 years 7 months ago #10 by sambow23 Replied by sambow23 on topic Mesh Edges

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

Please Log in or Create an account to join the conversation.

  • Soulfate
More
5 years 5 months ago #11 by Soulfate Replied by Soulfate on topic Mesh Edges

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.


SMAA edge detection is not good. I think that this kind of detection, with some exclusion, would be really good for FXAA

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 5 months ago #12 by Marty McFly Replied by Marty McFly on topic Mesh Edges
SMAA doesn't detect edges as you'd think. The clue is in the name, "morphological" anti aliasing. It detects common shapes how they look after rasterization (such as L shapes for diagonal edges), tries to guess underlying geometry and how it would look when rasterized analytically.
The following user(s) said Thank You: jas01

Please Log in or Create an account to join the conversation.

  • Digika
More
1 year 10 months ago #13 by Digika Replied by Digika on topic Mesh Edges
This is pretty cool and relevant to my interest.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.