Inner edge detecting

Started by
5 comments, last by ATEFred 9 years, 5 months ago

Hi,

I am not that good of a shader programming. Still experimenting. Currently i am going with unity engine and practicing cg programming. I am trying to create a shader that will detect both inner and outer edges and outline them. So far i tried to fix the front face of my object and extended the vertices that are not visible. That worked for some basic shapes but not complex ones. I tried detecting the outer edges using some common sense that dot product of normal and view direction of a vertex will be 0. But I do no know how to set the outline there. How to create an extra thick line following the edges. And how can i detect the pixel changes inside the objects to detect the inner edges ?

Thanks in advance

Advertisement
Not sure I understand, are you after cel shading ?

Anything more complicated probably needs a custom vertex and/or a geometry shader to grant your pixel shader enough information (triangle adjacency, inner edge tagging).

A screenshot or mockup drawing might help wink.png

A pretty effective and simple way can be analysing your depth buffer. Using a sobel filter is pretty common for that kind of operation. http://homepages.inf.ed.ac.uk/rbf/HIPR2/sobel.htm

Not sure I understand, are you after cel shading ?Anything more complicated probably needs a custom vertex and/or a geometry shader to grant your pixel shader enough information (triangle adjacency, inner edge tagging).A screenshot or mockup drawing might help :wink:


Yes. That's exactly what I am after. I'll read through the article u provided.

A pretty effective and simple way can be analysing your depth buffer. Using a sobel filter is pretty common for that kind of operation. http://homepages.inf.ed.ac.uk/rbf/HIPR2/sobel.htm


I heard of it. I will try to get hang of the theory explained in your provided link.

I just had a closer look at that XNA article. It actually uses the edge detection approach. There are others, and now that you have the name you can search better (AFAIK cel shading also means color quantization, not just edge enhance). The wikipedia entry lists the one I had in mind: Not a post process approach but a two pass with some culling trick.

A pretty effective and simple way can be analysing your depth buffer. Using a sobel filter is pretty common for that kind of operation. http://homepages.inf.ed.ac.uk/rbf/HIPR2/sobel.htm


I heard of it. I will try to get hang of the theory explained in your provided link.

That was just the first link I found on google. It's pretty simple in practice: sample your depth buffer for the point your are shading and the surrounding points, compute how much variance there is over the kernel, and this will tell you if you are on/close to an edge or not. You can then shade the point differently based on that. Kernel size will impact how wide your filter is. (though you can control the thickness in other, more performance friendly ways as well of course)

This topic is closed to new replies.

Advertisement