[solved] Some sort of clipping problem.

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

[solved] Some sort of clipping problem.

Post by agamemnus »

(Edit: see my last post on this thread, on page 2, for a solution.)

I am using the svn as of a few weeks ago.

I'm experiencing incorrect clipping... (possibly an Irrlicht memory buffer overflow?)

http://img401.imageshack.us/i/screensho ... 19291.png/

The blue cyan background is the "sea"... it's a 2-triangle polygon. Its z-buffering is set to on.
Each distinct area is made up of a lot of different triangles. Under almost each "flag" (the square white thing) are models of forts. Under certain viewing angles, various areas start disappearing, like Britain and a bit of northern Europe, in this case.

The problem disappears if I remove the model.

Edit: I managed to make the problem go away, but I think it's a memory overflow issue.. I did use gdb and didn't get any hits with it.

What I have done is this: I exploded two rectangles (rectangles that have textures) in my modeling program (Sketchup 7) and re-exported.

It's very odd. I have this exact same texture setup for those textures in some other models... leaning towards a memory overflow somewhere.
Last edited by agamemnus on Thu Jan 27, 2011 7:32 pm, edited 1 time in total.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

What makes you think it's an overflow issue? It sounds like a simple case of z-fighting.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Because it doesn't happen if I make miniscule (seemingly random) changes to the fort model, and because the fort model (even raised in the air) causes this.

... and because there's no z-fighting when I remove the fort model altogether.

All of that.... is just not normal and completely illogical. :\
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

I am now getting this problem again upon adding another completely innocent model to my game.

No one else has any problems like this?
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Still not solved....

Does anyone have any idea why at certain angles the objects disappear?
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

I noticed that if I make the disappearing area polygons have a zbuffer ON (currently it's off for them), this doesn't happen. It also doesn't happen when the ships (which are just made visible, not added) have no textures (just colors).
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Anyone else?

This still happens after 1.7.2.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

No one can help you until you give people some way to reproduce the problem... which means reduce the problem to a minimal code example + post models necessary to reproduce it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

But I can't do that because I'm coding in Freebasic and I have tens of thousands of lines of interconnected code... :\ It would take absolutely forever to distill the various parts of code and make a C++ example.

Here is something similar:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=40378
Except... I checked the bounding boxes and they are all fine.

All I can say is that it's some sort of "bounding box" problem when objects without a zbuffer are in the scene; perhaps the bounding boxes are internally corrupted -- they show up fine via a bounding box visual test. Both some objects with and without a zbuffer are affected, but again, only when I have objects without a zbuffer.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe the wrapper does not set up all render states properly. So far, there is no evidence that there's a problem in the Irrlicht setup. We cannot search for something which is likely to be non-existant in our code.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

INFO: my program's models/geography/etc. are done with a drawall command.
hybrid wrote:Maybe the wrapper does not set up all render states properly.
A possibility, yes.

Can you think of any combo of render states & settings that could possibly blank an object like I described? Just looking for some speculation so I could try SOMETHING...
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Any other theories?

I don't think it's the wrapper not "setting the render states properly", because:

* It just uses a drawAll command.
* Everything is fine on one angle, but a change of .1 degree of the view will cause Britain (for instance) to disappear. If this is a wrapper bug, it would have to be quite a fiendish bug! :twisted:

See the links here--
http://img696.imageshack.us/i/screensho ... 00360.png/ -- OK
http://img443.imageshack.us/i/screensho ... 00361.png/ -- not OK!

Just a slight rotation in the camera caused this.

Edit: So again, to get rid of the problem I just have to get rid of my flat rectangle, which currently works as "the sea"... here is the wrapper code for setting material flags.

Code: Select all

/* ----------------------------------------------------------------------------
set the material of a node
*/
#define MAX_MAT_FLAGS 17
void DLL_EXPORT IrrSetNodeMaterialFlag( void *vptrNode, unsigned int uiFlag, bool boValue )
{
    E_MATERIAL_FLAG emfFlagTable[] = {
            EMF_WIREFRAME,
            EMF_POINTCLOUD,
            EMF_GOURAUD_SHADING,
            EMF_LIGHTING,
            EMF_ZBUFFER,

            EMF_ZWRITE_ENABLE,
            EMF_BACK_FACE_CULLING,
            EMF_FRONT_FACE_CULLING,
            EMF_BILINEAR_FILTER,
            EMF_TRILINEAR_FILTER,

            EMF_ANISOTROPIC_FILTER,
            EMF_FOG_ENABLE,
            EMF_NORMALIZE_NORMALS,
	           EMF_TEXTURE_WRAP,
	           EMF_ANTI_ALIASING,

	           EMF_COLOR_MASK,
	           EMF_COLOR_MATERIAL
    };


    // if a valid flag is selected
    if ( uiFlag < MAX_MAT_FLAGS )
    {
        // change the flags property on this node
        ((ISceneNode*)vptrNode)->setMaterialFlag(
                emfFlagTable[uiFlag], boValue );
    }
}
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Maybe it has something to do with the Irrlicht model loader.

I guess it wouldn't hurt to post one of the "problem" models here .. maybe someone can check if they don't load properly (I would if I knew how).

There are two models. One is almost exactly the same. 1x_b causes problems, and 1x does not. The only difference between them is that the two textures on the roof of the fort are grouped in separate rectangles for 1x_b. For 1x, they are not grouped in separate rectangles -- they are part of the roof group.

If I remove the textures on the roof, the problem goes away... but I don't see any problems with the textures.

Here's the link:
http://filegator.net/files/fN9JYyz71295988277.html
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

I'm jumping back to drawAll() now.

It seems that there is just no way to set the draw order for objects where the zbuffer is off... in one frame, one node will draw first, and in another, another node will draw first...

This is only apparent when the scene changes in a certain way -- as far as I can tell, any extra object with a zbuffer set to "on" will cause the draw order to fluctuate depending on your viewing angle. :-\
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

agamemnus wrote:I'm jumping back to drawAll() now.

It seems that there is just no way to set the draw order for objects where the zbuffer is off... in one frame, one node will draw first, and in another, another node will draw first...

This is only apparent when the scene changes in a certain way -- as far as I can tell, any extra object with a zbuffer set to "on" will cause the draw order to fluctuate depending on your viewing angle. :-\
I just think that in general it's not a good idea to turn off the z-buffer, especially when it's just for a couple of elements in your scene since you will get these unexpected results

There are other ways to solve your problem...
Post Reply