Game Development Community

Purple Screen

by Doug Barnes · in Torque X 2D · 11/26/2007 (10:24 am) · 19 replies

Hello Everyone,

Ok so here is the problem I am having when I draw to many objects on screen all of a sudden object start to disappear and the entire background of the game goes purple. Has anyone ever had this happen to them? I could really use some help fixing this problem because I have no idea where to even start.

Thanks in advance,
Doug

#1
11/26/2007 (10:40 am)
Is this consistently happening for you with every project or just a specific game? For example, if you create a new game using the StarterGame template and then add the objects, does it still happen? Also, how many is "many"... a couple dozen? or more like a couple thousand?

John K.
#2
11/26/2007 (11:11 am)
It happens in every project and I have about 70 objects on screen.
#3
11/26/2007 (11:28 am)
Very interesting. I can't reproduce it at all, I created a new project from the StarterGame template and then filled the scene with 10,000 GarageGame logos. My frame rate drops to a solid 1fps, but there are no disappearing objects or purple screen. And this was running on a POS Dell Latitude D610 with a Mobile Intel 915 video adapter, not my Dell XPS.

So, I'm guessing the problem is either with your video card or there is something special in your code. If you want to reproduce my tet case, just create a new StarterGame project. Then, in Torque X Builder, add a single GGLogoMaterial to the scene, marked as a Template and named "ggTemplate". Then, add the following code to the BeginRun() method just after the scene loads.

T2DSceneObject ggTemplate = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("ggTemplate");
 
T2DSceneObject clonedObject;
 
if (ggTemplate != null)
{
    Random randomGenerator = new Random();
    for (int i = 0; i < 100; i++)
    {
        int x = randomGenerator.Next(-50, 50);
        int y = randomGenerator.Next(-36, 36);

        clonedObject = (T2DSceneObject)ggTemplate.Clone();
        clonedObject.SetPosition(new Vector2(x, y), true);
        clonedObject.Layer = 10;
        TorqueObjectDatabase.Instance.Register(clonedObject);
    }
}

If this is still causing the problem, you should verify that you have the latest drivers for your video card.

John K.
#4
11/26/2007 (2:24 pm)
@John - What version of the TX code do you have?
#5
11/26/2007 (4:25 pm)
It should be on 1.0.5.1, but I'll double check on that. Are you see the same problem too?

John K.
#6
12/12/2007 (8:24 am)
Anyone have any clue about this? Another issue, which seems related, is objects actually vanish after you get so many on screen. It seems to happen at around 70 objects on the screen. In some cases, they turn purple, in others they completely vanish from the screen. Anyone from GG have any clue?
#7
12/12/2007 (6:40 pm)
I just tried John's test and I couldn't reproduce your problem. This was on a Radeon X600. Would you mind describing your project a little more? Is your project based on a starterGame template? Does this just happen with static sprites, or animated sprites too? Do you override Draw? Did you attempt John's test and what were your results? Finally, what kind of hardware are you running?
#8
12/13/2007 (7:18 am)
Using John's test, and the latest beta of TX, the issue happened immediately. One of two things happens, either the purple screen, or stuff starts vanishing. Did you spawn the images in different locations and possibly number them so you could ensure you weren't seeing some dissapear and not knowing it?
#9
12/13/2007 (2:30 pm)
Yes my images were spwaned at different locations and I could count them all when that number was reasonable (less than 100). What about some of my other questions?
#10
01/03/2008 (9:14 am)
I was having the same problem with objects disappearing, so I tried the test code above. Same results. I can't get more than about 70 objects to render, no matter what I set the count to. I'm using the 3d open beta, and have reproduced the problem on 3 machines with 3 different video cards.

In my app, the objects are still there, updating, colliding etc., they're just not rendering. If you're spawning any kind of bullets etc. you reach this limit very quickly...

Can someone confirm that the test code above actually works as expected with the open beta? Make sure you make ggTemplate small (1x1) and crank up the number to 1000 - are you actually seeing 1000 objects?

Some more info:
- My project was based on a Starter Game template.
- I don't override Draw.
- I only have a few objects on screen at any time. The problem seems to be related to the total number of objects you've created rather than the number on screen. It's almost as though MarkForDelete doesn't free all resources properly...
- I see the problem with static and animated sprites, as well as particle effects.
- Newer objects seem to render fine, older ones just start disappearing.
- Older objects start flickering before disappearing completely.
- I don't see a purple screen, just disappearing objects.

Hope someone can help with this - I can't test my project for more than 30 seconds before objects start disappearing!
#11
01/03/2008 (3:06 pm)
Things do indeed behave this way in Torque X 3d beta. I can't replicate it in the current version ot Torque X, 1.0.5.1.

Excuse my bluntness, but it's a beta release. If you are relying on it for something important, ouch... Sorry, but that's a no no. I'm betting GG is already aware of this problem and will have it fixed at release time.
#12
01/03/2008 (4:36 pm)
I just wanted to confirm that it is in fact a problem that other people are seeing, since from the thread it seemed like maybe other people weren't.

I'm not relying on the beta - but the best way to test a beta is to use it for real (e.g., make a game with it), and report the bugs you find. Assuming that GG already knows about the problem kind of defeats the purpose of a public beta! Personally, I would love to see GG adopt a more organized, public approach to bug tracking so people can see known issues, bug status, etc. E.g., at work we use FogBugz: www.fogcreek.com/FogBugz/. Forums can also work if officially monitored, with topics annotated as [resolved], [fixed], [rejected] etc.

BTW, I'm not bashing the product - Torque X is an awesome engine, I love the component design, and I'm having a blast playing with it! Hammering on the beta is only going to make the final release better - it's tough love!

I was also posting extra detail to maybe prompt someone more familiar with the engine to say: "oh, its sounds like blah, just do blah, blah..."
#13
01/03/2008 (5:01 pm)
Yay! I can finally reproduce! I had to change my earlier code sample to the following:

T2DSceneObject ggTemplate = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("ggTemplate"); 
T2DSceneObject clonedObject = null;
int MAX_X = 10;
int MAX_Y = 10;
if (ggTemplate != null) 
{ 
    Random randomGenerator = new Random();
    for (int x = 0; x < MAX_X; x++)
    {
        for (int y = 0; y < MAX_Y; y++)
        {
            //int x = randomGenerator.Next(-25, 25);
            //int y = randomGenerator.Next(-18, 18);
            clonedObject = (T2DSceneObject)ggTemplate.Clone();
            clonedObject.SetPosition(new Vector2(x, y), true);
            clonedObject.Layer = 10;
            TorqueObjectDatabase.Instance.Register(clonedObject);
        }
    }
    
    //draw the box
    T2DPolygon poly = new T2DPolygon(); 
    poly.Color = new Vector4(255, 255, 255, 255);
    poly.Position = new Vector2(MAX_X/2, MAX_Y/2);
    poly.Primitive = 4;
    poly.Size = new Vector2(MAX_X, MAX_Y); 
    TorqueObjectDatabase.Instance.Register(poly);
}

Now, that everything is nice and neat in a grid, missing items are more obvious. Look at the following images... In each case, the top-left of the GG Logos grid should start at the (0,0) origin. It works nicely for the 5x5 (25) case. But in the 10x10 (100) case you can see the first few are missing... and in the 25x25 (625) case, many logos are missing.

5x5
www.envygames.com/share/render5x5.jpg
10x10
www.envygames.com/share/render10x10.jpg
25x25
www.envygames.com/share/render25x25.jpg
The good news is that now that I can reproduce, I can dig a little. My hunch is a bug (or limitation) in the bin-instance rendering. Did anyone check into the default bin size attached to the scene graph, maybe we just need to change the default value. Anyway, I'll look more into this.

John K.
#14
01/03/2008 (7:20 pm)
Sorry, let me rewrite that. I was trying to say GG has probably become aware of this problem after the beta was released due to a couple threads like this. There's no way to know for certain though. So, I definitely agree with you about need for organized bug tracking.

I think the reason John and myself weren't seeing the bug at first was because we weren't using the beta, and the poster didn't clarify that until later in the thread. I didn't notice that until today after reading your post, Alex.


@John - DefaultBinSize is the same in both versions.
#15
01/10/2008 (3:29 pm)
Found the problem and got past the 80 objects on the screen limitation. It came down to one line in the source, but it's conditional on a boolean that is public. For your t2dscenegraph set UseLayerSorting to false.

This particular line(353 in T2DSceneGraph.cs) modifies the layerdepth property of a 2d sceneobject which then gets used as Z in the translation portion of the object to world matrix for rendering. My guess is that the Z position puts the object past the view frustum. I dunno...

I'm not so sure it's a bug anymore.
#16
01/10/2008 (4:04 pm)
Awesome! Great find Joshua! Bug or not, this has really been a pesky problem for a lot of people - I'm impressed that you tracked it down. At least it's now documented here for everyone to find.

John K.
#17
01/10/2008 (4:57 pm)
I learned tons about the 2d engine because of this problem. In a way I'm greatful.
#18
01/10/2008 (9:41 pm)
Great news! Thanks!