Jump to content
  • Advertisement
Sign in to follow this  
paic

Comparing 2 textures [solved]

This topic is 4740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'd like to check if 2 textures are identicall or not. For the moment, I get the first mipmap level, then the description. Depending of the format, I compute the size of the textures (in bytes), lock the entire textures, and simply do a memcmp on the 2 pointers. BUT with compressed .dds (DXT1, DXT2, etc.) I have a problem : how do I compute the actual size of the texture to feed the memcmp function ? I someone can help me on that, or tell me another way to do the compare ... thanks in advance ^^ [Edited by - paic on May 31, 2005 9:43:43 AM]

Share this post


Link to post
Share on other sites
Advertisement
One way if im correct is by caculating the crc32 of the textures and comparing that. Another way is with a texture manager, I use one for my projects but generally I just compare the textures file name because I generally use external resources.

How ever if you had a texture manager you could always caculate the crc32 of each texture at initilization, however this may lag a little, so good to put in a load screen.

Share this post


Link to post
Share on other sites
In theory you should be able to use any file-diff tool. It probably can't show you the differences for binary files but should be able to confirm if the files are the same. However the files must be identical, not just the image described. If you want to do it at run-time from your program, just generate a texture from each image file using D3DX functionality maybe and compare the data there?

Share this post


Link to post
Share on other sites
Ok, seems like I wasn't really clear

@DevLiquidKnight : I'm needing that function for a texture manager ^^ Checking the filenames is not enough : what if graphists export 2 models in seperate directories, with the same texture ? And to complicate, they even changed the texture name ! (Aaah those nice graphists who seem to like making our lives like hell ^^) To compute crc32, I also need the size of the data block, which leads me to the same question : how do I get this size for a compressed texture like DXT1, etc. ?

@d000hg : loading the texture using a D3DX functionality and compare the data ... ^^ That's what I already do, and it's good for standard texture : ARGB, RGB, L16, etc. because from the texture format and size, I can compute the size of the data. But my question was : for COMPRESSED textures like DXT1, DXT2, etc. I don't know how to compute this size, and so, i'm unable to compare the data.


However, your answers gave me an idea : just compare the FILES instead of the image data, it's easier ... but slower :(


So if noone have another solution, i'll compare the 2 files, but I'd like to avoid it as much as possible ^^

Share this post


Link to post
Share on other sites
You could perhaps load the texture itself into memory which would uncompress it and compare it there.

The texture manager is not just a function its a singleton class. ^^

Share this post


Link to post
Share on other sites
Quote:
Original post by Nik02
Maybe this will be of help. Haven't had the need to calculate compressed DDS memory layout myself, though, so I cannot confirm the info personally.


This should work for him I think, it gives equation:

When computing DXTn compressed sizes for non-square textures, the following formula should be used at each mipmap level:

max(1, width ÷ 4) x max(1, height ÷ 4) x 8(DXT1) or 16(DXT2-5)

Share this post


Link to post
Share on other sites
Quote:
Original post by paic
Thx a lot Nik02, that's what I was looking for ^^


No prob [wink]

Share this post


Link to post
Share on other sites
I really hope this isn't to compare textures to remove copies from your texture manager. You're going to send load time through the roof, if it is. =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!