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

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #540 on: January 22, 2019, 03:20:43 pm »
1. Yes. Just rem out line 397 in GLuint glsl_LoadShader() (shaders.h):

//"fragmentColor.a += (dot(lightSpecular.a, lightSpecular.a) * 0.1); // SPECULAR_ALPHA\n"

In fact I can't even understand the idea behind the alpha channel in a light color, let alone use it purposefully in my code. ;D

2. What do you mean, about ShaderToy? From now on, I'm going to DL your ShaderToy WIPs/models only when you say you're through with them and what you've posted is your final vision of the work -- like I did with unreal.zip.

I don't want to irritate you any more and interfere with my untimely and lame suggestions or comments on what you're doing and how. :)
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 #541 on: January 22, 2019, 05:37:09 pm »
Ok, that did it, thank you!

Now you can use this in Tealc.mtl
Code: [Select]
newmtl plastron
#alphatocoverage
Ka 0.01 0.01 0.01
Kd 0.75 0.75 0.75
Ks 0.75 0.75 0.75
map_Kd Body.png
map_bump plastron_bump.png
map_Ka Body_AO.png
map_Ns Body_Roughness.png
map_Ks Body_Metallic.png
Ns 912
d 0.99
illum 2

About ShaderToy i was speaking of this
https://www.shadertoy.com
To use as an optional wallpaper replacement.

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

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #542 on: January 22, 2019, 06:09:59 pm »
Now you can use this in Tealc.mtl

Done, thank you!

Quote
To use as an optional wallpaper replacement.

Oh, I confused it with SketchFab... Evidently the identical number of letters in the name confused me.

About animated backgrounds, it isn't much of a problem to draw an animated ray tracing shader's output to the screen background quad in place of a static wallpaper texture. But we also have that fancy "ambient reflection" mode, whereby the shader output should be used as a reflection texture to cover the model surfaces.

I see a solution as drawing the shader output into a preallocated texture map first to cover the wallpaper quad and then reuse it as the refl texture for the surfaces. The method is known as "draw to texture" that's often used to model animated television and movie screens with the help of .AVI files. But this will require some reasonable experimentation to ensure sufficient quality not worse than that of the existing static wallpapers. Perhaps the preallocated texture map size will have to be monitored in real time and resized to match the current gP.hGL because if the map is too small, magnification to fit the current screen size can make the resultant image too blurry to maintain high quality of the scene background.
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 #543 on: January 24, 2019, 08:24:57 am »
Functions to smooth out, and overcome dull linearity of, object translation/rotation by adding extra acceleration are called easing functions.

Add the following code just above SplitterCallBack() in Splitter.h:

Code: [Select]
// Easing equation for an exponential (2^^t) ease-in/out: accelerate until halfway, then decelerate.
__forceinline float easeInOutExpo(float t) {
    if (t == 0) return 0;
    if (t == 1) return 1;
    t *= 2;
    if (t < 1) return 0.5f * powf(2, 10 * (t - 1));
    return 0.5f * (-powf(2, -10 * (t - 1)) + 2);
}

Then use the following code instead of existing case WM_NCLBUTTONDBLCLK in SplitterCallBack():

