Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shading individual areas of triangles without aliasing artifacts


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 laylay   Members   -  Reputation: 310

Like
0Likes
Like

Posted 15 July 2014 - 06:38 PM

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, 15 July 2014 - 06:42 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS