Author Topic: Peugeot-Onyx (concept car)  (Read 42786 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #15 on: January 05, 2018, 05:58:27 pm »
Mike--

Here is the new Main.zip, with the new menu option "Show IPS (Iteration/second)".

I have also attached the latest WIP project (indices 9432819).

Note:
IPS is the only thing that we can compute with accuracy, especially because of the queue used by the GPU.



...

« Last Edit: January 07, 2018, 02:27:37 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Peugeot-Onyx (concept car)
« Reply #16 on: January 06, 2018, 02:31:45 am »
Thank you Patrice,

Are you sure the other modules (especially your precompiled libraries) have not been updated as well?

I am not seeing the IPS counter on my screen after recompilation with the new Main.cpp... :(


P.S. Please be patient for a little while more. I'll send you the sources with individual per-component color and on/off control over all the 3 lights and total scene brightness in both the FFP and PPL this afternoon or evening.
« Last Edit: January 06, 2018, 08:54:49 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)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #17 on: January 06, 2018, 10:19:49 am »
Mike--

Here is the full project in VS2013 PRO version.
I have checked the IPS with it, and it works fine by me.

Note:
The Resource folder is empty to reduce the size of the zip file

Do a WinMerge first, to see the minor code changes.

I am waiting for your version before working on the new meta, but take your time there is no hurry, this is the privilege of retirement.  :)

« Last Edit: January 06, 2018, 11:42:36 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Peugeot-Onyx (concept car)
« Reply #18 on: January 06, 2018, 02:59:59 pm »
Thanks again Patrice,

But I'm sorry to say this latest ObjReader you sent me compiles just fine yet it doesn't show the IPS counter under Windows 7 either. But it does, under Windows 10.

Just don't tell me you aren't using Win 7 any more and you're living in the 22nd century. Us mortals still use Win 7 a lot and not being compatible with it is detrimental to the product. ;)
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: Peugeot-Onyx (concept car)
« Reply #19 on: January 06, 2018, 06:21:16 pm »
Quote
doesn't show the IPS counter under Windows 7 either

That is very strange, because the code is the same than the one i am using into my BassBox plugins (written at the time of XP/VISTA).
And both WinLIFT and GDImage are compiled with VS2010 to produce smaller DLL.

BTW i just updated all my computers to the latest Windows 10 patch, to protect me from the new Spectre/Meltdown big threat, that affects all CPU computers build since 20 years, and ranking from Andoid to IOS (PC, tablet, and smartphone).

« Last Edit: January 06, 2018, 06:26:57 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #20 on: January 06, 2018, 07:15:09 pm »
Mike

Please try with the attached zip file provided with a new IPS.h include file, that you should be able to check in debug mode with Seven.

...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Peugeot-Onyx (concept car)
« Reply #21 on: January 07, 2018, 04:05:04 am »
... a new IPS.h include file, that you should be able to check in debug mode with Seven.

Thank you Patrice,

I'll try it as soon as I'm through with the lights.

I've installed the patch for my Win 10 that's on a separate PC, but I haven't yet, for my Win 7 that's the host OS on my main dev workstation. I hear the patch can make your CPU run up to 40% slower, which I wouldn't like to see on my WS. I rarely use it for surfing the web anyway, so I don't think anybody would be so eager or patient enough as to fish for my personal info on such a rare occasion...
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: Peugeot-Onyx (concept car)
« Reply #22 on: January 07, 2018, 07:58:15 am »
Patrice,

I've done all the lighting I planned for ObjReader. It's now even cooler than what I have in my own Objector. As far as the 3 static directional light sources in both FFP and PPL are concerned, this lighting is almost as strong as what you probably have in your C4D editor renderer.  8)

All that's left to program is a scene master illumination control whose slider I squeezed in to the right of alpha threshold knob for now. I guess you'll have to re-position and anchor it to your liking all by yourself. I put it there just for testing.

I need only to add 9 buffer color arrays more wherein the colors are going to be attenuated by the scene master illumination factor slider and fed to the GL_LIGHT sources. That's little to do but I'll finish it off later today. Need to zzzzzz a little after a sleepless night.

In the meantime, watch what acid lighting can easily do with your creations.  ;D

« Last Edit: January 07, 2018, 08:00:13 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)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #23 on: January 07, 2018, 11:09:53 am »
Mike--

Quote
I hear the patch can make your CPU run up to 40% slower
So far i didn't notice a speed degradation into my multimedia applications, at least on my gaming laptop.

Quote
this lighting is almost as strong as what you probably have in your C4D editor renderer.

Wow, you did a tremendous work, congratulations !

Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #24 on: January 07, 2018, 04:53:21 pm »
Material support suggestion for both A2C and Billboarding