Code: [Select]
    case WM_NCLBUTTONDBLCLK:
        RightPanelSize = ClientW - ClientWGL + SPLITTER_WIDTH;
        GetViewRect(GetParent(hWnd), &tmi);
        w = Width(tmi);
        h = Height(tmi);
        WasXoffset = gP.splitXoffset;
        nStep = 15;
        if (GetWindowPlacement(gP.hMain, &wp)) {
            if (wp.showCmd == SW_SHOWMAXIMIZED) { nStep *= 2; }
        }
        void gl_DrawScene();
        if (gP.splitXoffset == 0) { // Move to center
            gP.splitXoffset = (w - SPLITTER_WIDTH) / 2;
            x = 0;
            while (x < gP.splitXoffset) {
                long xPos = (long)(easeInOutExpo((float)x / (float)gP.splitXoffset) * gP.splitXoffset);
                MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
                MoveSplitter();
                gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
                glFinish(); // Complete redraw first then proceed
                x += nStep;
            }
        } else { // Dock to the right
            x = WasXoffset;
            gP.splitXoffset = 0;
            while (x > 0) {
                long xPos = (long)(easeInOutExpo((float)x / (float)WasXoffset) * WasXoffset);
                MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
                MoveSplitter();
                gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
                glFinish(); // Complete redraw first then proceed
                x -= nStep;
            }
        }
        MoveWindow(gP.hGL, -gP.splitXoffset, 0, w, h, TRUE);
        MoveSplitter();
        skSetAnchorCtrl(gP.hGL, ANCHOR_HEIGHT_WIDTH);
        gP.bRedraw = TRUE; // Redraw the OpenGL scene
        nRet = 1;
        break;

Please let me know if splitter movement and gP.hGL redraw run smoothly enough for you.
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 #544 on: January 24, 2019, 08:41:24 am »
That seems to work fine by me, thanks!

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

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #545 on: January 24, 2019, 12:51:03 pm »
Good to hear that!

Then let's eliminate the gP.hGL flicker along the left border of gP.hMain when dragging the splitter in the same manner because it annoys me a lot under my W7. (I'm not sure though if you're seeing it too under your W10 but I'm too lazy to check it on my own W10 box)

0. First of all, delete the line with the forward declaration of void gl_DrawScene(); from within your existing case WM_NCLBUTTONDBLCLK: code in SplitterCallBack().

1. Instead, put it somewhere on top of SplitterCallBack(), e.g. like this:

........
void gl_DrawScene(); // Forward declaration

