0
\$\begingroup\$

I've added simple color based ambient occlusion to my game.

First it looked like this (from giawa.com): Wrong anisotropy

The description: "Due to anisotropy, the ambient occlusion shading on the top left is inconsistent with the top right. We need to flip those quads so that they get rendered properly."

So according to that I had to flip some faces in order to fix the issue. I did and then it would look like this: wrong culling

This is of course because of back face culling, culling the flipped faces.

When I disable culling, it looks like this:

Corrected anisotropy

Which is how it's supposed to look. But as you can imagine, that costs a lot of performance because culling is now disabled.

According to the article: http://www.giawa.com/author/giawa/page/10/ "This occurs due to differences in how the GPU linear interpolates across the edge of a triangle versus the body of a triangle. This is called anisotropy, and can be fixed by ‘flipping’ the quad. My final fix was to enable polygon culling, which meant I had to make sure to render my quads in a consistent winding. "

I've searched for this "polygon culling" but could not find anything about that.

I can't just switch between culling modes because all the vertexes are added to a vertex buffer when initializing a chunk. This is so I can render each chunk in one draw call.

I hope anyone knows a way to fix this, thanks in advance.

\$\endgroup\$
6
  • \$\begingroup\$ You can set up culling hovewer you want in DirectX. You will find it in the Rasterizer state settings, but I can't say more without knowing more details. \$\endgroup\$ Commented Sep 14, 2014 at 17:50
  • \$\begingroup\$ yes, I know you can set culling to back face culling or front face culling (or none) but that doesn't solve the problem. because of the way ambient occlusion works, you have to flip some of the the faces. that means some will need backface culling and some will need frontface culling. There comes the problem cus they are meshed together as a "chunk" meaning all data is merged. This guy in the article was talking about polygon culling but I could not find anyting about that \$\endgroup\$
    – Duckdoom5
    Commented Sep 14, 2014 at 21:50
  • \$\begingroup\$ What is "the anisotropy correction"? \$\endgroup\$ Commented Sep 15, 2014 at 1:33
  • \$\begingroup\$ Also, I saw you cross-posted this to Stack Overflow. That's frowned upon - you should pick the site best suited to the question (which is this one) and post it only there. \$\endgroup\$ Commented Sep 15, 2014 at 1:36
  • \$\begingroup\$ @Nathan the 'correction' is flipping the faces that are rendered in the wrong way. I'll add some more info( that can be found in the article) in the op later today. I'll also remove the other post. Sorry for violating the rules. \$\endgroup\$
    – Duckdoom5
    Commented Sep 15, 2014 at 8:37

1 Answer 1

4
\$\begingroup\$

By "flip the quads", the article doesn't mean to reverse the winding order. That swaps the front and back faces of the quad and causes other problems, as you've found.

The article means to change the way the quad is divided into two triangles. Instead of a quad like this:

 __________
|         *|
|      *   |
|   *      |
|*_________|

sometimes you need a quad like this:

 __________
|*         |
|   *      |
|      *   |
|_________*|

Splitting along the other diagonal makes the vertex interpolation look different, and the article is taking advantage of this to improve the appearance of the AO.

It can be done by permuting the vertices. If the first quad had vertices 1, 2, 3, 4 then the second one should have 2, 3, 4, 1.

(BTW, the author's use of the term "anisotropy" in that article is a bit confusing as that word is usually used only to talk about anisotropic texture filtering, which is something completely different. What the author calls "anisotropy" I would just call the fact that vertex interpolation is done per-triangle, not per-quad.)

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, I never knew that you can switch vertices without actually flipping the face. \$\endgroup\$
    – Duckdoom5
    Commented Sep 17, 2014 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .