Edge Detection + zbuffer?

Hey guys, I was hoping someone can help me with a little problem i’m having with edge detection. I have it applied, and it’s working fine as it is, but objects further in the distance really look horrible. If needed, I can provide an image of my issue, but i’m sure if you’re familiar with edge detection, it’s a problem you’ve probably faced yourself. After doing some searching around, I think the answer might involve a zbuffer to thin the lines out the further they are from the camera?

Keep in mind i’m an artist, so scripting and coding are a little over my head to program myself. I’m going to need some help hahaha.

I’m not asking how to apply edge detection, or how to “make an outline around my models”. I just need some help making the outlines look better, from farther away. They’re too thick, and become clumpy looking, nobody out there has any comment on this? IS it fixable?

Darcy,

Your email provides NO information about what you are doing. An image would help, script examples would help, shader code helps. Or just more specifics. I don’t have an answer to your question, but much of the time, if you provide concise, but detailed infos, you will get an answer.

Gigiwoo.

oh, sorry about that. I thought I was pretty clear.
The issue has nothing to do with shaders, so I don’t need to post that, and the image effect is the one that comes with unity pro. I will post the script just in case you’re unfamiliar with it’s code.

. I can also provide some images that will probably do a better job at illustrating my problem than my words.


I don’t want the image outline for objects that are really far away, to be the same width as objects close to the camera.

As you can see in the picture, it looks pretty bad as it is.

EDIT: I must have done something wrong with the code to use images, because they didn’t work, so heres the links.

Example 1

Example 2

You need a new outline shader for that, it’s not a scripting issue.
Try asking in the shader forum.

The effect is done using the edge detection image effects on my camera, and i’m pretty sure that’s done using a script. Using the toon outline shader on each object, in each scene is a little counter productive no?

Please correct me if i’m wrong too, because I’m only going on assumptions here, and in either case, a shader won’t work on the terrain, so that still doesn’t solve my issue. I suppose I could use one camera to draw terrain, and one to draw everything else, but that seems like i’m going overboard. I had this same problem in udk before and it was solved using a zbuffer.

Point being in all of this, is I don’t think it’s a shader issue, but a script issue. I believe this to be in the right section, and using the toon shader with outline still has the exact same problem with probably the same solution.

you just gave me an idea actually that may work. If I used 2 cameras. 1, with edge detection on, that only renders terrain, and the other rendering everything else, with the outline/toon shader applied to it. Would that work, and if so, how taxing would it be in comparison to using 1 camera?

The script just runs an image effect or post-effect shader (‘edgeDetectShader : Shader’ in the script).
Not a normal material shader, but still a shader.