Author Topic: Animated Backgrounds?  (Read 52576 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Animated Backgrounds?
« Reply #15 on: May 21, 2019, 09:46:05 am »
- Canonical
Is gorgeous, except when we get too close from the ground.

- RollerCoaster
Same as above, but my preference goes to canonical.

Thank you very much for your hard work, much appreciated !

Here are a few other glsl web sites:
http://glslsandbox.com/
https://www.vertexshaderart.com/
https://shaderfrog.com/

And more about OpenGL shaders there:
https://github.com/radixzz/awesome-glsl
« Last Edit: May 21, 2019, 01:51:47 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #16 on: May 22, 2019, 11:34:50 am »
Thanks for the links, my friend! :)

Well, so far the Caribbean Pirates shader seems the absolute best candidate for becoming an animated background.

It is completely if-less and very, very fast. My GPU typical usage stays as low as only 5 to 7% at 60 FPS full-screen! :o :D

My mods:
  • fade in/out/pause disabled
  • stars noise texture reworked to become 4 times finer
  • moonscape programmatic "texture" brightness and scale readjusted accordingly.
Enjoy! 8)
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: Animated Backgrounds?
« Reply #17 on: May 22, 2019, 12:11:18 pm »
Very good, thank you !

Do you think that would requires much changes into OR, to add background animations.
And what would be the mtl syntax.
#anim shaderfile

or just the existing
#wallpaper shaderfile.shd
with the shader extension.

PS: I also thought of using PNG animations, like in my eye candie RedHawk project.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #18 on: May 22, 2019, 01:48:18 pm »
Always at your service, my friend! :D

No, there aren't going to be many changes; just a few simple manipulations:
  • load shader textures into an extra tex array once an animated background shader is selected from the list
  • setup TUs and bind uniforms exactly as in the FBSL script Init() function below the texture loading code
  • render the animated background frame with an own short display list invoking the vertex and pixel shaders
  • unbind textures and uniforms to reuse the TUs in our FFP or PPL render procs as usual
  • delete textures from the extra tex array when another wallpaper is selected.
I think your animated PNGs won't need many changes either except creating separate textures for each PNG frame and sync'ing their change with our main timer in a controlled fashion to achieve the expected animation speed. I think you can do it even without my assistance. You can even reuse the existing background display list.  :)

Regarding the #meta, I believe we can reuse the existing #wallpaper for your animated PNGs but add an extra parameter ani preceding the PNG file name OR even have no special parameter at all if you can sense automagically if a PNG is animated or not.

Animated shader files should IMHO have canonical .fs extensions (they lack a common vertex shader part and therefore shouldn't be called .glsl files), preserve their attribution blurbs, and be put in the common \Resource folder together with the associated textures. Shader recompilation and texture loading can be done in a separate worker thread (OpenGL is a multithreaded framework, after all) so as not to stall the current display activity. I think they would require some separate #meta to enumerate all the associated texture assets.


(I'm currently working on your favorite Oblivion 166 drone and will come back when ready or failed :D)
« Last Edit: May 22, 2019, 01:50:54 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: Animated Backgrounds?
« Reply #19 on: May 22, 2019, 02:31:14 pm »
Yes, i can detect automatically if a png file is an animation or not.

Here is a couple of animations i was thinking about
« Last Edit: May 22, 2019, 04:40:08 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #20 on: May 22, 2019, 05:59:55 pm »
They're looking cool but are they going to be as attractive when resized? ::) The wallpapers should be ideally hires 1980x1050 to avoid magnification at all...

OK here comes your favorite nursery beanbag. ;D

The shader appears quite fast at 30FPS. My GPU load is from 30% to 75% full screen, depending on the visible size of the drone. 60FPS load my GPU to 100% like the Shadertoy original in the browser.

What I did was as follows:
  • Disabled the noise texture in iChannel0: it had absolutely no visible effect either on Shadertoy or in the demo
  • Changed the original cubemap in iChannel3 to an ordinary map. We cannot yet properly load or display cubemaps because we have no skyboxes or skydomes in OR.
  • Adjusted shader parameters to accept the reworked map. It is responsible for cloudy sky illumination. It is not as prominent as the original cubemap, and it obscures the terrain when high up in the sky a little stronger than optimal. But it is quite noticeable and effective when the drone is on the ground.
Overall, the demo is not so impressive as the original due to the lack of voice synthesis. I wish I knew exactly how they handle sound synthesis and music. Perhaps some day I'll be able to understand enough of ObjectiveC illegible syntax to mimic it in OR.

Enjoy! :)
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: Animated Backgrounds?
« Reply #21 on: May 22, 2019, 06:53:55 pm »
My friend, you did a tremendous work with it, even if it is not really suitable to use with the existing oblivion models (clouds, or marching landscape, would be better)

Congratulations !

As you know i have some experience with Bass.dll audio, this is something i can think about once we have glsl/fs in OR.
We probably can do the same than with my existing OpenGL plugins.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #22 on: May 22, 2019, 07:32:20 pm »
I'm glad you like it, my friend! :)

What concerns bass.dll (not sound synthesis but just playback of music etc.), I saw their music sound shaders and I think I understand how the thing actually works under the hood.

Modern bass.dll is able to output in real time an array of up to 1024 audio samples of current music, each in its very narrow frequency band pretty much the same as an analog band-pass filter does. Each sample carries its own volume level and thus the array may be used for fine simulation of a spectrum analyzer.

The set of array samples should constitute the X axis of a 1024x1024 px large 2D bitmap. The Y axis should represent a proportionately scaled volume level of the loudest sample, i.e. the max allowable volume, in the band-pass filter bands. Such a BMP "snapshot" should be taken 30 or 60 times per second (as the CPU/GPU/bass.dll audio buffer permit), converted into an OpenGL 2D texture, and bound to some iChannelX sampler like an ordinary 2D texture would. The texture is then sampled by the graphics shader to modulate its other parameters, etc.

Actually, the number of band samples in the bitmap may be much lower if we aren't going to simulate a full-blown spectrum analyzer. E.g. there may be only 4 sample bands in it, say, some high frequency band, one high-mid, one low-mid, and one mid-bass. And only those 4 samples are going to be used for graphics shader modulation. Given there are 256 gradations of volume level in a sample, the 4 samples can be packed a 1x1 px large 32-bit BMP/texture. BMP creation, BMP-to-texture conversion, and sampling of such a tiny "texture" can run lightning fast and easy for the GPU.

Or you can just take a combined volume output of bass.dll and create a 1x1 px large 8-bit 256-level grayscale texture from it to modulate you graphics to the overall music beat.

BTW video capture is done in a similar way but the number of samples depends on the exact current video frame size, and samples are taken and converted to BMPs at the exact current video frame frequency. There are lots of video shaders on Shadertoy that implement such technique.

Now, the question. Do you think you can provide me with a working scheme to create such BMPs on the fly based on bass.dll's band-pass output as I described above? I can then step in and add texture creation and manipulation code for us to be able to modulate our 2D and 3D display in OR with the sweet sounds of music we like. :)
« Last Edit: May 22, 2019, 09:15:34 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: Animated Backgrounds?
« Reply #23 on: May 22, 2019, 09:23:00 pm »
This is what i am using in MBox64   8)

Code: [Select]
const void* BassChannelGetWimData() {
    static float fft[256];
    memset(&fft[0], 0, sizeof(float)* 256);
    DWORD hChannel = gP.channelrec;
    if (gB.channel) { hChannel = gB.channel; }
    if (hChannel) { long nRet = BASS_ChannelGetData(hChannel, &fft[0], 1024); }
    return &fft[0];
}

