hole appear beetween polygon

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jeromebdx
Posts: 8
Joined: Mon Mar 05, 2012 11:41 pm

hole appear beetween polygon

Post by jeromebdx »

Hello everyone,

A problem appear when i try to render two surface (with two polygon) : some hole appear beetween polygon (just one pixel, and we see the background color).
Depend of the position of the camera, it appears everywhere beetwen two surface (screenshot => http://hpics.li/5517e48)

I think it is a problem of finite numerical precision limit, but i am not sure,

do you know this problem and how I can solve that ?

Thanks a lot

jerome
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: hole appear beetween polygon

Post by hybrid »

Depends on how you create the polygons, which are the exact locations, what drivers you use, etc. Maybe show the full code?
jeromebdx
Posts: 8
Joined: Mon Mar 05, 2012 11:41 pm

Re: hole appear beetween polygon

Post by jeromebdx »

ok, I made some test with examples of irricht and itis works,
I think that it's a problem of surface recovery.

I am looking to rewrite my code

thanks

jerome
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: hole appear beetween polygon

Post by REDDemon »

outdated video drivers have this problem. If you draw 2 triangles across 4 points (says a quad) with a single draw call its ok, but if you draw the two triangles in 2 separate draw call (using the same exact vertices, and also with the same transform/view matrix) in certain video cards you will see holes on the edge.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
jeromebdx
Posts: 8
Joined: Mon Mar 05, 2012 11:41 pm

Re: hole appear beetween polygon

Post by jeromebdx »

well,

finaly, i'am not able to solve my problem, so i wrote a small (and dirty :)) code to illustrate.

And to be sure that we speak about the same thing, I upload a video of the result : http://youtu.be/61d3VSXc-bw
You can see some white hole appear beetwen surfaces.

I really apreciate if you have a solution :D

jerome

Code: Select all

#include <irrlicht/irrlicht.h>
 
using namespace irr;
 
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
class Test
{
        public:
        static void build(core::array<S3DVertex> &vertices, const vector3df &pos, const vector3df &size)
        {
                vector3df front[4] = { vector3df(-.5, -.5, .5),
                                                                vector3df(.5, -.5,  .5),
                                                                vector3df(.5,  .5,  .5),
                                                                vector3df(-.5,  .5, .5)};
                for(char i=0;i<4;i++)
                {
                        vector3df p = front[i] * size + pos;
                        
                        vertices.push_back(S3DVertex(p,
                                                                 vector3df(-1,0,0),
                                                                 SColor(255, 255, 255, 255),
                                                                 vector2df(0,0)));
 
                }
        }
};
 
void add_surface(ISceneManager* smgr, const vector3df &pos, const vector3df &size)
{
        core::array<S3DVertex> vertices;
        array<u16> indices;
        Test::build(vertices, pos, size);
        indices.push_back( 0 );
        indices.push_back( 1 );
        indices.push_back( 2 );
        indices.push_back( 2 );
        indices.push_back( 3 );
        indices.push_back( 0 );
        
        scene::SMeshBuffer *buf = new scene::SMeshBuffer();
        SMesh *mesh = new SMesh();
        buf->append(vertices.pointer(), vertices.size(), indices.pointer(), indices.size() );
        mesh->addMeshBuffer(buf);
        buf->Material.setFlag(video::EMF_LIGHTING, true);
        buf->drop();
        smgr->addMeshSceneNode(mesh);
}
 
int main()
{
        IrrlichtDevice *device =
                createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
                        false, false, false, 0);
 
        if (!device)
                return 1;
 
        device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
        device->getCursorControl()->setVisible(false);
        
        IVideoDriver* driver = device->getVideoDriver();
        ISceneManager* smgr = device->getSceneManager();
        IGUIEnvironment* guienv = device->getGUIEnvironment();
 
        ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50, 0.2);
        camera->setPosition(vector3df(0, 0, 20));
        camera->setTarget(vector3df(0,0,0));
 
        add_surface(smgr, vector3df(0,0,0), vector3df(10,10,10));
 
        add_surface(smgr, vector3df(10,0,0), vector3df(10,20,10));
        while(device->run())
        {
                driver->beginScene(true, true, SColor(255,200,200,200));
 
                smgr->drawAll();
                guienv->drawAll();
 
                driver->endScene();
        }
 
        device->drop();
 
        return 0;
}
 
jeromebdx
Posts: 8
Joined: Mon Mar 05, 2012 11:41 pm

Re: hole appear beetween polygon

Post by jeromebdx »

Nobody can help me ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: hole appear beetween polygon

Post by hybrid »

I have to admit that I cannot see any hole in the video. But as it seems you have to quads which overlap, and which are exactly adjacent to some extent. This can lead to z-buffer fighting and in turn to wrong render orders or other artifacts. This will always occur if you have surfaces which align perfectly, but also overlap for some larger area. You can put a little distance between the surfaces, or use the polygon offset attribute in material (maybe only for Irrlicht 1.8, not sure yet).
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: hole appear beetween polygon

Post by REDDemon »

the only other way to solve the problem is to manually remove edges by overlapping primitives a bit.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
booe
Posts: 76
Joined: Thu Jul 29, 2010 2:12 pm

Re: hole appear beetween polygon

Post by booe »

hybrid wrote:I have to admit that I cannot see any hole in the video. But as it seems you have to quads which overlap, and which are exactly adjacent to some extent. This can lead to z-buffer fighting and in turn to wrong render orders or other artifacts. This will always occur if you have surfaces which align perfectly, but also overlap for some larger area. You can put a little distance between the surfaces, or use the polygon offset attribute in material (maybe only for Irrlicht 1.8, not sure yet).
I can see it! It's as white as a sheep!

ermmmm,,,, what about playing with multisampling?
utunnels
Posts: 37
Joined: Thu Apr 05, 2012 2:52 pm

Re: hole appear beetween polygon

Post by utunnels »

http://i.imgur.com/XIb4P.jpg

I think it is kinda like this. The D3D driver doesn't produce a gap in the face while openGL dirver does from certain angles. The model I'm using might not be accurate thought.

And it seems the coords are cauculated differently, for example in the picture, the opengGL driver seems to have smaller faces, for example, the edges of the leaves and the petals.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: hole appear beetween polygon

Post by REDDemon »

yes that's a driver bug. I have that bug on my laptop, the same don't happens on other computers I tried.. Also quake 3 levels of IRrlicht demo shows that seams on my pc.. probably is fixed if you update video drivers (i'm not updating because I need old drivers for tests). you can partially hide that artifact by disabling backface culling. (in certain cases the artifact will be visible, and disabling backface culling can increase render time if done for a whole scene).
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Post Reply