SFML community forums

General => General discussions => Topic started by: jamesL on July 13, 2016, 04:50:40 am

Title: is it "better" if textures are square ?
Post by: jamesL on July 13, 2016, 04:50:40 am

I just did the
Example: tile map
at the bottom of
http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php

I had to download the image and cut it up and piece it together to make the tileset

first I tried to make a square of 2 x 2
that didn't work
then I made a rectangle of 4 x 1

http://imgur.com/a/BSov0

http://i.imgur.com/DWce8Fs.png

to my surprise that worked

I know nothing about graphics, but I just assumed its "better" if tilesets are be square  --- I assumed its more optimized or something 

so does it matter ?
square or rectangle ? is one better or preferred ?

this was a small tileset, but what if it were larger
say a nice square of
32 tiles x 32 tiles with each tile being 16 x 16 
or a rectangle of
1024 tiles x 1 tile with each tile being 16 x 16 

they're both the same image size, but the 2nd one just seems wrong to me
Title: AW: is it "better" if textures are square ?
Post by: eXpl0it3r on July 13, 2016, 09:29:28 am
Not anymore really. In the past GPUs only supported texture size of 2^n x 2^n. Today this is not the case anymore and both your textures will work fine.
Title: Re: is it "better" if textures are square ?
Post by: SeriousITGuy on July 14, 2016, 10:02:53 am
What eXplOit3r said, but I think it is worth mentioning, that if you want no sprite clipping issues, and especially when you work with sprite rotation and scaling that you better use square sprites with sizes of 2^n.
Title: Re: is it "better" if textures are square ?
Post by: Tank on July 19, 2016, 09:56:54 am
I'm unsure, but do drivers nowadays still expand the textures to match 2x boundaries? Personally I've always used quadratic-sized textures to be able to use them effectively regarding space.
Title: Re: is it "better" if textures are square ?
Post by: aggsol on July 19, 2016, 01:40:56 pm
Well, if you target is android then using 1024x1024 as max size is key.  Having power of 2 square textures might be easier for using texture coordinates as well. Seems to be a matter of taste nowadays.
Title: Re: is it "better" if textures are square ?
Post by: Hapax on July 19, 2016, 02:05:02 pm
this was a small tileset, but what if it were larger
say a nice square of
32 tiles x 32 tiles with each tile being 16 x 16 
or a rectangle of
1024 tiles x 1 tile with each tile being 16 x 16 

they're both the same image size, but the 2nd one just seems wrong to me
The images use the same sized 'area', yes, but the maximum size for a texture is not its area, but its single dimension squared.
With your example, the first one (32x32) requires a texture of 512x512 pixels and almost certain to find support for that. However, the second one (1024x1) requires a texture width of 16384 and therefore requires support for textures of size 16384x16384 of which there is much less support.