# Outlining external edges on a complex shape made of cubes?

A gallery of my problem can be found here. I had to do it this way as it won't let me post more than 2 links due to my reputation.

I'm trying to use 3D cubes to generate an isometric cube world.

I got that working great and I merge only the visible vertices/indices into a buffer and draw from that.

Only problem is, as with any isometric game, it becomes difficult to differentiate between heights. For example in the first image: this archways top merges with the cubes below.

I ended up finding this shader and got it working by using it against a rendered normal map (second image) of the cubes.

You may be able to guess my problem from that image. The final result looks like the third image. The back edges are not draw with an outline, which are the most important. Which based on the normal map also means that diagonals also have the same problem on their sides (fourth image).

Is there any solution I can do for this? Either in the shader itself or perhaps when calculating the normals? I almost need to add something to the normal to distinguish their depth/height so faces on similar planes don't merge on edge detection. Or maybe there's a totally different option I could use.

Ideally I was aiming more for only edges to the air to be outlined so the archways bottom edges would not be outlined like they are now =/

• Have you tried to increase DepthSensitivity or lower DepthThreshold? Oh and if you want to introduce more complicated rules like not drawing the edges around the base of your pillars then you might need to take another approach. Probably something involving tagging the edges that you want an outline on and then drawing the lines. – PeterT Aug 4 '13 at 13:33
• I would follow Peter's second suggestion and strongly encourage taking another approach - shaders will of necessity be primarily 'screen-space', but what you really want is a 'world-space' approach; essentially you want to add 'edge markers' (little cylinders/black billboards/what-have-you) to some class of edges; either those that have a 'sharp' edge (i.e., a 90-degree bend) or those where the edge is 'reflex' (that is, the two faces on either side of it have one normal pointing towards the camera and one pointing away). The algorithmic approach will be much more flexible in the long run. – Steven Stadnicki Aug 4 '13 at 20:00
• @StevenStadnicki In the world array for the blocks, I already store the connections that the block has. On my 2D approach I used this as a bit mask to determine what outlines to draw per cube. As I still have that bit mask, I could still use it. The question is how would I go about rendering/drawing the outline? I have no idea how to draw a thin outline when it comes to vertices. I'm very new to 3D programming. – MattMcg Aug 4 '13 at 20:09
• And @PeterT, I tried to play with the parameters on the shader, none give the desired results still as it's strictly based off colour difference on the normal image, which there is none when one face exists inside the view area of a the same face. – MattMcg Aug 4 '13 at 20:10
• If you have a deferreed renderer where you have the pixels depth, then you can evaluate the depth different among two pixels and obscure them if its too large... – Blau Aug 4 '13 at 20:14