LRESULT CALLBACK SplitterCallBack(IN HWND hWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) {
    LRESULT nRet = 0; // Do not stop the event processing in GDImage.
........


2. Finally, patch your case WM_MOVING: in SplitterCallBack() as follows:

    case WM_MOVING: // Keep the window into the working area
        lpw = (RECT*) lParam;

        RightPanelSize = ClientW - ClientWGL + SPLITTER_WIDTH;
        GetWindowRect(GetParent(hWnd), &tmi);
        w = Width(tmi) - (skGetSystemMetrics(SK_CXFRAMELEFT) + skGetSystemMetrics(SK_CXFRAMERIGHT) + RightPanelSize) - SPLITTER_WIDTH;
        h = Height(tmi) - (skGetSystemMetrics(SK_CYCAPTION) + skGetSystemMetrics(SK_CYMENU) + skGetSystemMetrics(SK_CYFRAMEBOTTOM));

        tmi.left += skGetSystemMetrics(SK_CXFRAMELEFT);// - SPLITTER_WIDTH;
        tmi.top += skGetSystemMetrics(SK_CYCAPTION) + skGetSystemMetrics(SK_CYMENU);
        tmi.right -= skGetSystemMetrics(SK_CXFRAMERIGHT) + RightPanelSize;
        tmi.bottom -= skGetSystemMetrics(SK_CYFRAMEBOTTOM);
        GetWindowRect(hWnd, &rc);

        if (lpw->top < tmi.top) {
            lpw->top = tmi.top;
            lpw->bottom = lpw->top + Height(rc);
        }
        if (lpw->left < tmi.left) {
            lpw->left = tmi.left;
            lpw->right = lpw->left + Width(rc);
        }
        if (lpw->right > tmi.right) {
            lpw->right = tmi.right;
            lpw->left = lpw->right - Width(rc);
        }
        if (lpw->bottom > tmi.bottom) {
            lpw->bottom = tmi.bottom;
            lpw->top = lpw->bottom - Height(rc);
        }
        ZI_UseWinLIFTbackground(hWnd, TRUE, TRUE);
        gP.splitXoffset = tmi.right - lpw->left - SPLITTER_WIDTH;

        MoveWindow(gP.hGL, -gP.splitXoffset, 0, w, h, TRUE);
        skSetAnchorCtrl(gP.hGL, ANCHOR_HEIGHT_WIDTH);

        gP.bRedraw = TRUE; gl_DrawScene();
        glFinish();
// Complete redraw first then proceed (eliminate gP.hGL flicker)

        nRet = 1;
        break;


Now both the animated and manual dragging of splitter together with gP.hGL is going to be absolutely smooth, at least for me under my W7.
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 #546 on: January 24, 2019, 03:08:47 pm »
Done, but to say the truth that doesn't make any difference by me on W10.

They have done many changes into DWM between W7 and W10.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #547 on: January 24, 2019, 03:32:10 pm »
Not so for me:
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 #548 on: January 24, 2019, 05:16:53 pm »
Ok, i can see the difference, i shall have to try on my Intel.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #549 on: January 24, 2019, 05:42:43 pm »
On my intel the old WM_NCLBUTTONDBLCLK code was working fine, while easeInOutExpo is freezing the application  :-[

Added
The While loop for Dock to the right, seems to work for ever...
« Last Edit: January 24, 2019, 05:47:12 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 #550 on: January 24, 2019, 06:43:07 pm »
What about case WM_MOVING on your Intel? Does it work as expected?
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 #551 on: January 24, 2019, 07:42:44 pm »
Yes WM_MOVING, is working as expected.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #552 on: January 24, 2019, 07:57:40 pm »
What happens if you put a glFlush(); glFinish(); pair of calls immediately before, rather than after, the gl_DrawScene() call?

I don't think the use of easeInOutExpo() may affect the loop in any way. Its code is clear and concise and shouldn't cause any problems.


[ADD] My initial code works flawlessly on my AMD/ATi box.
« Last Edit: January 24, 2019, 08:40:02 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)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #553 on: January 24, 2019, 08:59:00 pm »
Still the same

see the attached screen shot

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

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Early WIP on v2.55
« Reply #554 on: January 24, 2019, 09:17:12 pm »
glFinih();
is causing the havoc

If i use only glFluch();
then no problem.

Here is the code that works on my Intel

Code: [Select]
    case WM_NCLBUTTONDBLCLK:
        RightPanelSize = ClientW - ClientWGL + SPLITTER_WIDTH;
        GetViewRect(GetParent(hWnd), &tmi);
        w = Width(tmi);
        h = Height(tmi);
        WasXoffset = gP.splitXoffset;
        nStep = 15;
        if (GetWindowPlacement(gP.hMain, &wp)) {
            if (wp.showCmd == SW_SHOWMAXIMIZED) { nStep *= 2; }
        }
        if (gP.splitXoffset == 0) { // Move to center
            gP.splitXoffset = (w - SPLITTER_WIDTH) / 2;
            x = 0;
            while (x < gP.splitXoffset) {
                long xPos = (long)(easeInOutExpo((float)x / (float)gP.splitXoffset) * gP.splitXoffset);
                MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
                MoveSplitter();
                gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
                glFlush();
                x += nStep;
            }
        } else { // Dock to the right
            x = WasXoffset;
            gP.splitXoffset = 0;
            while (x > 0) {
                long xPos = (long)(easeInOutExpo((float)x / (float)WasXoffset) * WasXoffset);
                MoveWindow(gP.hGL, -xPos, 0, w, h, TRUE);
                MoveSplitter();
                gP.bRedraw = TRUE; gl_DrawScene(); // Let the animation play while moving the window
                glFlush();
                x -= nStep;
            }
        }
        MoveWindow(gP.hGL, -gP.splitXoffset, 0, w, h, TRUE);
        MoveSplitter();
        skSetAnchorCtrl(gP.hGL, ANCHOR_HEIGHT_WIDTH);
        gP.bRedraw = TRUE; // Redraw the OpenGL scene
        nRet = 1;
        break;
    }
Patrice
(Always working with the latest Windows version available...)