void ColorInit() {
    WCHAR zResource[MAX_PATH];
    Path_Combine(zResource, EXEresource(), L"palette.png");
    long bmW = 0, bmH = 0;
    HBITMAP hBitmap = ZI_CreateBitmapFromFile(zResource, bmW, bmH);
    if (bmW > 33) {
        BITMAP bm; GetObject(hBitmap, sizeof(bm), &bm);
        BYTE* pBits = (BYTE*) bm.bmBits;
        for (long P = 0; P < 34; ++P) {
            gColor[P] = skARGB(pBits[3], pBits[2], pBits[1], pBits[0]);
            pBits += 4;
        }
    } else {
        gColor[0]  = 0;
        gColor[1]  = skARGB(255, 3,95,250);
        gColor[2]  = skARGB(255, 3,97,250);
        gColor[3]  = skARGB(255, 4,101,250);
        gColor[4]  = skARGB(255, 4,104,250);
        gColor[5]  = skARGB(255, 4,108,250);
        gColor[6]  = skARGB(255, 4,112,249);
        gColor[7]  = skARGB(255, 5,116,249);
        gColor[8]  = skARGB(255, 5,121,249);
        gColor[9]  = skARGB(255, 6,126,249);
        gColor[10] = skARGB(255, 6,130,249);
        gColor[11] = skARGB(255, 6,135,249);
        gColor[12] = skARGB(255, 7,139,249);
        gColor[13] = skARGB(255, 7,143,248);
        gColor[14] = skARGB(255, 7,147,248);
        gColor[15] = skARGB(255, 8,150,248);
        gColor[16] = skARGB(255, 8,154,248);
        gColor[17] = skARGB(255, 8,155,248);
        gColor[18] = skARGB(255, 11,158,248);
        gColor[19] = skARGB(255, 17,162,248);
        gColor[20] = skARGB(255, 24,166,249);
        gColor[21] = skARGB(255, 32,171,249);
        gColor[22] = skARGB(255, 41,176,249);
        gColor[23] = skARGB(255, 50,183,250);
        gColor[24] = skARGB(255, 59,189,250);
        gColor[25] = skARGB(255, 70,195,250);
        gColor[26] = skARGB(255, 80,201,251);
        gColor[27] = skARGB(255, 91,207,251);
        gColor[28] = skARGB(255, 100,213,252);
        gColor[29] = skARGB(255, 109,219,252);
        gColor[30] = skARGB(255, 118,224,252);
        gColor[31] = skARGB(255, 126,229,252);
        gColor[32] = skARGB(255, 133,233,253);
        gColor[33] = skARGB(255, 136,237,253);
    }
    DeleteObject(hBitmap);
}

long LevelColor(IN long nParam) {
    long nInt = min((long) (sqrt(nParam) * 8), 33);
    if (nInt < 1) { nInt = 1; }
    return gColor[nInt];
}

const int BBP_RENDER      = 1;       // Render the scene.
const int BBP_CREATE      = 2;       // Retrieve Title, Name, Version, Render mode.
const int BBP_INIT        = 3;       // Init the OpenGL.
const int BBP_SIZE        = 4;       // The size of the control has changed.
const int BBP_KEYBOARD    = 5;       // All keyborad message.
const int BBP_MOUSE       = 6;       // All mouse messages.
const int BBP_DESTROY     = 7;       // Free Up resources.

const int BBP_GDIPLUS     = 0;       // GDImage GDIPLUS compatible mode.
const int BBP_OPENGL      = 1;       // OpenGL mode.
const int BBP_DIRECTX     = 2;       // DirectX mode (for future extension).

const int BBP_SUCCESS     = 0;
const int BBP_ERROR       = -1;

struct BBPLUGIN {
    UINT msg;                   // The plugin's message (see above constant list).
    HWND parent;                // The parent window handle.
    HDC dc;                     // The parent window DC (while in play mode).
    HGLRC rc;                   // The parent OpenGL RC (while in play mode).
    WORD lpeak;                 // The left audio channel peak value (while in play mode).
    WORD rpeak;                 // The right audio channel peak value (while in play mode).
    char title[32];             // Plugin's name or title.
    char author[64];            // Plugin's author name.
    DWORD version;              // LOWRD major, HIWRD minor.
    long renderto;              // BBP_GDIPLUS, BBP_OPENGL, BBP_DIRECTX.
    long backargb;              // Default ARGB color background.
    float* fftdata;             // dword pointer to the FFT() as single array.
    WORD fftsize;               // Size of the FFT array.

    UINT winmsg;                // True Windows message.
    WPARAM wparam;              // wParam
    LPARAM lparam;              // lParam

    short* wimdata;             // dword pointer to the wave MM_WIM_DATA.
    QWORD medialength;          // Media length.
    QWORD mediapos;             // Media pos.

    char reserved[50];          // Reserved for future extension.
} ;                             // Structure size = 256

WORD SolvePeak(IN WORD nValue, IN WORD nTotal) {
    WORD nRet = 0;
    if (nTotal) { nRet = (nValue * 100) / nTotal; }
    return nRet;
}

FARPROC BBP_ProcHandle(IN FARPROC hProc, IN long RW) {
    static FARPROC WasHproc;
    if (RW) { WasHproc = hProc; }
    return WasHproc;
}

long BBP_Plugin(OUT BBPLUGIN &BBP) {
    long nRet = BBP_ERROR;
    if (IsWindow(gP.hGL)) {
        HGLRC glRC = (HGLRC) (ZI_GetProperty(gP.hGL, ZI_GLRC));
        if (glRC) {
            long_proc (BBPLUGIN*);
            zProc hProc = (zProc) BBP_ProcHandle(0, 0);
            if (hProc) { nRet = hProc(&BBP); }
        }
    }
    return nRet;
}

//long BBProc (OUT BBPLUGIN &BBP);
void BBP_Detached(IN HWND hWnd, OUT HMODULE &hLib) {
    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
    if (hLib) {
        BBP.msg = BBP_DESTROY;
        BBP.parent = hWnd;
        BBP_Plugin(BBP);
        //BBProc(BBP);

        // use brute force to delete any existing texture
        long Tmax = 64;
        long* DT = new long[Tmax]; memset(DT, 0, Tmax);
        for (long K = 0; K < Tmax; K++) { DT[K] = K; }
        glDeleteTextures(Tmax, (GLuint*)&DT[0]);
        delete[] DT;

        BBP_ProcHandle(0, 1); FreeLibrary(hLib); hLib = 0;
    }
}

WCHAR* BBP_ActivePlugin(IN WCHAR* sPluginName, IN long RW) {
    static WCHAR sWasPluginName[MAX_PATH];
    if (RW) { wcscopy(sWasPluginName, sPluginName); }
    return sWasPluginName;
}

void BBP_Reset() {
    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
    BBP.msg = BBP_CREATE;
    BBP_Plugin(BBP);

    WCHAR title[32]; ClearMemory(title, sizeof(title));
    WCHAR author[64]; ClearMemory(author, sizeof(author));
    MultiByteToWideChar(CP_ACP, 0, (char*)BBP.title, lstrlenA(BBP.title), title, 32);
    MultiByteToWideChar(CP_ACP, 0, (char*)BBP.author, lstrlenA(BBP.author), author, 64);
    wcscopy(gB.plugintitle, title); Add_Str(gB.plugintitle, L" by "); Add_Str(gB.plugintitle, author);

    //BBProc(BBP);
    if (BBP.renderto == BBP_OPENGL) {

        glDisable(GL_BLEND);
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHT0);
        glDisable(GL_LIGHT1);
        glDisable(GL_LIGHT2);
        glDisable(GL_LIGHT3);
        glDisable(GL_LIGHT4);
        glDisable(GL_LIGHT5);
        glDisable(GL_LIGHT6);
        glDisable(GL_LIGHT7);
        glDisable(GL_LIGHTING);
        glDisable(GL_COLOR_MATERIAL);
        glDisable(GL_ALPHA_TEST);
        glDisable(GL_NORMALIZE);

        glDisable(GL_LINE_SMOOTH);

        glGetError();

    }
}

// Load/unload plugin DLL to/from memory
long BBP_LoadPlugin(IN HWND hWnd, IN WCHAR* zPlugin) {
    static WCHAR zLastPlugin[MAX_PATH] = { 0 };
    static HMODULE hLib;
    long nDone = BBP_ERROR;
    long nLen = lstrlen(zPlugin);
    if ((nLen) && (_wcsicmp(zPlugin, zLastPlugin) != 0)) {
        if (FileExist(zPlugin)) {
            BBP_Detached(hWnd, hLib);
            hLib = LoadLibrary(zPlugin);
            if (hLib) {
                FARPROC hProc = GetProcAddress(hLib, "BBProc");
                if (hProc) {
                    BBP_ProcHandle(hProc, 1);
                    wcscopy(zLastPlugin, zPlugin);
                    BBP_ActivePlugin(zLastPlugin, 1);
                    // Reset plugin to default
                    BBP_Reset();
                    nDone = BBP_SUCCESS;
                }
            }
        }
    } else if (nLen == 0) {
        BBP_Detached(hWnd, hLib);
    }
    return nDone;
}

