Author Topic: There are many ways to go to Rome.  (Read 817 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1017
Re: There are many ways to go to Rome.
« Reply #105 on: March 24, 2019, 06:19:45 pm »
1. Très bon ! The easier the better! :)

2. What do you mean? ambiMapFilename is the name of our AO maps that may cause the need for UV correction in the first place! But I agree, reflection maps are useless here because their UVs are generated automatically in both pipelines and thus can't be edited manually.

3. By all means go ahead and add it! You should use every possibility to add as many tools as you only can to OR to make your model design efforts easier. That's what its editing functions are for. :)

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

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1190
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #106 on: March 24, 2019, 08:12:14 pm »
Here is the patch with the last changes.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1190
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #107 on: March 25, 2019, 08:03:11 pm »
What is your preference, to display behind transparent texture:
a PSD like checkerboard, or the new uvcheck.png
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1017
Re: There are many ways to go to Rome.
« Reply #108 on: March 25, 2019, 10:08:25 pm »
:-*

IMO there should be 3 options: (in the preferred order)
  • PSD-like checkerboard (default)
  • selectable solid colored background (usually I prefer dark green like the color of fabric on a poker/snooker table)
  • our regular UV-checker texture
Also, the red color should be reserved for the UVs ("bullets") and the associated wireframe areas that have been explicitly selected for modification. Deselected items should have a different color to be chosen optionally so as to look prominent against the current texture map background.


(Note we will eventually need much much more free space for the UV editor options and settings than the current "toolbar"...)
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: 1017
Re: There are many ways to go to Rome.
« Reply #109 on: March 25, 2019, 11:14:33 pm »
Re. your latest patch, when a mesh is (re)selected in a multi-mesh model, the user shouldn't have access to the tex maps that don't belong to that mesh's material. The top strip with the maps available for the current mesh should be updated in real time in response to the focus change in the mesh list.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1190
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #110 on: Today at 01:59:06 pm »
About CreateUVmap
Code: [Select]
void CreateUVmap(IN long selected) { // 03-20-2019
    MobjMesh* pMesh = &gtm_meshes[selected];
    long index = pMesh->startIndex; // gnm_indexBuffer[pMesh->startIndex];
    long vertsTotal = pMesh->triangleCount * 3;

    long x = 0, y = 0, w = 0, h = 0, nW = 0, nH = 0, nIDtoClone = 0, nSpriteCount = 0, color = 0;

    ZI_GetImageSizeFromControl(gT.hZoomCtrl, nW, nH);

    HDC hIC = zDisplayDC();
    HBITMAP hBitmap = zCreateDIBSection(hIC, nW, nH, 32);
    HDC hDC = CreateCompatibleDC(hIC);
    SelectObject(hDC, hBitmap);
    DeleteDC(hIC);

                    //// Create a GDI32 transparent brush, to clear the bitmap background.
                    //HBRUSH hBrush = CreateSolidBrush(NULL);
                    //RECT r; SetRect(&r, 0, 0, nW, nH);
                    //FillRect(hDC, &r, hBrush);
                    //DeleteObject(hBrush);

    POINT pt[3] = { 0 };
    LONG_PTR graphics = 0, pen = 0, brush = 0;
    GdipCreateFromHDC(hDC, graphics);
    // Create a pen to draw with
    GdipCreatePen1(ZD_ColorARGB(128, RGB(0,0,0)), 1.0f, UnitPixel, pen); // Do not use RGB(255,0,255), this is reserved for transparent GIF color.

    //GdipCreateSolidFill(ZD_ColorARGB(64, RGB(225,225,225)), brush);

    //WCHAR zAf[64] = { 0 };
    long count = 0;

    for (int j = 0; j < vertsTotal; j++, index++) {
        MobjVertexT* vertex = &gtm_vertexBuffer[gnm_indexBuffer[index]];

        pt[count].x = x = (long) ((nW - 1) * vertex->texCoord[0]);
        pt[count].y = y = (long) ((nH - 1) * (1.0f - vertex->texCoord[1]));

        count++;
        if (count == 3) {

            //GdipCreateSolidFill(ZD_ColorARGB(32, color), brush); color++; // Use a unique color for each triangle
            //GdipFillPolygon2I(graphics, brush, pt[0], count);
            //GdipDeleteBrush(brush);

            GdipDrawPolygonI(graphics, pen, pt[0], count);
            count = 0;
        }

        //StringCchPrintf(zAf, strSize(zAf), L"%d: %f, %f   x = %2d, y = %2d", j+1, vertex->texCoord[0], vertex->texCoord[1], x, y);
        //zTrace(zAf);

    }

    //GdipDeleteBrush(brush);

    GdipDeletePen(pen);
    GdipDeleteGraphics(graphics);
    DeleteDC(hDC);
    gT.MapID = IncrID();
    ZD_DrawBitmapToCtrl(gT.hZoomCtrl, 0, 0, hBitmap, ZD_ColorARGB(255, 0), gT.MapID, ZS_VISIBLE);
    ZD_SetObjectScroll(gT.MapID, TRUE);
    SpriteArrayInit(gT.MapID, gT.MapFileName);
    ZI_UpdateWindow(gT.hZoomCtrl, FALSE);
}

pMesh->triangleCount, reports the whole number of triangles in the mesh, but the UV's triangle count could be much smaller than that.

In the attached example, there are 440 triangles in the mesh, but only two in the corresponding UV flat projection.

What do you think is the best solution to draw only once the two triangles matching the UV's flat projection?


« Last Edit: Today at 02:03:56 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1017
Re: There are many ways to go to Rome.
« Reply #111 on: Today at 04:23:58 pm »
pMesh->triangleCount, reports the whole number of triangles in the mesh, but the UV's triangle count could be much smaller than that.
No, it couldn't. There should be exactly as many UV tris as there are 3D mesh tris.

Quote
In the attached example, there are 440 triangles in the mesh, but only two in the corresponding UV flat projection.
No, the UV projection contains 440 flat tris, and this is correct. It is just that the 3D mesh tris reuse the same portions of (actually, the entire) texture map rather than form up so called "UV islands" on a much larger map such as seen e.g. in the dragon's UV wireframe. Generally, reusing/sharing/overlaying portions of mesh texture maps is considered bad practice in modern 3D design because it prohibits generation of correctly matching light, shadow (AO), and height maps that by the very definition of visual phenomena they are intended to emulate simply cannot be shared among individual polies or meshes.

That said,
Quote
What do you think is the best solution to draw only once the two triangles matching the UV's flat projection?
there is no solution because in fact, the flat projection contains not 2 but 440 tris.

In order to be able to select and adjust the UVs of every quad in the mesh as may be necessary, the tri corner UVs should be made slightly different in each quad at model design time. Then, the resolution/magnification of UV editor (such as Tor) should be made sufficient to visualize those differences in both wireframe layout and "bullet" positions to be able to select and drag the right "bullets" and adjust the looks of each quad as necessary if needed.

If the UVs of all the quads are exactly the same, then you are in big trouble in case you need to adjust only one, or a few, of the quads. Then whatever resolution Tor or any other UV editor has, you won't be able to point-and-drag the correct bullet(s). :)

Do you understand what I mean?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1190
    • zapsolution
Re: There are many ways to go to Rome.
« Reply #112 on: Today at 05:11:22 pm »
If you look at the VT section within fur.obj


vt 1 1 0
vt 0 1 0
vt 0 0 0
vt 1 0 0
# 4 texture coordinates

you will see the original coordinates, my thought was to use them to compute the correct UV's map triangles, and in the case of "fur" using only 2 triangles rather than 440...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1017
Re: There are many ways to go to Rome.
« Reply #113 on: Today at 05:51:05 pm »
There should have been 220, rather than 4, UV pairs* with slightly different values. Then the model modder (such as you) would've been able to readjust them in case his mod needs it.

Those are not the "original" coords. Those are the evidence of model author's goofiness (if he doesn't know what I'm telling you) or evil intent (if he knows and has done it on purpose to disallow others to mod this mesh). ;)

The "correct UV map triangles" (as well as normals and positions) are those 440 ones that are drawn in accordance with the mesh's actual 3D geometry coded in the face section of .OBJ file through f directives but not those that are written in the .OBJ file's reusable and "depersonalized" v, vt, and/or vn caches!

How can you foretell you (or yet another modder) won't ever want, or need, to remap one or more UV pairs of this mesh in the future to some other places within some other, perhaps artistically much better, map instead of this simple fur.png? ;)

My friend, you're seeing (seeking) things (to optimize) that aren't there.


_______________________________________
* BTW why does your SW generate an empty 3rd UV coord in each pair? Can you turn that annoying option off?
« Last Edit: Today at 06:03:51 pm by Michael Lobko-Lobanovsky »
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)