Code: [Select]
struct MobjMat {
    float ambient[4];
    float diffuse[4];
    float specular[4];
    float shininess;        // [0 = min shininess, 1 = max shininess]
    float alpha;            // [0 = fully transparent, 1 = fully opaque]

    std::string defMapFileName;
    std::string colorMapFilename; // ML: let those stay for a while; haven't decided yet if we need them at all h
    std::string bumpMapFilename;

    long illum;

    // ML: EXTRA
    std::string ambiMapFilename; // ditto
    std::string specMapFilename;
    std::string reflMapFilename;
    // To those IDs that follow below, assign *IN ADVANCE AND ONLY ONCE PER MATERIAL* whatever this code:
    // ....
    // if (memcmp(pszTextName, &pMaterial->color|bump|ambi|specMapFilename[0], strlen(pszTextName)) == 0) {
    //  glBindTexture(GL_TEXTURE_2D, gt_texObj[nCount].Texture);
    //  break;
    // }
    // ....
    // returns in its "gt_texObj[nCount].Texture" in every texture loop of your Mobj_DrawUsing...() procs
    // in every frame they render again and again. There is absolutely no need to do it that way. You're
    // killing your FPS rate with your own hands by comparing turtle slow string names all over again in
    // each frame.

    // This is your *ABSOLUTELY HIGHEST PRIORITY* task.

    // Please take any such loop out of render procs into a separate procedure and run it just once for
    // all the textures in all the materials of the model, so that
    // &pMaterial->ambi|diff|bump|specMapID = gt_texObj[nCount].Texture;
    // then delete all those loops from the render procs and just use
    // glBindTexture(GL_TEXTURE_2D, &pMaterial->ambi|diff|bump|specMapID);
    // as appropriate.
    long colorMapID;
    long ambiMapID; // OpenGL numeric texture "names" (IDs) to be assigned as I described above
    long bumpMapID;
    long specMapID;
    long reflMapID;
    long isA2C;       // PAT: 01-07-2018
    long isBillboard; // PAT: 01-07-2018
};

