Quantcast
Channel: DirectXTex texture processing library
Viewing all 1174 articles
Browse latest View live

Updated Wiki: Compress

$
0
0
Compresses an image or set of images to a block-compressed (BC) format.

HRESULT Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format,
    _In_ DWORD compress, _In_ float alphaRef,
    _Out_ ScratchImage& cImage );

HRESULT Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef,
    _Out_ ScratchImage& cImages );

HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image& srcImage,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight,
    _Out_ ScratchImage& image );

HRESULT Compress( _In_ ID3D11Device* pDevice,
    _In_ const Image* srcImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight,
    _Out_ ScratchImage& cImages );

Parameters

device: The DirectCompute based versions of Compress require a Direct3D 11 device with Feature Level 10.0 or greater that supports DirectCompute.

format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)

Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB

compress: Compress control flags

alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)

alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.

Related flags

TEX_COMPRESS_DEFAULT Default flags.

Dithering

  • TEX_COMPRESS_RGB_DITHER Enables dithering RGB colors for BC1-3 compression
  • TEX_COMPRESS_A_DITHER Enables dithering alpha channel for BC1-3 compression
  • TEX_COMPRESS_DITHER Same as TEX_COMPRESS_RGB_DITHER and TEX_COMPRESS_A_DITHER

Weighting

  • TEX_COMPRESS_UNIFORM By default, BC1-3 uses a perceptual weighting. By using this flag, the perceptual weighting is disabled which can be useful when using the RGB channels for other data.

Threading

  • TEX_COMPRESS_PARALLEL This opts-in to multi-threaded compression if enabled.

Color space

  • TEX_COMPRESS_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_COMPRESS_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_COMPRESS_SRGB This is the same as setting both TEX_COMPRESS_SRGB_IN and TEX_COMPRESS_SRGB_OUT

The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB

BC7

  • TEX_COMPRESS_BC7_USE_3SUBSETS Indicates that BC7 compression should use the 3 subset modes (mode 0 and 2). Otherwise it skips these to improve compression performance.

Example

ScratchImage srcImage;

...

ScratchImage bcImage;
hr = Compress( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(), DXGI_FORMAT_BC3_UNORM, TEX_COMPRESS_DEFAULT, 0.5f, bcImage );
if ( FAILED(hr) )
    ...

Remarks

By default, the BC1 - BC3 color encoding algorithms will use a perceptual weighting of the Red and Blue channels which usually gives better visual results for standard color textures. For textures that do not contain color data, you will likely want to use TEX_COMPRESS_UNIFORM to disable the perceptual weighting.

When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.

The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.

This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.

Release Notes

The software based encoder for BC6H and BC7 is computationally expensive and can be quite slow. The DirectCompute based encoder which is much faster has been integrated into the DirectXTex library, but the standalone version is also available http://code.msdn.microsoft.com/BC6HBC7-DirectCompute-35e8884a

Threading

The CPU-based compressor will use all cores on a system if given TEX_COMPRESS_PARALLEL for the BC6H / BC7 codec.

The DirectCompute GPU-based compressor makes use of the device's immediate context.

Related Links

http://msdn.microsoft.com/en-us/library/bb204843.aspx
http://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt

Updated Wiki: Compress

$
0
0
Compresses an image or set of images to a block-compressed (BC) format.

HRESULT Compress( _In_ const Image& srcImage, _In_ DXGI_FORMAT format,
    _In_ DWORD compress, _In_ float alphaRef,
    _Out_ ScratchImage& cImage );

HRESULT Compress( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaRef,
    _Out_ ScratchImage& cImages );

HRESULT Compress( _In_ ID3D11Device* pDevice, _In_ const Image& srcImage,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight,
    _Out_ ScratchImage& image );

HRESULT Compress( _In_ ID3D11Device* pDevice,
    _In_ const Image* srcImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DXGI_FORMAT format, _In_ DWORD compress, _In_ float alphaWeight,
    _Out_ ScratchImage& cImages );

Parameters

device: The DirectCompute based versions of Compress require a Direct3D 11 device with Feature Level 10.0 or greater that supports DirectCompute.

format: Format to compress to. Must be a BC compressed format (i.e. DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM_SRGB - DXGI_FORMAT_BC7_UNORM, DXGI_FORMAT_BC7_UNORM_SRGB)

Note that the DirectCompute based versions of Compress only support DXGI_FORMAT_BC6H_UF16, DXGI_FORMAT_BC6H_SF16, DXGI_FORMAT_BC7_UNORM, and DXGI_FORMAT_BC7_UNORM_SRGB

compress: Compress control flags

alphaRef: Threshold reference value when compressing an alpha channel for BC1 formats which support 1-bit transparency. (0 to 1 range)

alphaWeight: Used to weight the error metric's alpha computation for the BC7 GPU compressor. Use 1.0 for default, or a larger number to improve alpha accuracy potentially at the expense of the color channels.

Related flags

TEX_COMPRESS_DEFAULT Default flags.

Dithering

  • TEX_COMPRESS_RGB_DITHER Enables dithering RGB colors for BC1-3 compression
  • TEX_COMPRESS_A_DITHER Enables dithering alpha channel for BC1-3 compression
  • TEX_COMPRESS_DITHER Same as TEX_COMPRESS_RGB_DITHER and TEX_COMPRESS_A_DITHER

Weighting

  • TEX_COMPRESS_UNIFORM By default, BC1-3 uses a perceptual weighting. By using this flag, the perceptual weighting is disabled which can be useful when using the RGB channels for other data.

Threading

  • TEX_COMPRESS_PARALLEL This opts-in to multi-threaded compression if enabled.

Color space

  • TEX_COMPRESS_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_COMPRESS_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_COMPRESS_SRGB This is the same as setting both TEX_COMPRESS_SRGB_IN and TEX_COMPRESS_SRGB_OUT

The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.
http://en.wikipedia.org/wiki/SRGB

BC7

  • TEX_COMPRESS_BC7_USE_3SUBSETS Indicates that BC7 compression should use the 3 subset modes (mode 0 and 2). Otherwise it skips these to improve compression performance.

Example

ScratchImage srcImage;

...

ScratchImage bcImage;
hr = Compress( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(), DXGI_FORMAT_BC3_UNORM, TEX_COMPRESS_DEFAULT, 0.5f, bcImage );
if ( FAILED(hr) )
    ...

Remarks

By default, the BC1 - BC3 color encoding algorithms will use a perceptual weighting of the Red and Blue channels which usually gives better visual results for standard color textures. For textures that do not contain color data, you will likely want to use TEX_COMPRESS_UNIFORM to disable the perceptual weighting.

When compressing for BC4, only the RED channel in the original image is used. When compressing for BC5, only the RED and GREEN channels are used.

The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be compressed that are not actually valid on Direct3D 11.

This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.

Release Notes

The software based encoder for BC6H and BC7 is computationally expensive and can be quite slow. The DirectCompute based encoder which is much faster has been integrated into the DirectXTex library, but the standalone version is also available http://code.msdn.microsoft.com/BC6HBC7-DirectCompute-35e8884a

Threading

The CPU-based compressor will use all cores on a system if given TEX_COMPRESS_PARALLEL for the BC6H / BC7 CPU codec.

The DirectCompute GPU-based compressor makes use of the device's immediate context.

Related Links

http://msdn.microsoft.com/en-us/library/bb204843.aspx
http://msdn.microsoft.com/en-us/library/bb694531.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955.aspx
http://en.wikipedia.org/wiki/S3_Texture_Compression
http://en.wikipedia.org/wiki/3Dc
http://developer.download.nvidia.com/opengl/specs/GL_ARB_texture_compression_bptc.txt

Updated Wiki: Decompress

$
0
0
Decompresses a block-compressed (BC) image or set of BC images.

HRESULT Decompress( _In_ const Image& cImage, _In_ DXGI_FORMAT format,
    _Out_ ScratchImage& image );

HRESULT Decompress( _In_reads_(nimages) const Image* cImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DXGI_FORMAT format,
    _Out_ ScratchImage& images );

Parameters

cimage: Must be a BC compressed image or this function will fail.

format: Format to decompress to. If set to DXGI_FORMAT_UNKNOWN the routine picks a reasonable default based on the input BC format.

Example

ScratchImage bcImage;

...

ScratchImage destImage;
hr = Decompress( bcImage.GetImages(), bcImage.GetImageCount(), bcImage.GetMetadata(), DXGI_FORMAT_UNKNOWN, destImage );
if ( FAILED(hr) )
    ...

Remark

The DirectXTex library functions allow arbitrary sized images to handle non-power-of-2 mipmapped BC textures. Note that Direct3D will not allow a resource to be created using BC format with the top-level size set to something other than a multiple of 4 in width and height, even though it does allow the mipchain below it to not meet that requirement. In other words, the library allows some textures to be decompressed that are not actually valid on Direct3D 11.

Related Links

See Compress

Updated Wiki: PremultiplyAlpha

$
0
0
This converts an image assuming the original is not using premultiplied alpha into a premultiplied alpha version of the same image. The format and size are not changed.

Breaking Change notice: The 'flags' parameter was not present in the August 2013 and previous versions of DirectXTex.

HRESULT PremultiplyAlpha( _In_ const Image& srcImage, _In_ DWORD flags,
    _Out_ ScratchImage& image );

HRESULT PremultiplyAlpha( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages,
    _In_ const TexMetadata& metadata, _In_ DWORD flags,
    _Out_ ScratchImage& result );

Parameters

flags: Combination of options to apply
  • PMALPHA_IGNORE_SRGB Ignore any sRGB colorspace conversions

This controls color space transformation for conversions.
  • TEX_PMALPHA_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_PMALPHA_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_PMALPHA_SRGB This is the same as setting both TEX_PMALPHA_SRGB_IN and TEX_PMALPHA_SRGB_OUT

Example

ScratchImage srcImage;

...

ScratchImage destImage;
hr = PremultiplyAlpha( srcImage.GetImages(), srcImage.GetImageCount(), srcImage.GetMetadata(), TEX_PMALPHA_DEFAULT, destImage );
if ( FAILED(hr) )
    ...

Remarks

This function does not operate directly on block compressed images. See Decompress and Compress.

This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.

This is most useful for working with rendering that relies on premultiplied alpha blending (see DirectXTK).

Related Links

http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx
http://home.comcast.net/~tom_forsyth/blog.wiki.html#%5B%5BPremultiplied%20alpha%5D%5D
http://ssp.impulsetrain.com/2011-08-10_Gamma_Correction_vs__Premultiplied_Pixels.html

Updated Wiki: Texconv

$
0
0
This DirectXTex sample is an implementation of the texconv command-line texture utility from the DirectX SDK utilizing DirectXTex rather than D3DX. This tool loads an image and prepares it for runtime use by resizing, format conversion, mip-map generation, block-compression, and writes the result in a file format suited for runtime use.

To create cubemaps, volume maps, or texture arrays from individual files, use Texassemble

Syntax

Texconv.exe uses the following command syntax:

texconv [-w number] [-h number] [-m number] [-f format] [-if filter] [-srgb | -srgbi | -srgbo] [-px  string] [-sx string] [-o directory] [-ft file-type] [-hflip] [-vflip] [-sepalpha] [-wrap | -mirror] [-pmalpha] [-fl feature-level] [-pow2] [-tu | -tf] [-dword] [-xlum] [-dx10]  [-nologo] [-singleproc] [-nogpu] [-aw number] [-nmap flags] [-nmapamp number] [-bcuniform] [-bcmax] [-bcdither] [-timing]
<file-name(s)>
The file-name parameter indicates the file(s) to convert.

The optional command-line switches are described in the following table.

Optional Switches Description

  • -wnumber Width of the output texture in pixels.
  • -hnumber Height of the output texture in pixels.
  • -mnumber Number of mipmap levels to generate in the output texture. This setting only applies to DDS output.
  • -fformat Output format. Specify the DXGI format without the DXGI_FORMAT_ prefix (i.e. "-f BC1_UNORM").
  • -iffilter Image filter. Use one of the following: POINT, LINEAR, CUBIC, FANT, BOX, TRIANGLE, POINT_DITHER, LINEAR_DITHER, CUBIC_DITHER, FANT_DITHER, BOX_DITHER, TRIANGLE_DITHER, POINT_DITHER_DIFFUSION, LINEAR_DITHER_DIFFUSION, CUBIC_DITHER_DIFFUSION, FANT_DITHER_DIFFUSION, BOX_DITHER_DIFFUSION, or TRIANGLE_DITHER_DIFFUSION. Filters with DITHER in their name indicate that the 4x4 ordered dither algorithm, while "DITHER_DIFFUSION" is error diffusion dithering.
  • -srgb, -srgbi, or -srgbo Use sRGB if both the input and output data are in the sRGB color format (ie. gamma ~2.2). Use sRGBi if only the input is in sRGB; use sRGBo if only the output is in sRGB.
  • -pxstring Text string to attach to the front of the resulting texture's name.
  • -sxstring Text string to attach to the end of the resulting texture's name.
  • -odirectory Output directory.
  • -ftfile-type A file type for the output texture. Use one of the following: bmp, dds, jpg, png, or tiff. The default value is dds.
  • -hflip Perform horizonal flip of image
  • -vflip Perform horizonal flip of image
  • -sepalpha Separates alpha channel for resize/mipmap generation. This implies an alpha mode setting of DDS_ALPHA_MODE_CUSTOM as this is typically only used if the alpha channel doesn't contain transparency information.
  • -wrap, -mirror Sets the texture addressing mode for filtering to wrap or mirror, otherwise defaults to clamp.
  • -pmalpha Converts the final texture data to use premultiplied alpha. This sets an alpha mode of DDS_ALPHA_MODE_PREMULTIPLIED unless the entire alpha channel is fully opaque.
  • -pow2 Fits each texture to a power-of-2 for width & height, minimizing changes to the aspect ratio.
  • -flfeature-level Sets the target feature level which determines the maximum supported texture size. Defaults to "11.0" which is 16834, the limit for 11.0 and 11.1 Feature Level hardware.
  • -tu DDS files with TYPELESS formats are treated as UNORM
  • -tf DDS files with TYPELESS formats are treated as FLOAT
  • -dword For DDS files use a DWORD alignment instead of BYTE alignment (used for some legacy files)
  • -xlum DDS files with L8, A8L8, or L16 formats are expanded to 8:8:8:8 or 16:16:16:16
  • -dx10 Forces DDS file output to always use the "DX10" header extension, and allows the writing of alpha mode metadata information. The resulting file may not be compatible with the legacy D3DX10 or D3DX11 libraries.
  • -nologo Suppress copyright message.
  • -singleproc If the DirectXTex library and the texconv utility are built with OpenMP enabled, by default the tool will use multi-threading for CPU-based compression of BC6H and BC7 formats to spread the compression work across multiple cores. This flag disables this behavior forcing it to remain on a single core.
  • -nogpu When compressing BC6H / BC7 content, texconv will use DirectCompute on the GPU if available. Use of this flag forces texconv to always use the software codec instead.
  • -awnumber Provides an alpha weighting to use with the error metric for the BC7 GPU compressor. Defaults to 1.0.
  • -nmapflags Indicates conversion from a height-map to a normal-map. The flags is a combination of one or more of the following, and must have one of r, g, b, a, or l:
    • r Use the red channel of the input as the height
    • g Use the green channel of the input as the height
    • b Use the blue channel of the input as the height
    • a Use the alpha channel of the input as the height
    • l Use the luminance computed from red, green, and blue channels of the input as the height
    • m Use mirroring in U & V. Defaults to wrap when doing the central difference computation.
    • u Use mirroring in U. Defaults to wrap when doing the central difference computation.
    • v Use mirroring in V. Defaults to wrap when doing the central difference computation.
    • i Invert sign of the computed normal
    • o Compute a rough occlusion term and encode it into the alpha channel of the output.
  • -nmapampnumber Indicates an amplitude for the normal map, which defaults to 1.
  • -bcuniform Uses uniform weighting rather than perceptual (BC1-BC3)
  • -bcmax Uses maximum compression (BC7: enables mode 0 & 2 usage)
  • -bcdither Uses dithering (BC1-BC3)
  • -timing Displays compression timing information

Examples

Open a Command Prompt, and change to the directory containing Texconv.exe (i.e. ...\DirectXTex\Texconv\Release)
http://windows.microsoft.com/en-us/windows/command-prompt-faq

Enter the following command-line after changing to the appropriate directory:
texconv -pow2 -f BC1_UNORM cat.jpg 

This loads a JPEG image 'cat.jpg', resizes the image to a power of 2 in each dimension (if the original was 512 x 683 it is resized to 256 x 512), mipmaps are generated, the file is converted to BC1_UNORM (aka DXT1) block compression, and written out as 'cat.dds'.

texconv -nmap lo -nmapamp 2 -f R8G8B8A8_UNORM heightmap.png

This loads the PNG image 'heightmap.png', converts it to a normal-map using luminance and an amplitude of 2, and writes the data out as a 'heightmap.dds' with mipmaps and an occlusion term in the alpha channel using the R8G8B8A8_UNORM format.

Updated Release: June 2015 (Jun 18, 2015)

$
0
0
June 18, 2015
  • New BC_FLAGS_USE_3SUBSETS option for BC7 compressors; now defaults to skipping 3 subset blocks
  • Fixed bug with MakeTypeless and A8_UNORM
  • Fixed file length validation problem in LoadDDSFromFile

NEWS: This project is now hosted on GitHubhttps://github.com/Microsoft/DirectXTex. This site is being maintained for now, but please move to using GitHub.

Released: June 2015 (Jun 18, 2015)

$
0
0
June 18, 2015
  • New BC_FLAGS_USE_3SUBSETS option for BC7 compressors; now defaults to skipping 3 subset blocks
  • Fixed bug with MakeTypeless and A8_UNORM
  • Fixed file length validation problem in LoadDDSFromFile

NEWS: This project is now hosted on GitHub https://github.com/Microsoft/DirectXTex. This site is being maintained for now, but please move to using GitHub.

Updated Release: June 2015 (Jun 18, 2015)

$
0
0
June 18, 2015
  • New BC_FLAGS_USE_3SUBSETS option for BC7 compressors; now defaults to skipping 3 subset blocks
  • Fixed bug with MakeTypeless and A8_UNORM
  • Fixed file length validation problem in LoadDDSFromFile

NEWS: This project is now hosted on GitHubhttps://github.com/Microsoft/DirectXTex. This site is being maintained for now, but please move to using GitHub.

Source code checked in, #4feff1578cbda33daaf5d21e6b3bfceef1356492

$
0
0
Use parallel compression for BC1-BC5

Source code checked in, #847ab8940a5067e4f36867ffaa1b154fbd7fadb3

$
0
0
Fixed round problem with 32-bit RGBA/BGRA formats

Source code checked in, #c12188a333ff49b203a563e33374344084aceed6

Source code checked in, #d7e19a28d351fa895995bd9bf2109d91978d7bef

$
0
0
Merge branch 'master' of https://github.com/Microsoft/DirectXTex

Source code checked in, #8ec79df15dc9014534be828965f096aa814da96b

$
0
0
Updated for Windows 10 SDK 10166

Source code checked in, #445a3d2da46cec360cec4e11ef0102c9328dc8f7

Updated Wiki: Home

$
0
0
NEWS: This project is now hosted on GitHubhttps://github.com/Microsoft/DirectXTex. This site is being maintained for now, but please move to using GitHub.

http://go.microsoft.com/fwlink/?LinkId=248926

Project Description
DirectXTex, a shared source library for reading and writing DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes a simple .TGA reader and writer since this image file format is commonly used for texture content processing pipelines, but is not currently supported by a built-in WIC codec.

Supported platforms:
  • universal Windows apps for Windows 10
  • Windows Store apps for Windows 8.1 / RT 8.1
  • Windows Phone 8.1
  • Windows desktop
  • Windows 7
  • Windows Vista
  • Windows Server equivalents of the above
  • Xbox One
Xbox One XDK developers: See the xtexconv sample which also includes some auxiliary platform-specific functionality for XDK development on the Microsoft Game Developer Network site https://developer.xboxlive.com/en-us/platform/development/education/Pages/Samples.aspx

Contributions
The DirectXTex contributors list will remain closed to ensure high-quality and focused feature set, but we are very interested in any bug-fixes, optimizations, additional features, or other community feedback on this library. Please use the Issue Tracker and feel free to attach code to the issue as needed. Note that any code contributed or released for the DirectXTex project is subject to the MS-PL.

windows8logo.jpg
windowsphone8logo.jpg
xboxonelogo.png

Updated Wiki: DirectXTex

$
0
0
The DirectXTex library includes a full-featured DDS reader and writer including legacy format conversions, a TGA reader and writer, a WIC-based bitmap reader and writer (BMP, JPEG, PNG, TIFF, and HD Photo), and various texture processing functions. This is intended primarily for tool usage.

The library assumes that the client code will have already called CoInitialize, CoInitializeEx, or Windows::Foundation::Initialize as needed by the application before calling any DirectXTex routines

Headers

The majority of the header files here are intended for internal implementation of the library only (BC.h, DDS.h, DirectXTexP.h, and scoped.h). Only DirectXTex.h (and DirectXTex.inl) is meant as a 'public' header for the library.

Namespace

All the functions in the library are in the DirectX C++ namespace.

Functions

DDS I/O Functions

TGA I/O Functions

WIC I/O Functions

Texture Functions

Direct3D 11 Helper Functions

Utility Functions

Structures

TexMetadata contains metadata information about the texture resource and organization such as width, height, depth, format, dimension, etc.
  • TEX_DIMENSION_TEXTURE1D, TEX_DIMENSION_TEXTURE2D, and TEX_DIMENSION_TEXTURE3D are alises for D3D10_RESOURCE_DIMEMSION and D3D11_RESOURCE_DIMENSION.
  • TEX_MISC_TEXTURECUBE is an alias for the same D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG.
  • TEX_MISC2_ALPHA_MODE_MASK is a mask for miscFlags2 to obtain the TEX_ALPHA_MODE.
Image contains information about the surface including width, height, format, rowPitch, slicePitch, and a pointer to pixel data. Note that for 1D and 2D images, slicePitch should be set to the full size of the image.

ScratchImage is a helper class that manages memory for functions that return a Image or set of Images.

Blob is a helper class that manages for functions that return a binary blob of data.

Rect contains a simple pixel-based rectangle used by the CopyRectangle function.

Adding to a VS solution

In your application's solution, right-click on the Solution and use "Add \ Existing Project..." to add the appropriate .vcxproj file to your solution.
  • DirectXTex_Desktop_2015 is for Windows desktop applications building with VS 2015.
  • DirectXTex_Desktop_2013 is for Windows desktop applications building with VS 2013 Express for Desktop, VS 2013 Community, VS 2013 Professional or higher.
  • DirectXTex_Desktop_2012 is for Windows desktop applications building with VS 2012 Express for Desktop, VS 2012 Professional or higher
  • DirectXTex_Windows10 is for universal Windows apps building with VS 2015 targeting Windows 10
  • DirectXTex_Windows81 is for Windows Store apps building with VS 2013 targeting Windows 8.1
  • DirectXTex_Windows8 is for Windows Store apps building with VS 2012 targeting Windows 8
  • DirectXTex_WindowsPhone81 is for Windows phone 8.1 apps building with VS 2013 Update 2 or later.
  • DirectXTex_XboxOneXDK is for Xbox One exclusive apps building with VS 2012 using the Xbox One XDK
  • DirectXTex_XboxOneADK is for Xbox One hub apps building with VS 2012 using the Xbox One ADK
In your application's project, right-click on the Project and use "References...", then "Add New Reference...", and then check the DirectXTex project name and click OK. For a Windows Store app, Windows phone, or Xbox One solution, you need to set Reference Assembly Output to false since DirectXTex is a static C++ library and not a WinRT component.

In your application's project settings, on the "C++ / General" page set Configuration to "All Configurations", set Platform to "All Platforms", and then add the relative path to DirectXTex;--assuming you have the DirectXTex folder in the same directory as your sln file, it should be $(SolutionDir$)\DirectXTex;--to the Additional Include Directories properties. Click Apply.

http://blogs.msdn.com/b/vcblog/archive/2010/05/03/flexible-project-to-project-references.aspx

Note: DirectXTex is not supported on Windows Phone 8.0, because WIC is not available on that platform. The .DDS files it generates are suitable for use on Windows Phone 8.x assuming the pixel format is supported by the device (currently Feature Level 9.3).

Release Notes

  • The alpha mode specification for DDS files was updated between the March 2013 and April 2013 releases. Any DDS files created using the DDS_FLAGS_FORCE_DX10_EXT_MISC2 flag or the texconv -dx10 switch using the March 2013 release should be refreshed.
  • Due to the underlying Windows BMP WIC codec, alpha channels are not supported for 16bpp or 32bpp BMP pixel format files. The Windows 8 version of the Windows BMP WIC codec does support 32bpp pixel formats with alpha when using the BITMAPV5HEADER file header.
  • While DXGI 1.0 and DXGI 1.1 include 5:6:5 (DXGI_FORMAT_B5G6R5_UNORM) and 5:5:5:1 (DXGI_FORMAT_B5G5R5A1_UNORM) pixel format enumerations, the DirectX 10.x and 11.0 Runtimes do not support these formats for use with Direct3D. The DirectX 11.1 runtime, DXGI 1.2, and the WDDM 1.2 driver model fully support 16bpp formats (5:6:5, 5:5:5:1, and 4:4:4:4).
  • Loading of 96bpp floating-point TIFF files results in a corrupted image prior to Windows 8. This fix is available on Windows 7 SP1 with KB 2670838 installed.

New Post: Retiring VS 2010 and VS 2012 support

$
0
0
VS 2010 and Windows Store 8.0 support is being retired for the July 29, 2015 release.

Source code checked in, #15535d72ac94e7a5e7946c9ff4c7174e7dc9e9a0

Updated Wiki: Version History

$
0
0
July 29, 2015
  • Fixed rounding problem with 32-bit RGBA/BGRA format conversions
  • texconv: use CPU parallel compression for BC1-BC5 (-singleproc disables)
  • Updated for VS 2015 and Windows 10 SDK RTM
  • Retired VS 2010 and Windows 8.0 Store projects

June 18, 2015
  • New BC_FLAGS_USE_3SUBSETS option for BC7 compressors; now defaults to skipping 3 subset blocks
  • Fixed bug with MakeTypeless and A8_UNORM
  • Fixed file length validation problem in LoadDDSFromFile

March 27, 2015
  • Added projects for Windows apps Technical Preview
  • Fixed bug with WIC-based mipmap generation for non-WIC supported formats
  • Fixed bug with WIC multiframe loader when resizing required
  • texconv: Added -nmap/-nmapamp for generating normal maps from height maps
  • texconv/texassemble: Updated to load multiframe WIC files (tiff, gif)
  • Minor code cleanup

November 24, 2014
  • Updates for Visual Studio 2015 Technical Preview
  • Minor code cleanup

September 22, 2014
  • Format conversion improvements and bug fixes (depth/stencil, alpha-only, float16, RGB -> 1 channel)
  • Fixed issue when BC decompressing non-standard compressed rowPitch images
  • Explicit calling-convention annotation for all 'public' functions
  • Code cleanup
  • Xbox One platform updates

July 15, 2014
  • texconv command-line tool fixes
  • Fixed problem with 'wide' images with CPU Compress
  • Updates to Xbox One platform support

April 3, 2014
  • Windows phone 8.1 platform support

February 24, 2014
  • Direct3D 11 video and Xbox One extended format support
  • New APIs: IsPlanar, IsPalettized, IsDepthStencil, ConvertToSinglePlane
  • Added 'alphaWeight' parameter to GPU Compress [breaking change]
  • texconv '-aw' switch to control the alpha weighting for the BC7 GPU compressor
  • Fixed bug with ordered dithering in non-WIC conversion codepaths
  • Fixed SaveToDDS* functions when using arbitrary row pitch values

January 24, 2014
  • Added sRGB flags for Compress (TEX_COMPRESS_SRGB*)
  • Added 'compress' flag parameter to GPU versions of Compress [breaking change]
  • Minor fix for potential rounding problem in GPU Compress
  • Code cleanup (removed DXGI_1_2_FORMATS control define; ScopedObject typedef removed)
  • Dropped VS 2010 support without the Windows 8.1 SDK (removed USE_XNAMATH control define)

December 24, 2013
  • texconv updated with -fl and -pow2 command-line switches
  • Fixed bug in Resize when doing custom filtering which occurred when exactly doubling the image size
  • Added move operators to ScratchImage and Blob classes
  • Xbox One platform support

October 21, 2013
  • Updated for Visual Studio 2013 and Windows 8.1 SDK RTM
  • PremultiplyAlpha updated with new 'flags' parameter and to use sRGB correct blending
  • Fixed colorspace conversion issue with DirectCompute compressor when compressing for BC7 SRGB

August 13, 2013
  • DirectCompute 4.0 BC6H/BC7 compressor integration
  • texconv utility uses DirectCompute compression by default for BC6H/BC7, -nogpu disables use of DirectCompute

August 1, 2013
  • Support for BC compression/decompression of non-power-of-2 mipmapped textures
  • Fixes for BC6H / BC7 codecs to better match published standard
  • Fix for BC4 / BC5 codecs when compressing RGB images
  • Minor fix for the BC1-3 codec
  • New optional flags for ComputeMSE to compare UNORM vs. SNORM images
  • New WIC loading flag added to control use of WIC metadata to return sRGB vs. non-sRGB formats
  • Code cleanup and /analyze fixes
  • Project file cleanup
  • Texconv utility uses parallel BC compression by default for BC6H/BC7, -singleproc disables multithreaded behavior

July 1, 2013
  • VS 2013 Preview projects added
  • SaveToWIC functions updated with new optional setCustomProps parameter

June 15, 2013
  • Custom filtering implementation for Resize & GenerateMipMaps(3D) - Point, Box, Linear, Cubic, and Triangle
    • TEX_FILTER_TRIANGLE finite low-pass triangle filter
    • TEX_FILTER_WRAP, TEX_FILTER_MIRROR texture semantics for custom filtering
    • TEX_FILTER_BOX alias for TEX_FILTER_FANT WIC
  • Ordered and error diffusion dithering for non-WIC conversion
  • sRGB gamma correct custom filtering and conversion
  • DDS_FLAGS_EXPAND_LUMINANCE - Reader conversion option for L8, L16, and A8L8 legacy DDS files
  • Added use of WIC metadata for sRGB pixel formats
  • Added BitsPerColor utility function
  • Fixed Convert threshold parameter usage
  • Non-power-of-2 volume map support, fixed bug with non-square volume maps
  • Texconv utility update with -xlum, -wrap, and -mirror options; reworked -if options for improved dithering
  • Texassemble utility for creating cubemaps, volume maps, and texture arrays
  • DDSTextureLoader and WICTextureLoader sync'd with DirectXTK versions

April 16, 2013
  • Updated alpha-mode metadata details in .DDS files
  • Added new control flags for Convert
  • Added new optional flags for ComputeMSE
  • Fixed conversion handling for sRGB formats
  • Fixed internal routines for handling R10G10B10_XR_BIAS_A2_UNORM, R9G9B9E5_SHAREDEXP, and FORMAT_R1_UNORM
  • Fixed WIC I/O for GUID_WICPixelFormat32bppRGBE pixel format files (HD Photo)
  • Fixed non-square image handling in GenerateMipMaps3D
  • Fixed some error handling in the DDS load code

March 22, 2013
  • Supports reading and writing alpha-mode (straight, premultiplied, etc.) metadata in .DDS files
  • Added build option to use WICCreateImagingFactory_Proxy instead of CoCreateInstance to obtain WIC factory

