Download

wireframe material

I’m working on a wireframe shader, based on an outline shader that I saw on YouTube.

It’s working reasonably well, except that at distances far from the camera there is a white sheen on the poly surfaces, as you can see below:

The material uses an edge-finding algorithm based on a post-process material that uses the depth buffer. As you walk across each pixel, you find its coordinates in the depth buffer and multiply by -4. Then you get the depth values for the adjacent pixels (left, right, top, bottom), and add that to the center, and if it comes out zero, the pixel is black (meaning that the pixels were all in-plane I guess), or if it doesnt then there’s an edge (one of the adjacent pixels was deeper or nearer than the center pixel). Below is the material, and the material function that is used to calculate the depth of each pixel, based on an offset from the central pixel:

Below is the Material Function ScreenTexelDepth:

As you can see from the picture though, it doesn’t seem to work too well at low angles far from the camera.

Anyone have an idea what I could do to rectify this problem?

Thanks