Code: [Select]
void Mobj_importMaterials(const char *pszFilename) {

    FILE* pFile = fopen(pszFilename, "r");
    if (pFile == 0) { return; }

    MobjMat* pMaterial = 0;
    long K = 0, nI = 0, nIllum = 0, nNumMaterials = 0;
    char szBuffer[MAX_PATH] = { 0 };
    char fullPath[MAX_PATH] = { 0 };

    Mobj_gl_cw(0, 1); // 10-29-2015
    Mobj_ambient(0, 1); // 11-19-2015
    Mobj_AlphathresholdValue(0.0f, 1); // 12-14-2015
    Mobj_bothsides(0, 1); // 05-02-2016
    Mobj_AlphaToCoverage(0, 1); // 12-11-2017

    long nGlobal = -1; // PAT: 01-07-2018

    // Count the number of materials in the MTL file.
    while (fscanf(pFile, "%s", szBuffer) != EOF) {
        CharLowerA(szBuffer);
        switch (szBuffer[0]) {
        case 'n': // newmtl
            if (strcmp(szBuffer, "newmtl") == 0) { // 12-12-2015 ML: n can also mean lowercase Ns
                ++nNumMaterials;
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                nGlobal = 0;
            } else {
                fgets(szBuffer, sizeof(szBuffer), pFile);
            }
            break;
        case '#': // Shall we use a specific  wallpaper or clockwise polygons
            if (nGlobal) {
            if (strcmp(szBuffer, "#wallpaper") == 0) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s", szBuffer);
                memset(&gsw_wallpaper[0], 0, sizeof(WCHAR) * MAX_PATH);
                MultiByteToWideChar(CP_ACP, 0, szBuffer, (long)strlen(szBuffer), gsw_wallpaper, MAX_PATH);
            } else if (strcmp(szBuffer, "#gl_cw") == 0) {
                Mobj_gl_cw(-1, 1);
            } else if (strcmp(szBuffer, "#ambient") == 0) {
                Mobj_ambient(-1, 1);
            } else if(strcmp(szBuffer, "#bothsides") == 0) {
                Mobj_bothsides(-1, 1);
            } else if (strcmp(szBuffer, "#threshold") == 0) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s", szBuffer);
                Mobj_AlphathresholdValue((float) atof(szBuffer), 1);
            } else if(strcmp(szBuffer, "#alphatocoverage") == 0) {
                Mobj_AlphaToCoverage(-1, 1);
            } else {
                fgets(szBuffer, sizeof(szBuffer), pFile);
            }
            }
            break;
        default:
            fgets(szBuffer, sizeof(szBuffer), pFile);
            break;
        }
    }

    rewind(pFile);

    gnm_numberOfMaterials = nNumMaterials;
    gtm_materials.resize(gnm_numberOfMaterials);
    gnm_numberOfTextures = 0;
    nNumMaterials = 0;

    // Load the materials in the MTL file.
    while (fscanf(pFile, "%s", szBuffer) != EOF) {
        CharLowerA(szBuffer);
        switch (szBuffer[0]) {
        case 'n': // Ns
            if (szBuffer[1] == 's') {
                fscanf(pFile, "%f", &pMaterial->shininess);
                // Wavefront .MTL file shininess is from [0,1000].
                // Scale back to a generic [0,1] range.
                pMaterial->shininess /= 1000.0f;
            } else if (strstr(szBuffer, "newmtl") != 0) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                // Material
                pMaterial = &gtm_materials[nNumMaterials];
                pMaterial->ambient[0] = 0.2f;
                pMaterial->ambient[1] = 0.2f;
                pMaterial->ambient[2] = 0.2f;
                pMaterial->ambient[3] = 1.0f;
                pMaterial->diffuse[0] = 0.8f;
                pMaterial->diffuse[1] = 0.8f;
                pMaterial->diffuse[2] = 0.8f;
                pMaterial->diffuse[3] = 1.0f;
                pMaterial->specular[0] = 0.0f;
                pMaterial->specular[1] = 0.0f;
                pMaterial->specular[2] = 0.0f;
                pMaterial->specular[3] = 1.0f;
                pMaterial->shininess = 1.0f;
                pMaterial->alpha = 1.0f;
                pMaterial->defMapFileName = szBuffer;
                pMaterial->colorMapFilename.clear();
                pMaterial->bumpMapFilename.clear();
                pMaterial->illum = 1;
                pMaterial->ambiMapFilename.clear();
                pMaterial->specMapFilename.clear();
                pMaterial->reflMapFilename.clear();
                pMaterial->colorMapID = 0;
                pMaterial->ambiMapID = 0;
                pMaterial->bumpMapID = 0;
                pMaterial->specMapID = 0;
                pMaterial->reflMapID = 0;

                m_materialCache[pMaterial->defMapFileName] = nNumMaterials;
                ++nNumMaterials;
            }
            break;

        case 'k': // Ka, Kd, or Ks
            switch (szBuffer[1]) {
            case 'a': // Ka
                fscanf(pFile, "%f %f %f",
                    &pMaterial->ambient[0],
                    &pMaterial->ambient[1],
                    &pMaterial->ambient[2]);
                pMaterial->ambient[3] = 1.0f;
                break;

            case 'd': // Kd
                fscanf(pFile, "%f %f %f",
                    &pMaterial->diffuse[0],
                    &pMaterial->diffuse[1],
                    &pMaterial->diffuse[2]);
                pMaterial->diffuse[3] = 1.0f;
                break;

            case 's': // Ks
                fscanf(pFile, "%f %f %f",
                    &pMaterial->specular[0],
                    &pMaterial->specular[1],
                    &pMaterial->specular[2]);
                pMaterial->specular[3] = 1.0f;
                break;

            default:
                fgets(szBuffer, sizeof(szBuffer), pFile);
                break;
            }
            break;

        case 't': // Tr
            switch (szBuffer[1]) {
            case 'r': // Tr
                if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
                    fscanf(pFile, "%f", &pMaterial->alpha);
                    if (pMaterial->alpha > 0.0f) {
                        pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
                    }
                    if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
                } else {
                    fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
                }
                break;

            default:
                fgets(szBuffer, sizeof(szBuffer), pFile);
                break;
            }
            break;

        case 'd':
            fscanf(pFile, "%f", &pMaterial->alpha);
            break;

        case 'i': // illum
            fscanf(pFile, "%d", &nIllum);
            pMaterial->illum = nIllum;
            if (nIllum == 1) {
                pMaterial->specular[0] = 0.0f;
                pMaterial->specular[1] = 0.0f;
                pMaterial->specular[2] = 0.0f;
                pMaterial->specular[3] = 1.0f;
            }
            break;

        case 'm': // map_Kd, map_bump
            // 11-02-2015 added support for map_Ka, map_Ks
            if (strstr(szBuffer, "map_kd")) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                Path_CombineA(fullPath, (char*)gsm_directoryPath.c_str(), szBuffer);
                if (FileExistA(fullPath)) {
                    pMaterial->colorMapFilename = fullPath;
                    ++gnm_numberOfTextures;
                }
            } else if (strstr(szBuffer, "map_bump")) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                Path_CombineA(fullPath, (char*)gsm_directoryPath.c_str(), szBuffer);
                if (FileExistA(fullPath)) {
                    pMaterial->bumpMapFilename = fullPath;
                    ++gnm_numberOfTextures; // 03-24-2015
                }
                // 11-02-2015
            } else if (strstr(szBuffer, "map_ka")) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                Path_CombineA(fullPath, (char*)gsm_directoryPath.c_str(), szBuffer);
                if (FileExistA(fullPath)) {
                    pMaterial->ambiMapFilename = fullPath;
                    ++gnm_numberOfTextures; // 03-24-2015
                }
                // 11-02-2015
            } else if (strstr(szBuffer, "map_ks")) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                Path_CombineA(fullPath, (char*)gsm_directoryPath.c_str(), szBuffer);
                if (FileExistA(fullPath)) {
                    pMaterial->specMapFilename = fullPath;
                    ++gnm_numberOfTextures; // 03-24-2015
                }
            } else {
                fgets(szBuffer, sizeof(szBuffer), pFile);
            }
            break;

        case 'r': // refl
            if (strstr(szBuffer, "refl")) {
                fgets(szBuffer, sizeof(szBuffer), pFile);
                sscanf(szBuffer, "%s %s", szBuffer, szBuffer);
                Path_CombineA(fullPath, (char*)gsm_directoryPath.c_str(), szBuffer);
                if (FileExistA(fullPath)) {
                    pMaterial->reflMapFilename = fullPath;
                    ++gnm_numberOfTextures; // 03-24-2015
                }
            }
            break;

        case '#': // PAT: 01-07-2018 meta specific for material
            if (strcmp(szBuffer, "#alphatocoverage") == 0) {
                if (Mobj_AlphaToCoverage(0, 0) == 0) {
                    pMaterial->isA2C = -1;
                }
            } else if(strcmp(szBuffer, "#billboard") == 0) {
                pMaterial->isBillboard = -1;
            }
            break;

        default:
            fgets(szBuffer, sizeof(szBuffer), pFile);
            break;
        }
    }
    fclose(pFile);
}
« Last Edit: January 07, 2018, 04:58:50 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Peugeot-Onyx (concept car)
« Reply #25 on: January 07, 2018, 06:26:42 pm »
Looks fine, Patrice!