January 29, 2013
  • Added PremultiplyAlpha to DirectXTex; -pmalpha switch for texconv command-line tool
  • Fixed problem with forceSRGB implementation for Ex versions of CreateTexture, CreateShaderResourceView, DDSTextureLoader and WICTextureLoader

December 11, 2012
  • Ex versions of CreateTexture, CreateShaderResourceView, DDSTextureLoader and WICTextureLoader
  • Fixed BC2 and BC3 decompression issue for unusual color encoding case
  • Converted annotation to SAL2 for improved VS 2012 /analyze experience
  • Updated DirectXTex, DDSView, and Texconv with VS 2010 + Windows 8.0 SDK project using official 'property sheets'

November 15, 2012
  • Added support for WIC2 when available on Windows 8 and Windows 7 with KB 2670838
  • Added optional targetGUID parameter to SaveWIC* APIs to influence final container pixel format choice
  • Fixed bug in SaveDDS* which was generating invalid DDS files for 1D dimension textures
  • Improved robustness of CaptureTexture when resolving MSAA source textures
  • Sync'd DDSTextureLoader, ScreenGrab, and WICTextureLoader standalone versions with latest DirectXTK release

September 28, 2012
  • Added ScreenGrab module for creating runtime screenshots
  • Renamed project files for better naming consistency
  • New Typeless utilities for DirectXTex
  • Some minor code cleanup for DirectXTex's WIC writer function
  • Bug fixes and new -tu/-tf options for texconv

June 22, 2012
  • Moved to using XNA Math 2.05 instead of XNA Math 2.04 for USE_XNAMATH builds
  • Fixed BGR vs. RGB color channel swizzle problem with 24bpp legacy .DDS files in DirectXTex
  • Update to DirectXTex WIC and WICTextureLoader for additional 96bpp float format handling on Windows 8

May 31, 2012
  • Minor fix for DDSTextureLoader's retry fallback that can happen with 10level9 feature levels
  • Switched to use "_DEBUG" instead of "DEBUG" and cleaned up debug warnings
  • added Metro style application project files for DirectXTex

April 20, 2012
  • DirectTex's WIC-based writer opts-in for the Windows 8 BMP encoder option for writing 32 bpp RGBA files with the BITMAPV5HEADER

March 30, 2012
  • WICTextureLoader updated with Windows 8 WIC pixel formats DirectXTex updated with limited non-power-of-2 texture support and TEX_FILTER_SEPARATE_ALPHA option
  • Texconv updated with '-sepalpha' command-line option
  • Added USE_XNAMATH control define to build DirectXTex using either XNAMath or DirectXMath
  • Added VS 2012 project files (which use DirectXMath instead of XNAMath and define DXGI_1_2_FORMATS)

March 15, 2012
  • Fix for resource leak in CreateShaderResourceView() Direct3D 11 helper function in DirectXTex

March 5, 2012
  • Fix for too much temp memory allocated by WICTextureLoader; cleaned up legacy 'min/max' macro usage in DirectXTex

February 21, 2012
  • WICTextureLoader updated to handle systems and device drivers without BGRA or 16bpp format support

February 20, 2012
  • Some code cleanup for DirectXTex and DDSTextureLoader
  • Fixed bug in 10:10:10:2 format fixup in the LoadDDSFromMemory function
  • Fixed bugs in "non-zero alpha" special-case handling in LoadTGAFromFile
  • Fixed bug in _SwizzleScanline when copying alpha channel for BGRA<->RGBA swizzling

February 11, 2012
  • Update of DDSTextureLoader to also build in Metro style apps; added WICTextureLoader
  • Added CMYK WIC pixel formats to the DirectXTex conversion table

January 30, 2012
  • Minor code-cleanup for DirectXTex to enable use of PCH through 'directxtexp.h' header

January 24, 2011
  • Some code-cleanup for DirectXTex
  • Added DXGI 1.2 implementation for DDSTextureLoader and DirectXTex guarded with DXGI_1_2_FORMATS compiliation define

December 16, 2011
  • Fixed x64 compilation warnings in DDSTextureLoader

November 30, 2011
  • Fixed some of the constants used in IsSupportedTexture(),
  • added ability to strip off top levels of mips in DDSTextureLoader,
  • changed DirectXTex to use CoCreateInstance rather than LoadLibrary to obtain the WIC factory,
  • a few minor /analyze related annotations for DirectXTex

October 27, 2011
  • Original release

Released: July 2015 (Jul 29, 2015)

$
0
0
July 29, 2015
  • Fixed rounding problem with 32-bit RGBA/BGRA format conversions
  • texconv: use CPU parallel compression for BC1-BC5 (-singleproc disables)
  • Updated for VS 2015 and Windows 10 SDK RTM
  • Retired VS 2010 and Windows 8.0 Store projects
Viewing all 1174 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>