Loading DDS Textures

BlitzMax Forums/BlitzMax Programming/Loading DDS Textures

col(Posted 2005) [#1]
Hi all. I've written a mod to load in dds textures. It won't load any flash dds cubemap textures or dds volume textures, just standard DXT1,DXT3 and DXT5 compressed mipmapped dds images. It won't load textures generated from DirectX Texture Tool - An internal parameter in the file descriptor always seems to be 0 !! Although you can always use this one :- http://mirror.ati.com/developer/TheCompressonator.exe

Unfortunately I've nowhere to web host, so if some kind person wouldn't mind hosting the files that'd be excellent.

The command is as simple as

Texture:Int = DDSLoadTexture("Test.dds")

and you get a 2D mipmapped texture to use as you would normally use a texture.

Cheers


Beaker(Posted 2005) [#2]
I can host for you. E-mail me.


Clyde(Posted 2005) [#3]
What's a DDs Texture?


AdrianT(Posted 2005) [#4]
does this work on mac too? if so your DA man :)

Been trying to get DDS support in trinity, only Ant wanted it cross platform and so he had automatic S3TC conversion when loaded into the game. Naturaly this isn't as good as being able to edit your own and use DDS in 3dsmax, Photoshop and winXP via the free plugin on the Nvidia developer site

I'll host your file for you at least for a month or so if you like?


AdrianT(Posted 2005) [#5]
Oh Thumbs, its a compressed texture that saves up to 6x the Vram as a regular Bitmap. There's max, maya, photoshop and XP plugins at:

http://developer.nvidia.com/object/nv_texture_tools.html

unless thats the texture tool col said didn't work?


col(Posted 2005) [#6]
@Evak, I assume you have a mac?? The DDS texture is primarily a Direct3D texture format and the function actually uses DirectDraw (2d) structures to 'get at' the file/texture format. The only way to know if it works is try it :) These should already be compiled into the code.

@Beaker, I've mailed them to you. Thanks a bunch.

@all
I can't remember if I had to install a dll to get it working coz I tried so many different ways you wouldn't believe it. Any probs, let me know.

Regards


col(Posted 2005) [#7]
Beaker has kindly hosted the file at www.playerfactory.co.uk/dds.zip . So a big THANKS go out to you for this.

There are 2 folders in the archive. You need to simply copy the nrg.mod folder into your Blitzmaxcore103\mod folder ( so it is in the same folder as BRL.mod and Pub.mod ). The other folder has a program to show you how to use the function. Don't forget if you use it in your code you will need to use:

Import nrg.dds

somewhere near the top of your code.

I'm working on the volume texture and cubemapped support, so I'll update this when finished.


AdrianT(Posted 2005) [#8]
Great work Colonel :)


col(Posted 2005) [#9]
Evak. Glad it works for mac also. Now I know how to code so Bmax will produce 'cross platform code'. Sorry for my ignorance, but whats Trinity?


AdrianT(Posted 2005) [#10]
er, I don't have a mac lol, didn't mean to misslead you. Trinity is antonys bmax 3d engine module.

hopefully the DDS thing will work on the mac, I guess we will have to wait for someone with a mac to try it out. I'd imagine theres a fair chance it will so long as you have an ATI or Nvidia card.


JoshK(Posted 2005) [#11]
How hard would it be to convert this loader to .bb code? A lot of people could use this.


col(Posted 2005) [#12]
Does Blitz3d support dds textures already??. I thought I saw some of 'swifts' code loading in .dds files?? could be wrong tho?

The whole of the code is written in c++ including generating the opengl texture, then the texture memory address is return into BlitzMax, and, well, as BMax uses opengl, it all comes together rather nicely ;)

I will try do it next. Just having some time-out to code a demo effect in B3D.

Regards


sswift(Posted 2005) [#13]
Col:
Blitz does not load DDS textures, and I have never written any code to.

There is however, a code archive snippet, that links to a Blitzcoder page, which has a library, which accesses an open source DLL called freeimage, which will load DDS files.

But that's only useful if you want to use DLL's to do it.

The DDS format in my opinion is rather useless for loading into Blitz. Why would you want to? I might, so I can allow people to EDIT them. But to load them for textures?

DDS can only compress images 6x, and it introduces blocky artifacts into the image. Jpeg compresses things as much as 50x, with fewer artifacts.

The only reason to use DDS is if you're going to use DDS compressed textures on the video card, and A) I'm not sure OpenGL even supports DDS textures, and B) If you're going to upload a DDS texture to the video card, wouldn't that just involve loading the raw data and sending it to the card as is?


Tom(Posted 2005) [#14]
I covered this when messing with a DX7 DLL. Bottom line is, we have no way to 'properly' return a DX7 surface pointer to Blitz3D because a B3D texture handle is a pointer to a custom struct.

What I did, was to cheat. I made my own DX7 surface from the DDS file, and set the surface pointer of an existing B3D texture to point to the new surface. (nasty!)

I do the same thing to make a renderable texture, they both work, but I honestly wouldn't reccommend using that method, it's just too hacky.

GL does support DDS, under a different naming convention I think (S3TC?), can't remember offhand. As for compression sswift......the DDS textures I loaded into B3D looked ok considering (depending on which mode DXT1 & 3 were ok iirc). No where near as bad as you make them out to be though :)


Tom


JoshK(Posted 2005) [#15]
I want to provide DDS support in CShop so DarkBasic users can view them. There are also a lot of good DDS textures out there to play with in FPSCreator and Doom 3.

I'm not looking for a way to support DDS compressed textures in OpenGL, I just want to load the file format as a regular texture.

BTW, it is extremely easy to implement compressed textures in gl.


col(Posted 2005) [#16]
It's not exactly hard. Depends on your experience as a programmer whether its difficult or not. The DDS texture is laid out as a compressed image and any mipmaps are also compressed after the next, so you just have to pay attention to the file. And you will need access to the texture in memory to implement it.

@swift.
I thought I saw a piece of code that had a filename with .dds extension. It was some code to do environment mapping or a similar effect. Never mind, you say it wasn't you.

@everyone
Take a look here for a better explaination of the conversion process:
http://developer.nvidia.com/attach/6585

Regards


JoshK(Posted 2008) [#17]
Does anyone still have this? I would like to load DDS files directly without using any external libs or passing them to VRAM.


SLotman(Posted 2010) [#18]
I know this is reaaally old, but if anyone has this available, I would love to see it working :)