Page 1 of 1
hole appear beetween polygon
Posted: Mon Mar 05, 2012 11:48 pm
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
Re: hole appear beetween polygon
Posted: Tue Mar 06, 2012 11:54 am
by hybrid
Depends on how you create the polygons, which are the exact locations, what drivers you use, etc. Maybe show the full code?
Re: hole appear beetween polygon
Posted: Fri Mar 09, 2012 9:48 am
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
Re: hole appear beetween polygon
Posted: Fri Mar 09, 2012 3:47 pm
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.
Re: hole appear beetween polygon
Posted: Tue Mar 13, 2012 10:46 pm
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
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;
}
Re: hole appear beetween polygon
Posted: Thu Mar 15, 2012 7:48 am
by jeromebdx
Nobody can help me ?
Re: hole appear beetween polygon
Posted: Thu Mar 15, 2012 8:55 am
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).
Re: hole appear beetween polygon
Posted: Thu Mar 15, 2012 8:24 pm
by REDDemon
the only other way to solve the problem is to manually remove edges by overlapping primitives a bit.
Re: hole appear beetween polygon
Posted: Thu Apr 05, 2012 6:05 am
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?
Re: hole appear beetween polygon
Posted: Fri Apr 06, 2012 1:50 pm
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.
Re: hole appear beetween polygon
Posted: Fri Apr 06, 2012 7:48 pm
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).