Sign in to follow this  

Outlining Meshes (PostProcess?)

This topic is 3146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm just about finishing funtionally with my game, and I'm looking to add one or two nice touches. One thing I would like to be able to do is draw a colored outline around certain objects. Now the important thing to know here is that I might be drawing multiple objects with outlines at any given time and the color need not always be the same. I'd like to outline to be a consistent thickness. Because the outline should be of consistent thickness, I'm thinking that doing this in a mesh shader is probably a bad idea. I could probably knock something up using the view vector and the surface normal and getting a rough outline that way - kinda like low grade cel shading outlines used to be done - but it's going to be dependent on the view, and so I'd have to adjust by the distance between the camera and the mesh, and it probably won't look good at certain depths. So I'm thinking this is probably best done as a post process shader. Then it's in screen space and the thickness of the outline will be constant. The only time it will look bad is when the object is a very, very long way away, and the game doesn't allow this to happen in the first place. Now performance in my game is good, but I don't have a lot to spare, so I need this to be as quick as possible. I don't need particularly high quality and I don't need an outline on sharp internal edges or anything like that so I don't think I need to render out normals and depths to a rendersurface. I would imagine a very simple shader to just output a flat color would be fine for what I'm going to call the "stencil" pass, where I just draw everything which needs an outline. But I would then need to apply a shader which calculates the outline. I've seen a couple of HLSL shaders to do a sobel filter, which I think results in an image which is black and white. That's fine for a single color outline, but if I want a blue outline on one mesh and a red outline on another mesh, that won't work. I considered perhaps rendering twice, once to a "stencil" surface which simply indicates where the outline meshes are, and another which outputs the color of the outline. Then I could filter the black and white one, sample both, and multiply them to get the output color. But the sobel filter is necessarily going to highlight pixels which were slightly outside the original mesh and therefore are not colored on the color map, so that won't work. Perhaps there's a simple solution I'm missing, but I can't really come up with a fast, straightforward way of getting coloured outlines around my meshes. I'm using TrueVision3D, by the way, so I can use my own .fx shaders and I know a little bit of HLSL. Hopefully someone can spark an idea for me.

Share this post


Link to post
Share on other sites

This topic is 3146 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this