Write .dds-file with custom mipmaps - possible?
Write .dds-file with custom mipmaps - possible?
Given an image list containing quadratic images with side lengths in powers of 2, would it be possible to write these out to a dds file as mipmaps?
For example:
image list contains 6 images:
image 1: 1024px x 1024px
image 2: 512px x 512px
image 3: 256px x 256px
image 4: 128px x 128px
image 5: 64px x 64px
image 6: 32px x 32px
I would like it to be exported as a .dds file with image 1 as the main image, and all the following images as mipmaps.
My use case attempts to achieve certain image effects when applying this dds file to a shader. In doing this, the conventional application of mipmaps as automatically generated, downscaled versions of the main image (Image 1 in my example) is not sufficient. From reading the docs, I gather this is what ImageMagick currently does.
In short, I need to be able to manually specify the contents of each mipmap.
Is this currently possible? If not, would it be possible to implement?
I'm currently using version 6.9.5-4 of ImageMagick.
Thank you for your time.
- Hans
For example:
image list contains 6 images:
image 1: 1024px x 1024px
image 2: 512px x 512px
image 3: 256px x 256px
image 4: 128px x 128px
image 5: 64px x 64px
image 6: 32px x 32px
I would like it to be exported as a .dds file with image 1 as the main image, and all the following images as mipmaps.
My use case attempts to achieve certain image effects when applying this dds file to a shader. In doing this, the conventional application of mipmaps as automatically generated, downscaled versions of the main image (Image 1 in my example) is not sufficient. From reading the docs, I gather this is what ImageMagick currently does.
In short, I need to be able to manually specify the contents of each mipmap.
Is this currently possible? If not, would it be possible to implement?
I'm currently using version 6.9.5-4 of ImageMagick.
Thank you for your time.
- Hans
Last edited by HansCz on 2016-08-03T21:24:12-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Write .dds-file with custom mipmaps - possible?
IM currently does not have any built in support for mipmaps, as far as I know. The closest is to write a pyramid tiff.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Write .dds-file with custom mipmaps - possible?
Does the DDS format support a mip-map structure? If so can you point the developers to that format description.
Re: Write .dds-file with custom mipmaps - possible?
Good call.
The closest to a format description I have been able to find so far, is this:
Reference for DDS
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Programming Guide for DDS
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
and yes, it does support a mipmap structure. see:
DDS File Layout
https://msdn.microsoft.com/en-us/librar ... le_Layout1
The closest to a format description I have been able to find so far, is this:
Reference for DDS
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Programming Guide for DDS
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
and yes, it does support a mipmap structure. see:
DDS File Layout
https://msdn.microsoft.com/en-us/librar ... le_Layout1
...A pointer to an array of bytes that contains the main surface data.
BYTE bdata[]
A pointer to an array of bytes that contains the remaining surfaces such as; mipmap levels, faces in a cube map, depths in a volume texture. Follow these links for more information about the DDS file layout for a: texture, a cube map, or a volume texture.
BYTE bdata2[]
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Write .dds-file with custom mipmaps - possible?
According to that document, DDS does support mipmap.
The IM page on formats at http://www.imagemagick.org/script/formats.php does imply that mipmaps are supported. See the -define for using that. Sorry I know little about DDS format. Perhaps one of the Windows users can comment further or one of the IM developers regarding its use.
The IM page on formats at http://www.imagemagick.org/script/formats.php does imply that mipmaps are supported. See the -define for using that. Sorry I know little about DDS format. Perhaps one of the Windows users can comment further or one of the IM developers regarding its use.
Re: Write .dds-file with custom mipmaps - possible?
Thanks, Fred. I'll look into it.
(shuffles off to read about -define and what it can do for DDS files...)
maybe the current DDS writer can be modified to assemble mipmaps from an imagelist, rather than autogenerating them from a base image. Hmmm....
In the meantime, I found this:
DirectXTex texture processing library
https://github.com/Microsoft/DirectXTex
It looks like it has code for generating a .DDS file with mipmaps, but again, auto-generated.
Maybe it could serve as a base for further investigation?
(shuffles off to read about -define and what it can do for DDS files...)
maybe the current DDS writer can be modified to assemble mipmaps from an imagelist, rather than autogenerating them from a base image. Hmmm....
In the meantime, I found this:
DirectXTex texture processing library
https://github.com/Microsoft/DirectXTex
It looks like it has code for generating a .DDS file with mipmaps, but again, auto-generated.
Maybe it could serve as a base for further investigation?
Last edited by HansCz on 2016-08-03T21:26:01-07:00, edited 1 time in total.
Re: Write .dds-file with custom mipmaps - possible?
I would like to talk to the person(s) who wrote the writer to determine if this is even feasible. He/she/they must be out there somewhere...I'll have a look around.
Re: Write .dds-file with custom mipmaps - possible?
searchcode.com to the rescue. It seems the current author is a certain Dirk Lemstra,
https://searchcode.com/codesearch/view/115223297/
It seems he is on github:
https://github.com/dlemstra
...and he is the latest committer to DDS.c as of today:
https://github.com/ImageMagick/ImageMag ... ders/dds.c
He has a profile on this very forum. Yay!:
memberlist.php?mode=viewprofile&u=24371
I'll compose a PM and see if he will answer.
https://searchcode.com/codesearch/view/115223297/
Now to find himCode: Select all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % DDDD DDDD SSSSS % % D D D D SS % % D D D D SSS % % D D D D SS % % DDDD DDDD SSSSS % % % % % % Read/Write Microsoft Direct Draw Surface Image Format % % % % Software Design % % Bianca van Schaik % % March 2008 % % Dirk Lemstra % % September 2013 %
It seems he is on github:
https://github.com/dlemstra
...and he is the latest committer to DDS.c as of today:
https://github.com/ImageMagick/ImageMag ... ders/dds.c
He has a profile on this very forum. Yay!:
memberlist.php?mode=viewprofile&u=24371
I'll compose a PM and see if he will answer.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Write .dds-file with custom mipmaps - possible?
You can PM him on this forum as dlemstra. He answers on both forums.
But if DDS does not support custom mipmaps, then I would be surprised if IM will support that. Be he and magick provide the definitive answer.
But if DDS does not support custom mipmaps, then I would be surprised if IM will support that. Be he and magick provide the definitive answer.
Re: Write .dds-file with custom mipmaps - possible?
Thanks A PM has been sent. I'll post any responses here.
Re: Write .dds-file with custom mipmaps - possible?
The dds coder currently auto generates the DDS mipmaps. I am open to adding this feature but I wonder how we should make this feature available. Maybe this:
Code: Select all
convert image1.png -define dds:mipmap-files="image2.png, image3.png" image1.dds
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Write .dds-file with custom mipmaps - possible?
Wouldn't it be more logical to take all the images in the current list, with a simpler define? Like this:
Code: Select all
convert image1.png image2.png image3.png -define dds:fromlist image1.dds
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Write .dds-file with custom mipmaps - possible?
Just for clarification are you saying you want only one output image whose different resolution maps come from the different input images? Or are you asking for multiple output images with mipmaps for each?HansCz wrote:I would like it to be exported as a .dds file with image 1 as the main image, and all the following images as mipmaps.
Re: Write .dds-file with custom mipmaps - possible?
I also though about using this but I had the idea that this would be bad if you wanted to write multiple files in the same command. But now thinking about it that shouldn't be an issue. I'll talk with magick and see if he also thinks this is a good idea and then add it.snibgo wrote:Wouldn't it be more logical to take all the images in the current list, with a simpler define? Like this:Code: Select all
convert image1.png image2.png image3.png -define dds:fromlist image1.dds
Re: Write .dds-file with custom mipmaps - possible?
This is great news! Glad to hear you are willing to consider it. Eagerly awaiting any further developments!
Later there might also be texture arrays and 3d textures to consider. This would most likely demand some careful consideration of how the command should be formatted to avoid ambiguity as much as possible... But first things first I'm just happy you're willing to consider simple custom mipmaps on one texture for now
I know quite a few shader programmers in the Unity game engine community are going to love this.
Again. Thank you for considering this.
One output image with custom mipmaps was my initial thought. But anything that can speed up batching would be a nice addition.fmw42 wrote:Just for clarification are you saying you want only one output image whose different resolution maps come from the different input images? Or are you asking for multiple output images with mipmaps for each?
Later there might also be texture arrays and 3d textures to consider. This would most likely demand some careful consideration of how the command should be formatted to avoid ambiguity as much as possible... But first things first I'm just happy you're willing to consider simple custom mipmaps on one texture for now
I know quite a few shader programmers in the Unity game engine community are going to love this.
Again. Thank you for considering this.