Problem With OBJ

Started by AGP, July 29, 2012, 06:49:14 AM

Previous topic - Next topic

AGP

Egon, I know you were working on improving the OBJ importer. Any luck? Could it help my current issue? The following show the same model (same OBJ file) imported on jpct and RE-imported into Max (Max gets it right):



EgonOlsen

I've added support for loading normals, but that has nothing to do with the loading of geometry itself. To be honest, i've no idea what i'm seeing in your screen shot nor am i aware of any problems with loading geometry. If there's something wrong, i need at least the model or preferably a test case to see for myself.

AGP

If you look at the back (gray) wall, you can tell that the character in jpct is standing in front of that first (left to right), big, house. And as you can see in the Max render, the house looks perfect. I'll send you the model if it'll help.

EgonOlsen

Looks more like depth buffer issue to me than anything else, but it's actually impossible to tell based on a screen shot. As said, i need the model at least. If you want to speed up processing, create a simple test case as well (i.e. one that loads the textures and a model an displays it at a spot that shows the problem).

AGP

I think you're right about it being a depth buffer issue, but I wrote you a tester that should have illustrated the problem and, instead, renders the model perfectly with the software renderer) Then I went back and tested my game with the software renderer, and the model renders perfectly. I'll send you the tester via e-mail so you can see for yourself.

EgonOlsen

That happens because you are setting everything but the ground to transparent. Transparent objects have to sorted to be rendered correctly. In case of the software renderer, this happens per polygon and works more or less fine in this case. With compiled object of the hardware renderer, this happens per object based on the objects' center. If you do this for a complete scene like this, the sorting has to be faulty in almost every case. Imagine a house standing on the ground and both are sorted based on their centers' depth values...depending on how you look at it, the house will be above or below the ground.

Solution: Don't do this. It's eating up fillrate for no gain anyway. Set only those objects to transparent that have to be...like the trees' leaves. Don't set everything to transparent just to ease things. It's slower and inaccurate and serves no purpose other than being easier to code.

AGP

#6
But I have another level that is a forest, which basically means that everything that isn't the ground is a tree. I'd hate to have to write a loader per level (and I'm not talking about wasting time writing ten lines, I just think it's inelegant).

I'll turn off the transparency and report back, thanks.

EgonOlsen

It shouldn't be a problem for a forest (see for example: http://www.jpct.net/forum2/index.php/topic,2471.msg20470.html#msg20470) as long you don't make opaque objects transparent too (like in your current scene).

It's far more inelegant to make everything transparent IMHO. Have you tried to let the loader handle this? The OBJ-loader can load transparency information from the mtl-definitions as long as you are not mixing transparent and opaque materials in one object (in which case it reverts to opaque).

Anyway, this isn't a design decision of mine, it's a technical requirement. So i can't do anything about it except giving some tips on how to handle this.