Highlight 2d polygon border with shader

Started by
0 comments, last by haegarr 8 years, 11 months ago
Hello,
currently I'm working with Havok Vision Engine that uses HLSL in windows.
I constructed a 2d polygon and now the goal is to highlight its border using shader in a fashion like the attached file green_poly.jpg.
But I'm rather new to shader programming in general and don't find a proper way to solve this problem.
I thought about using normals but as far as I'm aware they only should point towards their face direction (which is flat ...).
Do you have an idea on how to solve this or know a technique/algorithm that faces this problem?
Thank you in advance
Advertisement

There are (at least) two possible approaches:

a) The original polygon is the dark area inside the green border, and the border is additional geometry build from extending the original polygon. The additional geometry can then be colored by standard interpolation of vertex color.

b) The polygon area reaches to the outside where the green border fades out into the background, and no additional geometry is generated. Then the vertex shader is used to compute the distance of the current pixel to the edges in screen space, and the color of the pixel is chosen as function of the distance. Obviously, you need to send a vertex attribute which is used to distinguish whether or not a vertex counts to an edge that is to be highlighted. The theory can be read in several articles around the web.

This topic is closed to new replies.

Advertisement