DarkPlacesEngine / DarkPlaces

The DarkPlaces Quake engine, created by LadyHavoc. Official Git repository (replaces SVN).
https://icculus.org/twilight/darkplaces/
GNU General Public License v2.0
272 stars 38 forks source link

Texture Matrix Issue For Q1 Maps Using Shader or External Texture #163

Open Baker7 opened 5 months ago

Baker7 commented 5 months ago

This water in Quake Combat+ is wrong:

xon_20240407_texture_matrix_q1_affects_all_shaders_and_external_textures_Mod_LoadTextureFromQ3Shader_model_brush_c

In model_brush.c in Mod_Q1BSP_LoadTextures

This is not equivalent to at all to classic DarkPlaces and the result is that all replacement textures and shaders in Q1 bsp will have the wrong texture matrix because the external texture size is used.

        tx = loadmodel->data_textures + i;
        // try to load shader or external textures, but first we have to backup the texture_t because shader loading overwrites it even if it fails
        backuptex = loadmodel->data_textures[i];
        if (name[0] && /* HACK */ strncmp(name, "sky", 3) /* END HACK */ && (Mod_LoadTextureFromQ3Shader(loadmodel->mempool, loadmodel->name, loadmodel->data_textures + i, va(vabuf, sizeof(vabuf), "%s/%s", mapname, name), false, false, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP | TEXF_COMPRESS, MATERIALFLAG_WALL) ||
                        Mod_LoadTextureFromQ3Shader(loadmodel->mempool, loadmodel->name, loadmodel->data_textures + i, va(vabuf, sizeof(vabuf), "%s"   , name), false, false, TEXF_ALPHA | TEXF_MIPMAP | TEXF_ISWORLD | TEXF_PICMIP | TEXF_COMPRESS, MATERIALFLAG_WALL)))
        {
            // set the width/height fields which are used for parsing texcoords in this bsp format
            tx->width = mtwidth;
            tx->height = mtheight;
            continue;
        }
        // no luck with loading shaders or external textures - restore the in-progress texture loading
        loadmodel->data_textures[i] = backuptex;

It is actually worse than that, it doesn't honor map folder like "textures/e1m1/this_texture.tga" won't ever get used.

What I did in Zircon was to rewrite and rework the texture load using DarkPlaces Classic for the sequence of event while keeping the intentions of what DarkPlaces Beta was trying to improve.

texturematrix

This is what the water is supposed to look like.