Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: is it "better" if textures are square ?  (Read 4267 times)

0 Members and 1 Guest are viewing this topic.

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
is it "better" if textures are square ?
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: is it "better" if textures are square ?
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SeriousITGuy

  • Full Member
  • ***
  • Posts: 123
  • Still learning...
    • View Profile
Re: is it "better" if textures are square ?
« Reply #2 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.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: is it "better" if textures are square ?
« Reply #3 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.

aggsol

  • Newbie
  • *
  • Posts: 24
  • C++
    • View Profile
    • My Github Account
Re: is it "better" if textures are square ?
« Reply #4 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: is it "better" if textures are square ?
« Reply #5 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*