void ResizeOpenGL() {
    if (gP.pluginloaded) {
        if (IsWindow(gP.hGL)) {
            BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
            BBP.msg          = BBP_SIZE;
            BBP.parent       = gP.hGL;
            BBP_Plugin(BBP);
            //BBProc(BBP);
        }
    }
}

void RenderOpenGL(IN DWORD nLevel, IN short* pInt) {

    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));

    HDC glDC = (HDC) (ZI_GetProperty(gP.hGL, ZI_GLDC));
    HGLRC glRC = (HGLRC) (ZI_GetProperty(gP.hGL, ZI_GLRC));
    if (glRC) {

        BBP.msg          = BBP_RENDER;
        BBP.parent       = gP.hGL;
        BBP.dc           = glDC;
        BBP.rc           = glRC;
        BBP.lpeak        = SolvePeak(LOWORD(nLevel), 128);
        BBP.rpeak        = SolvePeak(HIWORD(nLevel), 128);
        BBP.backargb     = 0;
        BBP.fftdata      = (float*) BassChannelGetData();
        BBP.fftsize      = 256;
        BBP.medialength  = gB.medialength;
        BBP.mediapos     = gB.mediapos;
        BBP.wimdata      = pInt;

        BBP_Plugin(BBP);
        //BBProc(BBP);

        // Refresh display
        SwapBuffers(glDC);

        InvalidateRect(gP.hGL, NULL, 0);
        UpdateWindow(gP.hGL);
    }
    ReleaseDC(gP.hGL, glDC);
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #24 on: May 22, 2019, 10:04:10 pm »
OK Patrice, not so fast -- one step at a time.

From what I can see in the code, I'm now practically interested only in BassChannelGetWimData():

1. What is 1024 in BASS_ChannelGetData(hChannel, &fft[0], 1024)? Is it 1024 bytes of data or 1024 band-pass samples?

2. If those are bytes, then does it mean you're getting only 256 floating-point volume value samples for a max 256-band filter?

3. If yes, then is it the max number of bands you can get from bass.dll at any one time?

4. Can you get only 4, 8, 16, etc. volume value samples at frequencies of your own choice?

Please answer each of the questions. My following questions and wishes will depend on the fullness of your answers.
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: Animated Backgrounds?
« Reply #25 on: May 22, 2019, 11:36:49 pm »
First, you must understand that Bass.dll is build upon the Windows waveform audio API.

Have a look at MSDN there for the MM_WIM_DATA message
https://docs.microsoft.com/en-us/windows/desktop/multimedia/mm-wim-data

Tomorrow, I shall try to find an application i wrote long ago, that was using directly the core audio API.

Added:
I think to remember that its name was audiocap ;)
https://forum.pcsoft.fr/en-US/pcsoft.us.windev/7156-audio-capture-demo/read.awp
http://www.jose.it-berater.org/smfforum/index.php?topic=1504.msg4734#msg4734
The oscilloscope should do what you are looking for.

I shall send you the PowerBASIC DLL source code, once i could remember where i saved it  ???
« Last Edit: May 22, 2019, 11:48:21 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #26 on: May 23, 2019, 12:03:57 am »
Thank you, Patrice.

I am able to build it all by myself -- bit by bit -- from ground up reading up on modern bass.dll user interface and API. I used to develop audio grabbing and filtering SW too, using my FBSL and older versions of bass.dll and other audio processing libraries, quite some time ago. Granted, it wasn't as beautifully presentable as your media players and video plugins and stuff, but it was usable all right and it did its job.

But that means I'll have to put shaders and OR aside.

