Jump to content
  • Advertisement
cgaish

2D texture atlas creator and exporter c++

Recommended Posts

Posted (edited)

Hi,

I am trying to implement a custom texture atlas creator tool in C++, need suggestion regarding any opensource fast API or library for image import and export?

Also this tool will compress the final output atlas image into multiple formats like DXT5, PVRTC and ETC based on user input, what should be the best way to implement this?

Thanks

Edited by cgaish

Share this post


Link to post
Share on other sites
Advertisement
30 minutes ago, cgaish said:

opensource fast API or library for image import and export?

OpenGL? Your PC should already have it installed so you only need a C++ editor.

When making tools like this I like to use irrlicht, very useful for little things like this.

32 minutes ago, cgaish said:

formats like DXT5, PVRTC and ETC

On GitHub there are libraries for all these, just search them one by one.

Share this post


Link to post
Share on other sites

Hello,

before going forward - and as you're going to create a tool, I'd recommend you to decide:

  • What is your target architecture?

    Is the packing tool going to be used by standard PCs (x64 + AVX or SSE?)? Is it going to be GPU-only (Compute shaders or CUDA?)? Targeting mobile market?
     
  • What performance you expect?

    Do you require atlas creation per-frame? Or is it going to be pre-processed?
     
  • Additional features?

    Generating mip-maps? Do you want to store them in the atlas? Have whole atlas mip-mapped? Different algorithm should be used for stored normal maps, alpha maps, diffuse maps!
     
  • Licensing

    Every 3rd party tool you bring in introduces some problems - apart from often adding some unpleasant syntax (which can be encapsulated nice), it is licensing that hurts the most.

 

Why am I asking these questions? Simply because the actual purpose of the tool should be the one deciding the required performance and feature set.

If you require building of texture atlas within single frame, then you are most likely not going to do any S3TC compression directly (there might be a way though - in case everything you want to store is already S3TC compressed). There is also possibility of doing S3TC compression on GPU, which might be fast enough for this purpose.

So... if you require top-performance, you will have to write quite a lot of code yourself and optimize a lot. If you require just pre-processing, using SOIL, DevIL or even OpenCV might be good. Although be sure to read their licenses! And note, that reading or writing images with these will most likely take at least hundreds of ms or even seconds (which caused quite a lot of trouble for me).

As for compression algorithms - I believe https://github.com/castano/nvidia-texture-tools/wiki contains algorithms for S3TC compression. Which could be a good start. Note AMD has also this https://github.com/GPUOpen-Tools/Compressonator - which can be called as a library to compress data block with S3TC or other block compression. You could just call it from your application, therefore saving quite a lot of time either:

  • Copy-pasting S3TC/ETC/... compression and decompression algorithms
  • Writing your own S3TC/ETC/...

