Strange Artifacts In Heightfield

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
I worked out the normals for a heightfield but I'm having some odd artifacts show up. It could be the other sides of the hills, but I have back face culling enabled in OpenGL. Anything else maybe causing these artifacts to show up?
[Image: screenshot2.bmp]
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
When you move around, do the artifacts move? They look like extra polygons made by an errant vertex array.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
The artifacts don't move, different ones appear. It's not a vertex array problem because I'm not using vertex array Smile. It's just a display list. Here's the code I used to make the display list:
Code:
list = glGenLists(1);
    glNewList(list, GL_COMPILE);
    {

        for(int i = 0; i <= width - accuracy; i += accuracy)
        {
            glBegin(GL_TRIANGLE_STRIP);
            for(int j = 0; j <= depth - accuracy; j += accuracy)
            {
                if((i + accuracy) <= (width - accuracy))
                {
                    if(normals != NULL)
                        glNormal3f(normals[j * width + (i + accuracy)].x, normals[j * width + (i + accuracy)].y, normals[j * width + (i + accuracy)].z);
                    glVertex3f((i + accuracy) * tileSize, GetHeight(i + accuracy, j), j * tileSize);
                }

                if(normals != NULL)
                    glNormal3f(normals[j * width + i].x, normals[j * width + i].y, normals[j * width + i].z);
                glVertex3f(i * tileSize, GetHeight(i, j), j * tileSize);
            }
            glEnd();
        }
    }
    glEndList();
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
*cringes at how many more resources that takes up compared to a vertex list*

Stupid question, but you do have depth testing enabled, right? Also, how large is your depth buffer? That's also the kind of artifacts you'd get if your depth buffer is too small, but that would have to be awfully unforgiving to give artifacts with that much distinction. Annoyed
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
I know it would be better with a vertex array, but I'm just trying to get this all set up and working first. Then I'll optimize.

I'm using a 32 bit depth buffer and yes depth testing is enabled. I've kinda been stumped on this for a few days now.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
When you move up any closer, do holes start appearing, or is it always clean whenever you go up to a specific area? Can you post a build so we can test it out and view it ourselves?
Quote this message in a reply
Member
Posts: 41
Joined: 2006.01
Post: #7
It looks like you have gaps where the triangle size changes (the resolution band edges).
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #8
It doesn't really look like z-fighting to me.

Tried rendering as a mesh? Might give some insight into what you fucked up.

On a somewhat unrelated note, you can get rid of the uneven blending by running your image through a simple blur convolution filter before building a mesh from it. Looks much prettier :-p

EDIT: just for curiosity's sake, what are the near and far values you use for your clipping planes?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #9
I'm not sure what you mean by rendering as a mesh. Did you mean a vertex array or VBO? I'm looking into those next.

And the weird blending is because all the normals are surface normals. I still have to implement a normal averaging algorithm to smooth out the normals.

I believe the near and far values are .01 and 1000.0 respectively.

I did get a build up. Hopefully it works. I bundled freetype, FTGL, SDL, OpenAL, and SDL_image into the bundle. On my Mac, I have it linked to an older version of the QuickTime framework (for some weird SDL glitch) so I'm not sure if you need that as well. I didn't bundle it because it was about ten times larger with QuickTime bundled.

[DEAD LINK REMOVED]

EDIT: After seeing this post, I decided to go look at my gluPerspective() and turns out my near was .001 or .0001. I reduced it to .1 and it works just fine. Thanks
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2006.02
Post: #10
Those clipping plane values are likely to give you some trouble. Try making them 10.0 to 100.0 or something.

The following page has more detail (see 12.040):
http://www.opengl.org/resources/faq/tech...buffer.htm

And what I meant by rendering as as mesh is render it as a wireframe mesh, so you can see if it's deformed more easily.

EDIT: ya beat me to it :-p
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES 2.0, 2D Alpha Transparency Artifacts Macmenace 3 8,222 Mar 28, 2010 11:18 PM
Last Post: AnotherJake
  Multisample AA Artifacts metacollin 4 5,228 Aug 14, 2009 07:11 PM
Last Post: metacollin
  Shadow Mapping - Self-Shadowing Z-Fighting Artifacts Bachus 16 22,696 Feb 11, 2009 12:24 PM
Last Post: arekkusu
  Opaque and Translucent Objects Intersection Artifacts Bachus 6 3,960 Jan 11, 2003 06:55 AM
Last Post: NCarter