I was hoping I could use your skills and knowledge to get answers to my questions quicker so as not to stall my other activities. I was also hoping you could implement the simpler GDI (not GPI+/GDImage -- that's unnecessary and actually detrimental) part of work without my interference but following my advice on what we need in OR rather than what you have in your players and visualizers.

I was wrong.

No big deal. I remove this question from the agenda until I'm through with your (still far from exhaustive) shader list.



P.S. If you're willing to help me out, give me a workable example code for any of you linear (spectrum analyzer-style) visualizers if you have one, based on bass.dll. Not just a plugin abortion with public bells and whistles, but the core engine with the routines to set up bass.dll to read in an audio file, fill its audio buffers, adjust buffer size based on the file sample rate, get a copy of audio buffer chunks in a required format, and the most important of all, split the buffer spectrum at a given point in time into an array of samples taken at given frequencies within the spectrum to control how high up each frequency column in the spectrum analyzer should go at this particular point in time:



This array of frequency samples is the core of structured data to create a 2D bitmap ("bitmap" means a "two dimensional array of structured data bits", not a picture or photo or drawing or painting) that can be converted/"loaded" into an OpenGL texture to be usable in an ordinary texture unit even though this "texture" is not an "image" in the classical sense of both words.

P.P.S.
Quote
The oscilloscope should do what you are looking for.

Are you mocking me or what? Do you think I can learn a single bit of useful information from a zip that contains nothing but PR blurbs and a bunch of binary files?

Are you also going to suggest I should buy and study Windev just to scratch up a trivial WinAPI/GDI script to get me a handful of meaningful data bits from an audio file to create a grayscale BMP?! :-[
« Last Edit: May 23, 2019, 01:41:25 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)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #27 on: May 23, 2019, 02:46:05 am »
Two Oblivion HUDs added below. Both run at 30FPS and have an optional background texture added. You may use any PNG that's named target.png or delete/rename the texture altogether to have a plain black background like on Shadertoy. No other adjustments needed.

HUD proper runs for me at 15% GPU usage full screen, and Radar, at up to 30%.

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: Animated Backgrounds?
« Reply #28 on: May 23, 2019, 08:08:02 am »
Quote
Are you mocking me or what? Do you think I can learn a single bit of useful information from a zip that contains nothing but PR blurbs and a bunch of binary files?

I asked you to give me some time to find the source code, audiocap is easy to understand because it is based directly onto the native wavefront API.

See the attached complete PowerBASIC source code , provided without bells and whistles.

The native API calls are within  AudioCap32.inc
the important Wim data is stored in @pWaveHdr.lpData (pointer to the waveform buffer, WAVEHDR PTR).
The buffer size relies on how you have used WaveInOpen, in the example "Stereo 44100 16-bit" and the DeviceToUse (stereomix or microphone).

The waveform buffer is decoded and rendered into DrawWave using a gain within 1-3, because sometime the signal could be very flat.
In BassBox i am using sqr to enhance it.

I am limiting myself to a color range of 32 values, generaly the lowest one being blue, and the higher bright red (see levelColr).

DrawWave is the section where you must build your bitmap to match your preference and create the texture, but this could also be used to change the size of the OpenGL components and their colors.

With Bass.dll BASS_DATA_FFT512, returns 256 floating point value, that is the same to what i am using with the core API.
You can use it like this
Code: [Select]
FUNCTION BassChannelGetData () AS DWORD
    DIM fft(255) AS STATIC SINGLE
    LOCAL nRet AS LONG
    RESET fft()
    IF gnAudioPause = %FALSE THEN
       IF gnAudioChannel THEN
          nRet = BASS_ChannelGetData(gnAudioChannel, VARPTR(fft(0)), %BASS_DATA_FFT512)
       END IF
    END IF
    FUNCTION = VARPTR(fft(0))
END FUNCTION
further details explained there:
http://www.un4seen.com/doc/#bass/BASS_ChannelGetData.html

The main advantage of Bass.dll over the core API, is that it is able to use most of the popular audio format.
But the only thing understood by the API is wavefront, this works like the different graphic formats ultimatly converted to bitmap.


Quote
But that means I'll have to put shaders and OR aside.
Please no, one step after another...
« Last Edit: May 23, 2019, 09:34:24 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Animated Backgrounds?
« Reply #29 on: May 23, 2019, 08:17:19 am »
The two Oblivion HUDs, are absolutly perfect !!!

I am thrilled to see them runing in OR  8)
Patrice
(Always working with the latest Windows version available...)