• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Fixing a texture that crashes WE

Status
Not open for further replies.
Level 9
Joined
Jun 22, 2012
Messages
472
Hey there!

I'm facing a really strange problem. I'm using a model that was working perfectely and all of a sudden it is now crashing WE. The problem does not seem to come from the model itself but from its texture. Actually, the problem is "solved" when I delete the orginal texture and replace it by a random texture with the good path.

Before the bug, the model was displaying well (in War3 Model editor and in game/WE).

After the bug, the model still looks good in War3 Model editor, but in WE the wrapping has changed (cf Capture) and it crashes the game when the unit is selected in WE. I tried to convert the texture to TGA then again to BLP (with Warcraft viewer 2.3), but the output texture is 0kb. Then, I tried to only convert the texture to TGA and change the path of the texture accordingly but the wrapping is again messed up (in a diferrent way in WE and Model editor). The "good" news about this last try is that WE doesn't crash anymore.

Do you have the same problem with the model and texture? Because I didn't have it at the beginning.

I have no clue how to solve this problem, I've tried all that came in mind, so help is highly welcome :)!

+rep for helpers and thanks in advance!
 

Attachments

  • Aragorn.blp
    168.7 KB · Views: 97
  • Aragorn.TGA
    1.5 MB · Views: 108
  • Capture.PNG
    Capture.PNG
    9.6 KB · Views: 107
  • HU14(blptexturepath).mdx
    347.5 KB · Views: 109
  • HU14(tgatexturepath).mdx
    347.5 KB · Views: 84
Level 13
Joined
May 10, 2009
Messages
868
I downloaded those files attached to your comment, and they work for me.

However, the TGA texture looks flawed when I zoom out/keep a certain distance away from the model, as you can see below:

WE:
xPKWpif.jpg

GAME (I had to double their scaling size in the following image):
t5rw2qi.jpg

EDIT: It looks like the .BLP texture had a size of 774 x 518 pixels. As far as I know, the blp size limit is/was 512 x 512 pixels. I reduced its size, and attached the file to this post. It seems that solved the problem for Judotrente.
 

Attachments

  • a.w3m
    1.3 MB · Views: 72
  • Aragorn.blp
    550 KB · Views: 114
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
However, the TGA texture looks flawed when I zoom out/keep a certain distance away from the model, as you can see below:
Obviously. TGA lacks mipmaps. Mipmaped surfaces can only use blp files as WC3 does not auto generate mipmaps. TGA files load all other non existent mipmaps as transparent black hence the artefacts.

EDIT: It looks like the .BLP texture had a size of 774 x 518 pixels. As far as I know, the blp size limit is/was 512 x 512 pixels. I reduced its size, and attached the file to this post. It seems that solved the problem for Judotrente.
This was the case until 1.27b. Now only mipmaps less than or equal to 512*512 (dimension wise) are loaded with the higher resolution ones discarded. There is no problem getting WC3 to use a 1920*1080 BLP file but it is pointless doing so as the extra quality cannot be used.

My hint is to not use trash like WC3 Model Viewer to make broken BLP files. Instead use my JAVA library which was not written using a wrong specification so makes working BLP files.

If you state the JPEG quality you want and the source image I can make you a working BLP at the maximum resolution possible.

Do note that between 1.27a and 1.27b there have been huge changes to how WC3 processes BLP files. If you still use a legacy WorldEdit, such as for JNGP, then it will crash with some BLP files that do not crash WC3. Additionally WC3 will no longer load BLP files without a complete set of valid mipmaps.

TGA files have no resolution limits in WC3. However they have no mipmaps which means they are useless for most purposes. Without mipmaps you get aliasing which destroys the purpose of "high resolution" texutures.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Oh, to be honest, I didn't know what's mipmap, and that TGA lacks it. However, I've read about it a little bit, and that makes sense now. Thanks!
The reason mipmaps exist is due to sampling theory and the need to scale/distort images in real time. Performing such scale/distortion in real time is not as easy as one might think. The simplest way is to resample, mapping output pixels to the nearest pixel in the image using a matrix. This is very efficient and real time friendly however it suffers the same problems as all sampling, a finite nyquist frequency and so aliasing. Bilinear filtering helps a bit by interpolating a pixel value using the 4 nearest image pixels, and it is also very real time friendly and can be easily hardware accelerated. However this "filter" is a finite impulse response filter limited to 4 pixels so will only work to prevent aliasing down to half the original resolution. Any image scaled to under half the original resolution will start to suffer increasing magnitudes of aliasing as pixels will skipped by the filter. To get around this mipmaps can be used which are a set of pre-filtered images down sampled dividing dimensions by 2 (minimum 1 pixels). When a mipmapped image is down sampled in real time then the highest resolution mipmap level is chosen that when using the sampling filter will not produce aliasing. This is further improved with trilinear filtering which not only interpolates from 4 neighbouring samples of the selected mipmap level, but also between 2 mipmap levels to eliminate discontinuities caused by mipmap level boundaries.

How mipmaps should be computed is a subject of much debate. The generally "correct" approach is an area based averaging filter, somewhat like bilinear filtering but with a resolution appropriate sample size. Others include the "on the fly" approach of repeated bilinear downsampling from the previous mipmap level, similar but with bicubic filtering and by down sampling in the frequency domain (potentially most correct but has other issues). Many modern robust games will automatically generate mipmaps for images that lack them however this does come at a load time penalty, especially if algorithms like area averaging are used which are not very efficient.

You can see the result of mipmaps, or more likely the lack there of, by looking at the terrain of WC3. In World Edit zoom out far from the terrain and you will start to see the terrain texture aliasing. This is because WC3 terrain is not mipmaped due to how it works (would cause artefacts). If a high resolution custom TGA tile texture is used the aliasing is even more clear. Oddly the aliasing is reduced by forcing trilinear filtering at a driver level, which might look better but is most certainly less correct.
 
  • Like
Reactions: ILH
Status
Not open for further replies.
Top