May I also suggest once again that we take this opportunity and change the #ambient global metacommand to something more appropriate, e.g. like #multilight or similar? The term "ambient" has a very precise meaning in OpenGL, and this meaning differs dramatically from what the #ambient metacommand currently implies in the context of ObjReader's material library file...  ::)
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: Peugeot-Onyx (concept car)
« Reply #26 on: January 07, 2018, 06:38:11 pm »
No problem, btw the A2C works great now per material into PPL i shall do the same for FFP;)

and we can still use the global one.
« Last Edit: January 07, 2018, 06:39:59 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Peugeot-Onyx (concept car)
« Reply #27 on: January 07, 2018, 06:54:59 pm »
Ok, now we can use the #multilight meta-command, and gP.nAmbientLight become gP.nMultiLight.

Reworking the ONYX.mtl to use A2C per material rather than global...

Added:
Onyx looks perfect ;)

Tell me if you want the new .mtl file, and the latest changes i have done into mobj.h and Main.cpp  :-[
« Last Edit: January 07, 2018, 07:17:15 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Peugeot-Onyx (concept car)
« Reply #28 on: January 08, 2018, 03:22:53 am »
Patrice,

My suggestion is as follows.

1. I'm finished  with ObjReader's lights. My code comes in the zip below. There are many changes to Main/mobj but all of them are indispensable.

2. Compile them as-is and see/get accustomed to how the lights and GL_EMISSION now work in ObjReader. Do not criticize; what you don't like will most likely be something you're not yet accommodated well enough to.

3. Use WinMerge to merge your mods with my base code, not vice versa, little by little and see if anything in your mods breaks my functionality.

4. Once merged and fully working, you're free to trim the code making sure the functionality remains unaffected. Please do not attempt to camouflage my flag variables with your usual Mobj_xxxx() wrappers. Flags are supposed to work fast in time critical parts of the code, and extra function call overhead is the last thing we'd like to see e.g. in our render procs.


When it's all ready, I would be glad to get both the final sources AND the very latest glorious Onyx to match ObjReader's new capabilities.

Have fun! :)
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: Peugeot-Onyx (concept car)
« Reply #29 on: January 08, 2018, 08:46:47 am »
Thank you Michael for all your hard work, i shall now decipher the code and try to figure what is the best way to use it.

thank you again!

Patrice
(Always working with the latest Windows version available...)