[SOLVED] Rendering artifacts and eventual crash

vicoder

01-12-2007 05:23:34

Hey everyone,

This is my first post. I am quite impressed with the Ogre engine and PagedGeometry addon. I have written some code using both and am experiencing a problem. It would appear to me that it is a vertex buffer corruption of some sort. I have seen large triangles stretched across the terrain. Some with colors stretched. Others with tiled images of the vegitation it is attempting to reproduce. I have attached a screen shot. In any case the software will eventually crash. No problems when no PagedGeometry is used. It seems to happen when I add a second PageGeometry object to the scene.

My Configuration:
Dual Core 1.86MHz
1 gig RAM
nvidia 7800 graphics

JohnJ

01-12-2007 16:30:20

This sounds like the same problem as reported here:
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=5869

I'm going to try to reproduce and fix this today.

JohnJ

01-12-2007 17:50:38

Ok, the problem has been reproduced and should be fixed in the CVS version (let me know if you don't know how to download from CVS - I can e-mail you the new version if you want).

The problem was that when you use batch sizes large enough, the number of vertexes per batch exceeded 65535 (or 0xFFFF), the maximum value which can be stored in an unsigned 16-bit integer. BatchedGeometry was trying to use 16-bit integers to store polygon connection data, which obviously won't work when there are more than 65535 vertices to connect. Now BatchedGeometry will upgrade the index format to 32-bit if you use batches large enough to require it. However, if your batches are this large it's recommended that you consider reducing them: not all cards support 32-bit indexes I think, and batches this large probably won't load smoothly in real-time.

vicoder

01-12-2007 18:34:42

Thanks for the quick response. By batch size do you mean that the page size for loading is too large? I have tried smaller page sizes and the frame rate drops even when sitting still. I settled on using the PagedGeometry configuration from the Treeloader3D example which produced this problem. Thanks again for the quick response. I'll get the CVS code and compile it and let you know what I find.

vicoder

vicoder

01-12-2007 19:27:09

I ran the updated code. It ran very well. Much smoother page transisitions. However after about a minute it quit with an OGRE EXCCEPTION



It appears to be chewing up memory.

Before:



After, but before closing error window:



When running in OpenGL it didn't throw an exception but after a couple of minutes of flying around it started hesitating a second or 2 at each page load. After that memory was max'ed and the system didn't recover from that after the application was terminated. Additionally it took about 3 minutes for the program to exit.

Thanks for all of your help and hard work,
vicoder

JohnJ

01-12-2007 23:42:43

Hmm... this looks like another bug, unrelated to the messed up index buffer bug above (which I just solved). Can you post the parameters (page size, etc.) you use to setup your trees / grass so I can try to reproduce?

vicoder

01-12-2007 23:57:03

This is my setup code:

Grass = new PagedGeometry(mCamera, 50);
Grass->addDetailLevel<GrassPage>(200);
grassLoader = new GrassLoader(Grass);
Grass->setPageLoader(grassLoader);
grassLoader->setHeightFunction(&getTerrainHeight);
grassLayer = grassLoader->addLayer("FGrass01");

grassLayer->setMinimumSize(2.0f,2.0f);
grassLayer->setMaximumSize(2.5f,2.5f);
grassLayer->setAnimationEnabled(true);
grassLayer->setSwayDistribution(10.0f);
grassLayer->setSwayLength(0.5f);
grassLayer->setSwaySpeed(0.5f);
grassLayer->setDensity(1.0f);
grassLayer->setFadeTechnique(FADETECH_ALPHA);
grassLayer->setMapBounds(TBounds(0,0,AlphaMapEditor->PageWorldX,AlphaMapEditor->PageWorldZ));
grassLayer->setDensityMap(AlphaMapEditor->TAlpha[0].get(),CHANNEL_RED);
grassLayer->setColorMap(AlphaMapEditor->TAlpha[1].get(),CHANNEL_ALPHA);

Dandelion = new PagedGeometry(mCamera, 30);
Dandelion->addDetailLevel<GrassPage>(100);
dandelionLoader = new GrassLoader(Dandelion);
Dandelion->setPageLoader(dandelionLoader);
dandelionLoader->setHeightFunction(&getTerrainHeight);
dandelionLayer = grassLoader->addLayer("Dandelion");

dandelionLayer->setMinimumSize(2.0f,2.0f);
dandelionLayer->setMaximumSize(2.5f,2.5f);
dandelionLayer->setDensity(0.05f);
dandelionLayer->setFadeTechnique(FADETECH_ALPHA);
dandelionLayer->setMapBounds(TBounds(0,0,AlphaMapEditor->PageWorldX,AlphaMapEditor->PageWorldZ));
dandelionLayer->setDensityMap(AlphaMapEditor->TAlpha[0].get(),CHANNEL_GREEN);
dandelionLayer->setColorMap(AlphaMapEditor->TAlpha[1].get(),CHANNEL_ALPHA);

I'm using Ogre Version 1.4.5 (Eihort) pre-compiled that I downloaded from ogre3d.org recently.

Thanks for looking into it. I really dig the look with your addon.
vicoder

JohnJ

04-12-2007 04:28:11

I've been trying to reproduce your problem, using almost exactly the same code you posted, with no success. The memory usage rises and continues to rise for a little bit when the application is running, but after a few seconds of moving the camera around it will level off, and even drop a little. When I stop moving the camera, the memory usage drops even more as PagedGeometry frees up unused cached geometry.

As you can see, the steady rise in memory consumption you're getting doesn't seem to be appearing in my tests:


Is there any more info you can give me that might help me determine the source of the memory leak? So far it looks like the memory leak isn't PagedGeometry's fault, but I'm not going to conclude anything yet. If you comment out the use of PagedGeometry in your project, does the memory consumption stop rising?

vicoder

06-12-2007 04:06:56

Thanks for your hard work. Possibly the reason I'm have a problem is that I don't stop moving. I continue to fly around until it crashes. The game that I am developing requires the camera to move constantly flying over the terrain. I was wondering if it might be the fact that I'm not giving the code enough time to clear memory. I'll try moving for a while then letting it sit and see if I get the same result as you.

Thanks again,
vicoder

vicoder

08-12-2007 02:11:30

JohnJ,

I found the problem. It was in my code. I did a copy and paste when I added the dandelions to the scene then edited the code. As you can see by the post I made with that code I failed to edit the entire addlayer line for the dandelions. My apologies for wasting your time. I fixed the line and all is well. I feel a bit embarrased since I make my living as a software developer but in my defense I have been taking a lot of pain medication for a recent back injury. Getting to know Ogre and all of the fine work in the community has been my diversion as I recover at home.

Thanks again,
vicoder

syedhs

08-12-2007 03:55:04

Getting to know Ogre and all of the fine work in the community has been my diversion as I recover at home.

Get well soon! Oh, we hope you will continue using Ogre even after you are fully recovered :)

JohnJ

08-12-2007 04:32:03

I found the problem. It was in my code. I did a copy and paste when I added the dandelions to the scene then edited the code. As you can see by the post I made with that code I failed to edit the entire addlayer line for the dandelions. My apologies for wasting your time. I fixed the line and all is well.
No need to apologize :) Actually I should apologize for not spotting that problem the addLayer line (I should have copied and pasted your code when testing too - instead I just replicated the parameters, which obviously didn't reproduce the problem).

I feel a bit embarrased since I make my living as a software developer but in my defense I have been taking a lot of pain medication for a recent back injury. Getting to know Ogre and all of the fine work in the community has been my diversion as I recover at home.
Don't feel too bad - copy n' paste errors like that are easy to miss, even for the best programmers :)

Get well soon!