Weird texture problem!

Blitz3D Forums/Blitz3D Programming/Weird texture problem!

jfk EO-11110(Posted 2005) [#1]
I am working with this decorator exported map since some time. I had some troubles, but finally I was able to export it optimized.

For some time I was using it in Interior Dropper(only reading it, never ever touched it in any writing mode), but then all of a sudden the grass texture chanched.

Here's an image how it looked for some time and how it should look:


And this is how it looked after some time. The flat ground texture chanched from floor5.jpg to floor6.jpg (also scaling) all of a sudden! I didn't chanche anything! Is this weird or what?



After some time I found out the texture is still displayed correctly in the engine. After some tests it seems, in Fullscreen it's displayed correctly, but no longer in windowed mode. what the - I hate it when unlogical things happen. First I thought it probably has something to do with absolute vs relative paths inside the mesh, but then I realized: both apps are using exactly the same mesh file.

Is this a bug? What's going on?!?

***********************************

EDIT I am currently trying to isolate te problem. Not so funny when it takes more time to solve problems than to create the art content, that is btw a heavy job by its own anyway. However.

Right now I have written a little test program that will check all triangles agains one another. One would think every Triangle should be there only once, especially when you have a max of two texture layers (diffuse + lightmap).

Surprisingly my app just told me that of 20573 Tris there are 15207 indentical tris. I can hardly believe this and am curretnly trying to find a bug in my test app, without luck so far, could this really be? Or is there some reason for identic multiple triangles that I don't think of right now?

Well, I'll let you know when I know more.

EDIT 2
Ok I have found a bug in the test app: when a triangle was there mutliple times, it was also counted multiple times, from the point of view of every Triangle. However, now I have edited it in a way that "clones" no more count their clones, the result is now:

3449 double Tris out of a 20573 Tris mesh.
Makes more sense, but is still a desaster if it's true.

EDIT 3 -------------------- (and conclusion so far)
Ok, it seems I am getting closer to the isolation of the problem. I have added some code to the test app that will reassemble the complete mesh with all surfaces, copying every aspect possibe (normals, vertex colors, alpha, uvs etc.), and most important, I did not include the double triangles. Now I got 17124 Triangles only, with the same visual result! a walktrough test was showing me there ain't no Tris missing. This means, the 3449 double Tris are not needed! Of course, there is one problem left no, how do I know what clone should I use when there are multiple Triangles. Right now I was able to reduce the polycount in a remarkable amount, but there where still the wrong textures used.

Basicly, the problem seems to be clear now: Decorator is creating additional Triangles in some cases. The triangles are then not removed by the optimation process. It is also some kind of random game if clone one or two of 2 identical Triangles will be rendered (bysides, a remark my Mark suggests identical Tris may cause massive slowdown), because the zbuffer has to choose from two identical depths. you can reproduce the bug this way: load and export a mesh several times in Decorator, the Number of triangles increases repeatedly, whenever you save it and then restart decorator.

It seems "save optimized" does only weld the vertices, but won't remove double triangles. Lee if you read this: I'd say it's a real bug that may be fixed realtive easily (I can give you my code, but it's pretty slow due to comparing 20k Tris vs 20k Tris in a bruteforce method, takes about a minute or so)

Removing double triangles could also be performed on a Per Surface base, whenever the user alters the painting brush (well in fact only when he is actually painting something with a new brush), this would be faster. Although it's still slow.

I still try to find an elegant solution that would remove the bad triangles and leave the wanted triangles unchanched.
The blues goes on :-°

EDIT 4 ----------

Ok, some good news: For every Triangle there seems to be a max of one possible clone (at least in my mesh). So all I had to do is using the clone instead of the first triangle found . Well this seems to be luck, because there's nothing that defines what's the clone and what's the original. The only thing I could think of is the creation date of the triangles. The ones that have been found later where also "painted" (= created) later.

So all I have to do now it adding a welding and a SaveB3D routine that can save a lightmapped level properly. I'll release this utility ASAP, but I'm not sure if it works for all similar problems, for the named reasons (no way to find out what triangles are unwanted clones and what's not).


jfk EO-11110(Posted 2005) [#2]
Ok, here's the test app.



BlackJumper(Posted 2005) [#3]
Ya gotta love jfk...

... Find problem. Post problem. Tackle problem. Re-tackle problem. Re-re-tackle problem. Solve problem. Share solution.

... and it's not even Xmas yet.

Cheers for this. Hopefully Lee can find time to take this on board.


jfk EO-11110(Posted 2005) [#4]
yeah, thanks. I just tested the exporter, seems to work nicely. Gimme a couple of minutes.

EDIT
Outch new problem. Loading order of the surfaces is diffrent every time, so it's not so easy to say if you shoud save the first tris or the second tris of the clones.


jfk EO-11110(Posted 2005) [#5]
Ok, here's this little emergency tool, very custom and inhouseish:
http://www.melog.ch/dl/kill_decorator18_clonetris_src.zip

or copy paste from here:


the required b3dfile.bb include file:



DH(Posted 2005) [#6]
Wonderful work there jfk, that was a pleasure to read!

What format are you exporting this in? If its B3D, you could always write your own in-house loader and optimizer (and even exporter). Its a bit of a "why should I do that?" resolution, however it seems that your editor really has issues with saving out more than needed geometry.

Just a thought


jfk EO-11110(Posted 2005) [#7]
Thanks for the suggestion. Probably there was a misunderstanding, caused by my broken english. It's not my editor, it's TeraBit's. The bug occurs rarely, so it wasn't reported until now. It is also something that is hidden very well.

My Optimizer Loads a b3d, then removes unneeded Triangles (clones) and welds the result, then saves it as b3d. It's an acceptable solution. Of course I hope this won't be neccessary anymore as soon as Terabit has fixed this in the original content creation tool: decorator, which is BTW. a pleasure to work with.

EDIT
Terabit just released version 1.81 with a bug fix for this and for a problem some other people had with the bitzsys.dll. So go and get it from from the toolbox.


DH(Posted 2005) [#8]
Yeah, I hear ya