1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  4. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  5. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Fixing a texture that crashes WE

Discussion in 'Requests' started by TheFrenchLeprechaun, Jan 11, 2017.

  1. TheFrenchLeprechaun

    TheFrenchLeprechaun

    Joined:
    Jun 22, 2012
    Messages:
    464
    Resources:
    0
    Resources:
    0
    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!
     

    Attached Files:

  2. LordDz

    LordDz

    Joined:
    May 11, 2007
    Messages:
    4,303
    Resources:
    0
    Resources:
    0
  3. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    780
    Resources:
    2
    Spells:
    2
    Resources:
    2
    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:
    [​IMG]
    GAME (I had to double their scaling size in the following image):
    [​IMG]

    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.
     

    Attached Files:

    Last edited: Jan 11, 2017
  4. TheFrenchLeprechaun

    TheFrenchLeprechaun

    Joined:
    Jun 22, 2012
    Messages:
    464
    Resources:
    0
    Resources:
    0
    That's what I feared...

    What could cause this damn bug?

    EDIT : fixed thanks to BloodSoul (texture resized to 512x512)
     
    Last edited: Jan 11, 2017
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,955
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.

    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.
     
  6. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    780
    Resources:
    2
    Spells:
    2
    Resources:
    2
    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!
     
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,955
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.