Shading individual areas of triangles without aliasing artifacts

Started by
-1 comments, last by laylay 9 years, 10 months ago

I recently simplified my map geometry merging identical faces with each other. The problem is I have a 3d texture that defines a damage value for each cell of the map. I sample the center of these texels to shade cells with the damage value. This works perfectly when there's 4 vertices per face cell but now that 2 triangles can make up many face cells, the damage shading has to change.

This is how it looks when each face cell has 4 vertices each.

4324234.png

This is the simplified mesh with my shader changes.

4324231.png

I first pass the vertex position as a varying. In the frag shader I floor it and add 0.5, I think this is what Nearest neighbour filtering does. This is very aliased and unacceptable so I tried smoothing it out, which is what you see in the second picture. http://csantosbh.wordpress.com/2014/01/25/manual-texture-filtering-for-pixelated-games-in-webgl/

This works well for removing the aliasing but it means edges that are adjacent to an air cell get interpolated back to a light colour.

I want to be able to have the exact results of the first image without having 4 vertices per cell face.

It's almost like I need to be able to emulate what CLAMP_TO_EDGE does because the error does not happen for edges touching the map bounds, which is when clamp to edge takes effect. I'm not sure if that's possible to do though.

This topic is closed to new replies.

Advertisement