If you decide for one of the above (copy-pasting or writing), I heavily suggest at least looking at how those algorithms work (you will most likely need it also for Compressonator, as if I'm not mistaken you need to compress per-block through the library, not as a whole image).

Share this post


Link to post
Share on other sites
25 minutes ago, Scouting Ninja said:

OpenGL? Your PC should already have it installed so you only need a C++ editor.

When making tools like this I like to use irrlicht, very useful for little things like this.

On GitHub there are libraries for all these, just search them one by one.

Thank you for your reply, I am new to OpenGL , so can you export images from opengl too as png etc?

Share this post


Link to post
Share on other sites
Posted (edited)
16 minutes ago, cgaish said:

so can you export images from opengl too as png etc?

Not by default but there is many examples on how to make a exporter.

I want to point out that learning how to save a image is the first step into making a custom atlas tool. If you miss this part it would be like learning the run before you crawl.

Edit:

Irrlicht can export.

Quote

OpenGL will not read or write image files for you. To read or write image files, you can either write your own code, include code that someone else has written, or call into an image file library. The following links contain information on all three strategies.

That is from the OpenGL site. https://www.opengl.org/ under https://www.opengl.org/archives/resources/faq/technical/miscellaneous.htm

There is lots of tutorials on this.

 

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites
10 minutes ago, Vilem Otte said:

Hello,

before going forward - and as you're going to create a tool, I'd recommend you to decide:

  • What is your target architecture?

    Is the packing tool going to be used by standard PCs (x64 + AVX or SSE?)? Is it going to be GPU-only (Compute shaders or CUDA?)? Targeting mobile market?
     
  • What performance you expect?

    Do you require atlas creation per-frame? Or is it going to be pre-processed?
     
  • Additional features?

    Generating mip-maps? Do you want to store them in the atlas? Have whole atlas mip-mapped? Different algorithm should be used for stored normal maps, alpha maps, diffuse maps!
     
  • Licensing

    Every 3rd party tool you bring in introduces some problems - apart from often adding some unpleasant syntax (which can be encapsulated nice), it is licensing that hurts the most.

 

Why am I asking these questions? Simply because the actual purpose of the tool should be the one deciding the required performance and feature set.

If you require building of texture atlas within single frame, then you are most likely not going to do any S3TC compression directly (there might be a way though - in case everything you want to store is already S3TC compressed). There is also possibility of doing S3TC compression on GPU, which might be fast enough for this purpose.

So... if you require top-performance, you will have to write quite a lot of code yourself and optimize a lot. If you require just pre-processing, using SOIL, DevIL or even OpenCV might be good. Although be sure to read their licenses! And note, that reading or writing images with these will most likely take at least hundreds of ms or even seconds (which caused quite a lot of trouble for me).

As for compression algorithms - I believe https://github.com/castano/nvidia-texture-tools/wiki contains algorithms for S3TC compression. Which could be a good start. Note AMD has also this https://github.com/GPUOpen-Tools/Compressonator - which can be called as a library to compress data block with S3TC or other block compression. You could just call it from your application, therefore saving quite a lot of time either:

  • Copy-pasting S3TC/ETC/... compression and decompression algorithms
  • Writing your own S3TC/ETC/...

If you decide for one of the above (copy-pasting or writing), I heavily suggest at least looking at how those algorithms work (you will most likely need it also for Compressonator, as if I'm not mistaken you need to compress per-block through the library, not as a whole image).

Thank you so much for the reply.

Target architecture would be PC x64, it is going to be pre-processed, for additional features only need to store alpha channel, no other map. 

SOIL and Devil looks promising.Thanks.

2 minutes ago, Scouting Ninja said:

Not by default but there is many examples on how to make a exporter.

I want to point out that learning how to save a image is the first step into making a custom atlas tool. If you miss this part it would be like learning the run before you crawl.

That is from the OpenGL site. https://www.opengl.org/ under https://www.opengl.org/archives/resources/faq/technical/miscellaneous.htm

There is lots of tutorials on this.

 

Will sure do.Thanks a bunch

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
  • Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By lucky6969b
      like this?

      const D3DXMATRIX robertx = D3DXMATRIX(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
    • By bojanzarnoski@gmx.de
      Hello,
      I want to get into coding again by programming a 2D platformer to get started, but i don't know if i should use Java or C# with the unity engine.
      I am pretty fit with Java, but with c# i have to start from scratch. What do you recommend and why?
    • By 3dmodelerguy
      So I have this code to create a textbox ui element with SDL2 and for the most part it works:
      #include <iostream> #include "TextboxUi.hpp" #include "../Engine/Text.hpp"; #include "../Utility/SdlUtility.hpp"; #include "../Engine/Game.hpp"; TextboxUi::TextboxUi(int x, int y, int width, int height, SDL_Color backgroundColor, SDL_Color textColor) { _background = {x, y, width, height}; _backgroundColor = backgroundColor; _textColor = textColor; } void TextboxUi::setValue(std::string value) { _value = value; } void TextboxUi::handleInput(SDL_Event &event) { switch (event.type) { case SDL_TEXTINPUT: { if (_isActive) { _value += event.text.text; _cursorPosition += 1; } break; } case SDL_TEXTEDITING: { break; } case SDL_KEYUP: { switch (event.key.keysym.sym) { case SDLK_BACKSPACE: if (_value.size() == 0) { break; } _cursorPosition -= 1; _value.erase(_cursorPosition, 1); break; case SDLK_s: { if (!_isActive) { _isActive = true; } break; } case SDLK_LEFT: { if (_cursorPosition == 0) { break; } _cursorPosition -= 1; break; } case SDLK_RIGHT: { if (_cursorPosition == _value.size()) { break; } _cursorPosition += 1; break; } case SDLK_ESCAPE: _isActive = false; _value = ""; break; default: break; } break; } default: break; } } void TextboxUi::enable() { _isActive = true; } void TextboxUi::disable() { _isActive = false; } void TextboxUi::draw(SDL_Renderer* renderer) { SdlUtility::setRenderDrawColor(Game::renderer, _backgroundColor); SDL_RenderFillRect(Game::renderer, &_background); // if there is no text Text would fail to create the surface and texture (not quite sure why) if (_value.size() == 0) { return; } Text text = Text("Assets/Fonts/Vera.ttf", 12, _value, _textColor); text.display(_background.x + 5, _background.y + 2); // @todo implement visual for text cursor } The one last thing I want to do before I call this textbox done for the time being is try to figure out how to simulate a cursor. At this point just getting a solid cursor would be final (though ultimately I would like to have it blinking. I have the cursor position so I know between which characters the cursor should be however I am not sure how to calculate that.
      Is there a way to calculate the width of a given string without actually rendering said sting to the screen with SDL2 / SDL2_ttf?
    • By Bobby Horn
      Hi everyone I'm a new game designer I'm currently getting my online bachelors degree from full sail University. I'm looking for a development team to make a JRPG. I'm doing this as a side project. I'm just started to learn how to use unity and I pick up on things quickly. I've been obbsed with making a JRPG game since I played final fantasy 7, and 8. I have the plot idea but I'm stuck on making the rest of the storyline. I know how many characters I'd like to have as part of the main playable ones and along with the ones that aid sometimes. I also decided on the villain for the game. There are some other details I thought about for the characters along with the turned based battle system and how I would like to do the magic users. I'm highly motivated to get this developed before I graduate. If you are interested to know more please contact me
    • By pcmaster
      Hello!
      Previous year in my job we implemented a HDR output (as in HDR10 / BT.2020 / ST.2084 PQ back-buffers) on one of our games on the consoles, which do support HDR10 over HDMI. The HDR compatible hardware (monitors, televisions) has already been around for a year, with varying quality.
      I wonder if there's already HDR-HW output exposed in the PC drivers? Windows 10? Vulkan? DX 11? DX 12? Which vendors?
      For those unfamiliar, I'm talking about outputting HDR signal to HDR hardware (using r10g10b10a2_unorm + PQ backbuffers, or better).
      Thanks, .P
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!