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
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!