Author Topic: Early WIP on v2.55  (Read 132778 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #420 on: December 24, 2018, 11:32:03 am »
Mike

With the current version there is definitly a normal/bump problem when we do not use mipmap  textures.
You can try also with the JetVet model, and look at the tire bump texture when switching from one mode to the other.

Quote
until I find something equally suitable for, and compatible under, both W7 and W10.
Unfortunatly, and as you know it already i have no more way to test it on Seven, except asking you ;)
BTW i have used already RTF files with success for help in my PhotoComposer (since more than 10 years), but never with OLE, that seems to be the issue on previous OS.

Added
I reworked the initialisation of the Help process to keep the loading speed of OR unchanged.   ;)
Now it will be fired only the first time than you press the top left Icon.
« Last Edit: December 24, 2018, 12:23:11 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #421 on: December 24, 2018, 01:22:31 pm »
With the current version there is definitly a normal/bump problem when we do not use mipmap  textures.

No Patrice,

This isn't a bug inherent in this version alone. It has a very long history, and I believe it dates back to the times when you were ObjReader's only developer.

See the same glitch all over JetVette under similar conditions in an ObjReader compiled over 2.5 years ago.

Anyway I'm working on it though not very fruitfully yet. It seems like trivial memory corruption somewhere because so far I couldn't spot any invalid handles anywhere... ???
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #422 on: December 24, 2018, 01:51:50 pm »
Yes, you are right it has a long history, but this is the first time it is so obvious in a model  :o
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #423 on: December 24, 2018, 05:42:36 pm »
Patrice,

I have isolated the cause of mipmapping glitch.

The cause is some moronic 3rd party textures that are made artificially GL_REPEATable for their creator to be able to exceed the normal [0.0f,1.0f] UV range and better see the UV map of a particular mesh against the other UVs in the model by moving the mesh UV map completely out of the texture display in their UV mapping SW. >:(

I'm currently writing a UV verification routine to protect us against such cases by leaving the texture wrappable rather than clamped to the edges. Alas, the texture loading process is going to become longer than it was before.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #424 on: December 24, 2018, 06:32:40 pm »
Thank you for the feedback, perhaps this checking could be done only when switching mipmap off?
« Last Edit: December 24, 2018, 06:38:08 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #425 on: December 24, 2018, 07:31:03 pm »
I have completed the help topic selection, would you like to try it?
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #426 on: December 24, 2018, 07:31:35 pm »
Thank you for the feedback, perhaps this checking could be done only when switching mipmap off?

Exactly but regardless, it's a doubly nested for-loop.

OK, here's une pilule for your cyborg girl friend and your favorite car: :)

mobj.h
Code: [Select]
// MLL 12-25-2018: sanity check for safe GL_CLAMP_TO_EDGE
BOOL verifyUvsFitIntoZeroOneRange(IN long texID) {
    MobjMesh*    pMesh       = NULL;
    MobjMat*     pMaterial   = NULL;
    MobjVertexT* vertex      = NULL;
    float*       UVs         = NULL;
    BOOL         bNeedVerify = FALSE;
    GLuint       index = 0;

    if (texID == 0) // irrelevant
        return TRUE;
    if (texID == gP.mt.Texture) // wallpaper's always clamped
        return TRUE;
    for (int i = 0; i < gM.numberOfMeshes; ++i) {
        pMesh = &gtm_meshes[i];
        pMaterial = pMesh->pMaterial;
        if (pMaterial->reflMapID) // refl UVs are autogenerated "ad hoc"
            return FALSE;
        bNeedVerify = FALSE;
        if ((pMaterial->colorMapID == texID)
            || (pMaterial->ambiMapID == texID)
            || (pMaterial->bumpMapID == texID)
            || (pMaterial->specMapID == texID)
            || (pMaterial->dispMapID == texID)
            || (pMaterial->emitMapID == texID)
            || (pMaterial->glossMapID == texID)) {
            bNeedVerify = TRUE;
        }
        if (bNeedVerify) {
            index = pMesh->startIndex;
            for (int j = 0; j < pMesh->triangleCount * 3; j++, index++) {
                vertex = &gtm_vertexBuffer[gnm_indexBuffer[index]];
                if (vertex->texCoord[0] < 0.0f)
                    return FALSE;
                if (vertex->texCoord[0] > 1.0f)
                    return FALSE;
                if (vertex->texCoord[1] < 0.0f)
                    return FALSE;
                if (vertex->texCoord[1] > 1.0f)
                    return FALSE;
            }
        }
    }
    return TRUE;
}

void Mobj_makeMultipleTextures(IN ZGLTEXTUREX* mt, IN long mtCount) {
    if (mtCount> 0) {
        long K, OkDelete = 0;
        long* Texture = new long[mtCount];
        memset(Texture, 0, sizeof(long) * mtCount);
        for (K = 0; K < mtCount; K++) {
            Texture[K] = mt[K].Texture; if (Texture[K]) { OkDelete = -1; }
        }
        if (OkDelete) { glDeleteTextures(mtCount, (GLuint*) Texture[0]); }
        glGenTextures(mtCount, (GLuint*) &Texture[0]);
        long nRet = glGetError();
        if (nRet == 0) {
            for (K = 0; K < mtCount; K++) {
                BYTE* lpArray = NULL;
                long xSize = 0, ySize = 0;

                Mobj_texAlpha(0, 1); // 05-10-2015 to detect if we are using an alpha channel
                if (Mobj_createGlTextureFromFileEX(mt[K].FullName, xSize, ySize, lpArray, mt[K].Square)) {
                    mt[K].Texture = Texture[K];
                    mt[K].alpha = Mobj_texAlpha(0, 0); // 05-10-2015 to detect if we are using an alpha channel
                    GL_BindTexture(GL_TEXTURE_2D, Texture[K]); nRet = glGetError();
                    if (nRet == 0) {
                        // MLL 10-18-2018: fix to disallow mipmaps following "Mipmap textures" menu
                        if ((mt[K].Square > TEX_STRETCH) && gP.nEnableMipMap) { // MipMapping in ZI_CreateGLTextureFromFileEX
                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // MLL 12-25-2018: _MIPMAP_LINEAR can't be used for MAG_FILTER !!!
                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
                            if (mt[K].Square == TEX_REPEAT) {
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
                            } else if (mt[K].Square == TEX_CLAMP) { // MLL 02-28-2018:
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Avoid BB edge artifacts
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // ditto
                            }
                            gluBuild2DMipmaps(GL_TEXTURE_2D, 4, xSize, ySize, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                        } else { // TEX_ANYSIZE, NO MIPMAPPING (e.g. wallpaper or do not mipmap at all)
                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                            // MLL 12-25-2018:  !!! VERIFY that the texture UVs were not generated by a
                            //                  CLINICAL IDIOT that moved them out of [0.0f,1.0f] range
                            //                  and made the texture artificially WRAPPED just to be able
                            //                  to better see these UVs against the other meshes' UVs !!!
                            if (verifyUvsFitIntoZeroOneRange(Texture[K])) {
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Avoid wallpaper bottom line artifacts
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // ditto
                            } else {
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
                                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
                            }
                            glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, lpArray);
                        }
                        nRet = glGetError();
                    }
                    free (lpArray);
                }
            }
        }
        delete[] Texture;
    }
}


Enjoy! :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #427 on: December 24, 2018, 07:34:31 pm »
I have completed the help topic selection, would you like to try it?

But of course Patrice,

Why are you asking? :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #428 on: December 24, 2018, 07:45:47 pm »
I am asking because you told me that it doesn't work on Seven. ;)

Here is my sync patch, i managed to handle 1000 topics (see the 3 digits number in front of each topic name in the Helper folder), that should be quite enough. The numbers are used to easily sort the topic list order.

See also the use of # in file name to perform indentation in the list ("005#Lighting.rtf").
« Last Edit: December 24, 2018, 07:49:43 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #429 on: December 24, 2018, 07:56:03 pm »
Thank you!

And here's a more, er, natural rendition of the sanity check function. Please ovewrite the older one with it:

Code: [Select]
// MLL 12-25-2018: sanity check for safe GL_CLAMP_TO_EDGE
BOOL verifyUvsFitIntoZeroOneRange(IN long texID) {
    MobjMesh*    pMesh       = NULL;
    MobjMat*     pMaterial   = NULL;
    float*       UVs         = NULL;
    GLuint       index       = 0;

    if (texID == 0) // irrelevant
        return TRUE;
    if (texID == gP.mt.Texture) // wallpaper's always clamped
        return TRUE;
    for (int i = 0; i < gM.numberOfMeshes; ++i) {
        pMesh = &gtm_meshes[i];
        pMaterial = pMesh->pMaterial;
        if (pMaterial->reflMapID) // refl UVs are autogenerated "ad hoc"
            return FALSE;
        if ((pMaterial->colorMapID == texID)
            || (pMaterial->ambiMapID == texID)
            || (pMaterial->bumpMapID == texID)
            || (pMaterial->specMapID == texID)
            || (pMaterial->dispMapID == texID)
            || (pMaterial->emitMapID == texID)
            || (pMaterial->glossMapID == texID)) {
            index = pMesh->startIndex;
            for (int j = 0; j < pMesh->triangleCount * 3; j++, index++) {
                UVs = &gtm_vertexBuffer[gnm_indexBuffer[index]].texCoord[0];
                if (UVs[0] < 0.0f)
                    return FALSE;
                if (UVs[0] > 1.0f)
                    return FALSE;
                if (UVs[1] < 0.0f)
                    return FALSE;
                if (UVs[1] > 1.0f)
                    return FALSE;
            }
        }
    }
    return TRUE;
}
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #430 on: December 24, 2018, 08:04:26 pm »
I am asking because you told me that it doesn't work on Seven. ;)

I want to keep my finger in the broth regardless -- just in case you're going to break something with your help system mods.  ;D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #431 on: December 24, 2018, 08:09:41 pm »
My friend

Your pilule is a very good medicine, that totaly cured the problem, thanks a bunch!
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #432 on: December 24, 2018, 08:27:54 pm »
I'm glad I was able to isolate the cause of trouble relatively fast. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #433 on: December 26, 2018, 03:02:42 am »
                  Want some?


« Last Edit: December 26, 2018, 10:37:39 am by Patrice Terrier »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #434 on: December 26, 2018, 09:59:07 am »
Make sure to put the .HTM+.FILES into your \Help subfolder and use the .EXE instead of your regular ObjReader.

This is your 64-bit HH.exe that's in your C:\Windows folder, made to serve as a thin top-level window wrapper for a COM browser control to display our HTML help pages. 8)

HH.exe can also display .XML files if a matching .XMS style sheet is provided, and of course, which is the most convenient way of all, it can display a precompiled .CHM file that would have the smallest footprint on the disk.

HH.exe's standard toolbar and index/contents tab control have been suppressed because their respective window areas have too much flicker. The total length of code to pop up, trim and resize HH.exe is probably twice shorter than your .RTF stuff.

This demo has no contents list box implemented but it can easily be added to the scene exactly like you do in your RTF help system.
« Last Edit: December 26, 2018, 10:02:38 am by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)