Game Development Community

Maximum product-supported texture dimension

by John Walsh · in Torque 2D Beginner · 07/03/2013 (10:26 am) · 12 replies

I've added a rather large image for my background scenery but when I run my .exe it comes up with this error in the log:
TextureManager::loadBitmap() - Cannot load bitmap 'C:/Users/John/Documents/Torque Projects/FirstGame1/modules/myModule/assets/scenery1.png' as its dimensions exceed the maximum product-supported texture dimension.

Is there anyway I can solve this? (My program still runs, but without my background)

#1
07/03/2013 (10:45 am)
In TextureManager.h, you can change this line to reflect your needs.

#define MaximumProductSupportedTextureWidth 2048

Meaning that the maximum texture size is 2048x2048.

A quick Google search for limitations :

iOS Pre 3GS = 1024x1024
iPads = 2048x2048

Modern GPUs vary a lot however, my Geforce GTS 450 reports a max texture size of 16384x16384. At a 16-bit color depth, that's 500 megs for one texture.

In the end it really depends on your target hardware and your needs.

If you want to use a large background without having large textures, you can use a CompositeSprite, splitting the large pictures into tiles.
#2
07/03/2013 (11:35 am)
Thanks, I edited my TextureManager.h and recompiled and it worked.
#3
07/03/2013 (11:46 am)
When I run my program now my .png loses a lot of quality and sharpness. Should I be using CompositeSprite instead?
#4
07/03/2013 (11:51 am)
You can try
%img = Sprite.Image;
%img.SetFilterMode("mode");

where mode is either NEAREST or BILINEAR

Note that you can also specify this directly in the asset's taml file.
#5
07/03/2013 (12:13 pm)
What does that do exactly?
#6
07/03/2013 (12:18 pm)
It sets how the bitmap is filtered by OpenGL

NEAREST is pretty much how the file originally looks
BILINEAR will blur things a little for a smoother appearance.

so if your texture was not as sharp as expected, try setting its filter mode to NEAREST.

A quick google search for NEAREST VS. BILINEAR Will show you exactly what I mean.
#7
07/03/2013 (1:45 pm)
I'm getting the error:
modules/myModule/scripts/background.cs (23): Unable to find object: '' attempting to call function 'setFilterMode'

I used %background for %img as that's the local variable for my background?

Here's the background.cs (without your code):
function createBackground( %this )
{
    %background = new Sprite(Scenery);
    
    %background.setBodyType( static );

    %background.Position = "0 0";

    %background.Size = "100 75";
    
    %background.SceneLayer = 31;
    
    %background.Image = "myModule:scenery1";

    /* Create border collisions.
    %background.createEdgeCollisionShape( -50, -37.5, -50, 37.5 );
    %background.createEdgeCollisionShape( 50, -37.5, 50, 37.5 );
    %background.createEdgeCollisionShape( -50, 37.5, 50, 37.5 );
    %background.createEdgeCollisionShape( -50, -34.5, 50, -34.5 );
    
    */
          
    myScene.add( %background );    
    

}
#8
07/03/2013 (1:51 pm)
SetFilterMode only exists in the ImageAsset namespace.

It should be called on %background.Image and not on %background itself.

%background is a Sprite, its Image filed points to an ImageAsset.

In this case, the line should be

%img = %background.Image;
%img.SetFilterMode("NEAREST")

or %background.Image.SetFilterMode("NEAREST");

Although I'm not sure option 2 works.
#9
07/03/2013 (2:08 pm)
I've added it in, and the background does show now, but I'm getting this error:
modules/myModule/scripts/background.cs (26): Unable to find object: 'myModule:scenery1' attempting to call function 'setFilterMode'

-----

function createBackground( %this )
{
    %background = new Sprite(Scenery);
    
    %background.setBodyType( static );

    %background.Position = "0 0";

    %background.Size = "400 400";
    
    %background.SceneLayer = 31;
    
    %background.Image = "myModule:scenery1";

    /* Create border collisions.
    %background.createEdgeCollisionShape( -50, -37.5, -50, 37.5 );
    %background.createEdgeCollisionShape( 50, -37.5, 50, 37.5 );
    %background.createEdgeCollisionShape( -50, 37.5, 50, 37.5 );
    %background.createEdgeCollisionShape( -50, -34.5, 50, -34.5 );
    
    */
         
    myScene.add( %background );    

   %img = %background.Image;  
   %img.SetFilterMode("NEAREST");  
   
}

Also, my .png is still blurry. I've been playing around with "%background.Size = "400 400";" trying to fix the problem but either it's not helping or I'm not getting the exact precise number. I tried option 2 as well but that didn't work either :/
#10
07/03/2013 (2:11 pm)
ok, the error means that %img points to the asset ID and not the ImageAsset Object.

replace
%img = %background.Image;

with

%img = AssetDatabase.acquireAsset(%background.Image);
#11
07/03/2013 (3:33 pm)
Thanks I'm not getting any error messages any more although the image is still blurry. I guess I'll just keep editing the sizes and zooms until I get it right. Thanks for your help again.
#12
07/03/2013 (4:12 pm)
John,

Simon is FAR more experienced with T2D than I am however, Are you running your final version in a NATIVE resolution for your graphics set-up? I know this sounds crazy but, up and down sampling can cause issues with blur and fuzziness. This is graphic card based, NOT Torque based. Just a thought.

Ron