iDevGames Forums
Strange Artifacts In Heightfield - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Strange Artifacts In Heightfield (/thread-4347.html)



Strange Artifacts In Heightfield - Nick - Apr 15, 2006 02:24 PM

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]


Strange Artifacts In Heightfield - akb825 - Apr 15, 2006 04:45 PM

When you move around, do the artifacts move? They look like extra polygons made by an errant vertex array.


Strange Artifacts In Heightfield - Nick - Apr 15, 2006 07:28 PM

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();



Strange Artifacts In Heightfield - akb825 - Apr 15, 2006 07:40 PM

*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


Strange Artifacts In Heightfield - Nick - Apr 15, 2006 07:43 PM

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.


Strange Artifacts In Heightfield - akb825 - Apr 15, 2006 07:52 PM

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?


Strange Artifacts In Heightfield - Chris Ball - Apr 15, 2006 09:19 PM

It looks like you have gaps where the triangle size changes (the resolution band edges).


Strange Artifacts In Heightfield - SOUCHAN - Apr 16, 2006 04:11 AM

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?


Strange Artifacts In Heightfield - Nick - Apr 16, 2006 05:52 AM

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


Strange Artifacts In Heightfield - SOUCHAN - Apr 16, 2006 05:58 AM

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/technical/depthbuffer.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