Sign in to follow this  

Shading individual areas of triangles without aliasing artifacts

This topic is 1281 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 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.

Edited by laylay

Share this post


Link to post
Share on other sites
Sign in to follow this