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

Author Topic: sf::Shader (GLSL) and texture2DArray?  (Read 3263 times)

0 Members and 1 Guest are viewing this topic.

Predator106

  • Newbie
  • *
  • Posts: 43
    • View Profile
sf::Shader (GLSL) and texture2DArray?
« on: November 09, 2012, 12:44:16 am »
I have a set of texture tiles...> 256 of them (i'm future-proofing here..), and it'd be nice if i could just push to my fragment shader directly to a texture2Darray...as opposed to having either 1 big spritesheet (which would be runtime generated because i fucking hate spritesheets), or something.

that way the the shader could just look them up easily in the texture2d array and be all like "i need tile type 24", *goes to index 23*.

thoughts?


edit: feel free to move to GRAPHICS cat
« Last Edit: November 09, 2012, 12:53:23 am by Predator106 »

Predator106

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: sf::Shader (GLSL) and texture2DArray?
« Reply #1 on: November 09, 2012, 02:08:24 am »
the only thing i can think of is to send all my tiles as one texture into the shader, then the shader then has a sort of spritesheet sort of. i guess that would work...but it's not optimallyw hat i'd prefer...and it means that i have 1 huge extra/needless texture floating around. i kind of prefer simplicity..

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: sf::Shader (GLSL) and texture2DArray?
« Reply #2 on: November 09, 2012, 06:21:34 am »
What I do is something a little more interesting... and costly but extremely helpful at times.
Gimp 2.0 (Maybe you know) has a Exporting Capability that you can export files as .H or .Cpp files.
You heard me... You can keep the files in the memory and without sending it everywhere to be read or something like that. Instead it would be known period in the code.

Down side, not extremely efficient if you have a REALLY large texture file and it can be really cumbersome to deal with unless you have a more streamlined workflow. That case you save, build and forget.

I use it for Icons and Gui Bitmaps.
If you notice I put "....", in my sentences way too much... I'm sorry.

Predator106

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: sf::Shader (GLSL) and texture2DArray?
« Reply #3 on: November 09, 2012, 06:30:02 am »
yeah..not efficient at all (a sort of small sized file takes *megabytes*), and wouldn't really help solve my issue

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: sf::Shader (GLSL) and texture2DArray?
« Reply #4 on: November 09, 2012, 06:57:01 am »
Agreed, Kinda a pain to work with.
Would most likely fit the budget for small 8 bit sprites or Menial stuff like Icons.
I wish they had a better way of storing the data for my idea but that seems non existent for the moment.

Never used Texture 2d arrays before.... but that sounds like something I could use too... let me know how it goes.
Until then I'm hard coding frames and loading them sporadically.
If anything else I helped you somewhere...
If you notice I put "....", in my sentences way too much... I'm sorry.

Predator106

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: sf::Shader (GLSL) and texture2DArray?
« Reply #5 on: November 09, 2012, 07:04:36 pm »
it looks like i will just make a tilesheet/spritesheet generated on the fly, at init time. since i hate spritesheets so i'm not using them in my actual game, just behind the scenes. since texture2darrays apparently have not wholly great hardware support, and if i send a texture2darray composed of 16x16 textures, i heard from a gpu dev that it'll probably get padded out to 128x128 automatically..