Original Post
I'm writing some software to render to texture based on vertex colors (no texture map at this point). There are often many triangles with shared vertices in a UV map, so in order to prevent ambiguity about triangle borders, I'm only filling the pixels which are inside the edges of the triangle (shown as green dots). However, since this is used as a texture map with bilinear interpolation for texture lookups, pixels outside of this area will influence the texture and cause visible seams. The bilinear interpolation grid is shown in pink. The pixels that should influence the texture that are not inside the triangle shown in red. I can't seem to figure out a clean and simple solution to this problem. One idea I had was to do the rendering in two passes: in the first pass, whenever I render a triangle, I calculate the edge normals, push the edges out 1 unit in the normal direction, then re-intersect them and render the area under the triangle. Then in the second pass, I can render on top of this texture the normal sized triangles. This idea doesn't work, because (a) it can result in enlarging triangles much more than they need to be in some dimensions, possibly causing overlap problems; (b) it doesn't always cover all the pixels that would be needed for bilinear interpolation anyway; (c) it doesn't work for degenerate triangles, which still need to have area covered in the map (see the bottom figured triangle). Another idea is to render the interior parts of triangles first, and then do a second pass and try to fill each pixel that has an 8-connected neighbor to a previously written pixel. But this would not work for triangles that are thin and manage to squeeze between 2 pixels. Even if I can figure out a simple way to fill the necessary pixels, it's not totally straightforward to figure out what color to interpolate there based on the vertex colors. I suppose the gradients could be extended, and then cropped for over/under saturation..
Anyway, I thought maybe these issues have been tackled before, any advice or resources would be appreciated
Anyway, I thought maybe these issues have been tackled before, any advice or resources would be appreciated