DDS Loading Into Texture2D

Started by
2 comments, last by L. Spiro 11 years, 2 months ago

Hi,

I am creating an engine using C# and SharpDX. To load DDS files, I was originally decoding the file to a R8G8B8A8 format which defeats the purpose of using DDS as it removes all compression. I am now trying to load DXT5 textures into my engine whilst keeping the compression but I am stuck when trying to copy the texture into the Texture2D DX resource. I have the texture format set as BC3_UNORM.

I'm not quite sure what part of the DDS file I am meant to be copying to the resource and whether or not I am meant to be reordering some channels of the file before doing so. I have tried to find documentation online but it seems to be scarce as everyone wants to use helper functions whereas I am trying to avoid using them solely for the task of loading a DDS file.

Any help or insight into what part of the file I am meant to be copying to the Texture2D resource and any modifications I need to perform would be helpful.

Thanks.

Advertisement
Skip the header and give each texture body as-is to the texture class/Direct3D.
When you have mip-maps you will have multiple texture bodies in the file. You have to calculate the sizes of each body anyway to know how much to give to Direct3D. Each texture body follows the previous with no padding between them.
Bodies are never smaller than 4×4 chunks, even when the dimensions of the mip-map (or texture) are smaller, such as 1×1.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Thanks for the info, I think I should be able to get it done now. Also, just double checking, is BC3_UNORM the correct format to be using with DXT5?

Yes, or D3DFMT_DXT5.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement