[SOLVED] Rendering artifacts and eventual crash
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.
Dual Core 1.86MHz
1 gig RAM
nvidia 7800 graphics
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.
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.
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.
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,
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?
This is my setup code:
Grass = new PagedGeometry(mCamera, 50);
grassLoader = new GrassLoader(Grass);
grassLayer = grassLoader->addLayer("FGrass01");
Dandelion = new PagedGeometry(mCamera, 30);
dandelionLoader = new GrassLoader(Dandelion);
dandelionLayer = grassLoader->addLayer("Dandelion");
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.
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?
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.
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.
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
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!