Author Topic: Animated Backgrounds?  (Read 52562 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Animated Backgrounds?
« Reply #180 on: January 01, 2020, 05:34:20 pm »
Here is a video link, to show you something i have been playing with  :o

video

The idea would be to change on the fly the ambient lighting, perhaps in Mobj_lightSettings,
so far the video has been done on a change done directly into
drawUsingProgrammablePipeline
using this piece of blue code that should replace the line in red.

            //float diffuse[4];
            //diffuse[0] = pMaterial->diffuse[0];
            //diffuse[1] = pMaterial->diffuse[1];
            //diffuse[2] = pMaterial->diffuse[2];
            //diffuse[3] = pMaterial->diffuse[3];
            //if (gB.channel) {
            //    if (gP.bSyncAudio) { // PATH: 12-25-2019
            //        DWORD nLevel = BASS_ChannelGetLevel(gB.channel);
            //        float rPulse = (max(LOINT(nLevel), HIINT(nLevel)) / 20000.0f);
            //        diffuse[0] = rPulse;
            //        diffuse[1] = rPulse;
            //        diffuse[2] = rPulse;
            //    }
            //}
            //glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse[0]);

            glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pMaterial->diffuse);
            glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pMaterial->specular);
            glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pMaterial->emissive); // ML 01-02-2018: glow
            glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, pMaterial->shininess * rShine)
« Last Edit: January 01, 2020, 05:37:33 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #181 on: January 01, 2020, 05:59:37 pm »
Hehe, the idea is wonderful!

In fact, the ability to modulate anything with anything (e.g. an oscillator's input frequency with another frequency and/or its output phase and/or amplitude with some other phase and/or amplitude) was how music synthesizers were invented! :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
Modulating the emissive channel
« Reply #182 on: January 03, 2020, 03:55:00 pm »
I am testing the new #pulse meta with individual mesh, applying the modulation to the emissive channel.

See the changes i have done into sync.zip,
search for:
// PAT: 01-03-2020 Pulse light on sound modulation
and try it with the new attached HAL_9000.zip

Check with different audio tracks, and tell me what you think.

I am using an extra parameter to adjust the modulation level.

#pulse 1.0 (default) to 4.5 or more
the higher = the less sensitive, because of this computation
float rPulse = (max(LOINT(nLevel), HIINT(nLevel)) / (20000.0f * pMaterial->rPulseLevel));

Of course we could use the same for the other parameters...
« Last Edit: January 03, 2020, 05:19:41 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #183 on: January 03, 2020, 08:15:55 pm »
Please update this function in mobj.h that somehow escaped sync'ing:

void Mobj_destroy() {
    gM.bHasPositions = false;
    gM.bHasTextureCoords = false;
    gM.bHasNormals = false;
    gM.bHasTangents = false;

    gM.numberOfVertexCoords = 0;
    gM.numberOfTextureCoords = 0;
    gM.numberOfNormals = 0;
    gM.numberOfTriangles = 0;
    gM.numberOfMaterials = 0;
    gM.numberOfMeshes = 0;
    gM.numberOfTextures = 0;

    gM.center[0] = gM.center[1] = gM.center[2] = 0.0f;
    gM.pose[0] = gM.pose[1] = gM.pose[2] = gM.pose[3] = gM.pose[4] =
        gM.pose[5] = gM.pose[6] = gM.pose[7] = gM.pose[8] = 0.0f;


    gM.rWidth = gM.rHeight = gM.rDepth = gM.rExtent = 0.0f;

    gsm_directoryPath.clear();

    gtm_meshes.clear();
    gtm_materials.clear();
    gtm_vertexBuffer.clear();
    gnm_indexBuffer.clear();
    gnm_attributeBuffer.clear();

    grm_vertexCoords.clear();
    grm_textureCoords.clear();
    grm_normals.clear();

    m_materialCache.clear();
    m_vertexCache.clear();

    deleteVBOs();
}


and also in mobj.h and renderers.h, please change all the remaining occurrences of true and false to TRUE and FALSE.


What regards light pulsing, HAL seems to be working but its implementation is not as elegant as the mainframe one. Can you better send me Robots2, the one that was there in your initial pulsed video? That model looked more coherent to my mind.
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 #184 on: January 03, 2020, 08:51:50 pm »
TRUE/FALSE have been changed everywhere, and Mobj_Destroy() has been updated, thank you!

Quote
Can you better send me Robots2, the one that was there in your initial pulsed video?
This one was using diffuse rather than emissive.

I could add an extra parameter in the material file to select between KD, KS, KE and use a switch case into the PulseLight procedure.

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

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #185 on: January 03, 2020, 09:22:23 pm »
Actually, you can take any light component(s) as an input source to pulse but send the resultant pulse e.g. into the emissive component for output.

There are many variants what can be pulsed and where it can be output to. Have you tried to send the pulse (possibly overbrightened) to the specular component just to see what happens? ;)
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 #186 on: January 04, 2020, 03:44:55 pm »
OK, here is the new release.
Now the new mtl parameters per material are
#pulse_A float_value (AMBIENT)
#pulse_D float_value (DIFFUSE
#pulse_S float_value (SPECULAR)
#pulse_E float_value (EMISSIVE)

New Robots2.mtl
Code: [Select]
#Light frontAmbient 0 0 0
#Light frontDiffuse 165 165 165
#Light frontSpecular 127 127 121

#Light leftAmbient 0 0 0
#Light leftDiffuse 127 127 121
#Light leftSpecular 47 79 79

#Light rightAmbient 0 0 0
#Light rightDiffuse 127 127 121
#Light rightSpecular 112 128 144

#Light topAmbient 0 0 0
#Light topDiffuse 25 25 112
#Light topSpecular 1 0 0

#multilight
#straylight 65
#wallpaper AniLights.fs
#playaudio Most_Geometric_Person.mp3 50 loop sync
#demo

newmtl mat_01
#rotate 0.05 0 0 1 359 361 0
#pulse_E 1
Ka 0.01 0.01 0.01
Kd 0.40000000596046 0.40000000596046 0.40000000596046
Ks 1 1 1
Ke 0.4 0.4 0.4
map_Ka mat_01_AO.png
map_Kd mat_01_ALB.png
map_bump mat_01_NRM.png
map_Ke mat_01_EMS.png
map_Ns mat_01_roughness.png
Ns 512
illum 2

newmtl mat_02
#rotate 0.05 0 0 1 359 361 0
Ka 0.01 0.01 0.01
Kd 0.40000000596046 0.40000000596046 0.40000000596046
Ks 1 1 1
map_Ka mat_02_AO.png
map_Kd mat_02_ALB.png
map_bump mat_02_NRM.png
map_Ns mat_02_roughness.png
Ns 512
illum 2

newmtl mat_03
#rotate -0.1275 0 1 0 0 0 0 1
#pulse_D 1
##pulse_E 2
Ka 0.01 0.01 0.01
Kd 0.39235669374466 0.39235669374466 0.39235669374466
Ks 1 1 1
Ke 0.35 0.35 0.35
map_Ka mat_03_AO.png
map_Kd mat_03_ALB.png
map_bump mat_03_NRM.png
map_Ke mat_03_EMS.png
Ns 512
illum 2

newmtl mat_04
#rotate -0.1275 0 1 0 0 0 0 1
#pulse_S 0.25
#pulse_D 2
##pulse_E 2
Ka 0.01 0.01 0.01
Kd 0.35159236192703 0.35159236192703 0.35159236192703
Ks 1 1 1
Ke 1 1 1
map_Ka mat_04_AO.png
map_Kd mat_04_ALB.png
map_bump mat_04_NRM.png
map_Ke mat_04_EMS.png
Ns 512
illum 2

See sync.zip for the changes that have been done.
Search for: // PAT: 01-04-2020
Note: the 2 new textures must be put into the robots2 folder
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #187 on: January 04, 2020, 05:04:12 pm »
OK but where's Most_Geometric_Person.mp3?
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 #188 on: January 04, 2020, 05:42:00 pm »
Here it is.

I made an error in PulseLight, currently the settings are exclusive, while they should be cumulative
We must use if comparison rather than switch   :-[
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #189 on: January 04, 2020, 06:08:56 pm »
Thank you!

Are you going to correct the sources now or later?
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 #190 on: January 04, 2020, 06:11:33 pm »
Use these

constants.h
Code: [Select]
#define AMBIENT                 1 // PAT: 01-04-2020 pulseID
#define DIFFUSE                 2 // PAT: 01-04-2020 pulseID
#define SPECULAR                4 // PAT: 01-04-2020 pulseID
#define EMISSIVE                8 // PAT: 01-04-2020 pulseID

mobj.h
Code: [Select]
                } else if (instr(szBuffer, "#pulse_") == 1) { // PAT: 01-04-2020 pulseID
                    if (fscanf(pFile, "%f", &pMaterial->rPulseLevel)) {
                        switch (szBuffer[7]) {
                        case 'a': // pulse_ambient
                            pMaterial->pulseID |= AMBIENT;
                            break;
                        case 'd': // pulse_diffuse
                            pMaterial->pulseID |= DIFFUSE;
                            break;
                        case 's': // pulse_specular
                            pMaterial->pulseID |= SPECULAR;
                            break;
                        case 'e': // pulse_emissive
                            pMaterial->pulseID |= EMISSIVE;
                            break;
                        default:
                            fgets(szBuffer, sizeof(szBuffer), pFile);
                            break;
                        }
                    }

renders.h
Code: [Select]
void PulseLight(MobjMat* pMaterial, IN float rShine) { // PAT: 01-04-2020 pulseID
            float ambient[4], diffuse[4], specular[4], emissive[4];
            ambient[0] = pMaterial->ambient[0];
            ambient[1] = pMaterial->ambient[1];
            ambient[2] = pMaterial->ambient[2];
            ambient[3] = pMaterial->ambient[3];

            diffuse[0] = pMaterial->diffuse[0];
            diffuse[1] = pMaterial->diffuse[1];
            diffuse[2] = pMaterial->diffuse[2];
            diffuse[3] = pMaterial->diffuse[3];

            specular[0] = pMaterial->specular[0];
            specular[1] = pMaterial->specular[1];
            specular[2] = pMaterial->specular[2];
            specular[3] = pMaterial->specular[3];

            emissive[0] = pMaterial->emissive[0];
            emissive[1] = pMaterial->emissive[1];
            emissive[2] = pMaterial->emissive[2];
            emissive[3] = pMaterial->emissive[3];

            if (gB.channel) {
                if ((pMaterial->pulseID) && (gP.bSyncAudio)) { // PAT: 01-04-2020 pulseID
                    DWORD nLevel = BASS_ChannelGetLevel(gB.channel);
                    float rPulse = (max(LOINT(nLevel), HIINT(nLevel)) / (20000.0f * pMaterial->rPulseLevel));
                    if (CheckStyle(pMaterial->pulseID, AMBIENT)) {
                        ambient[0] = rPulse;
                        ambient[1] = rPulse;
                        ambient[2] = rPulse;
                    }
                    if (CheckStyle(pMaterial->pulseID, DIFFUSE)) {
                        diffuse[0] = rPulse;
                        diffuse[1] = rPulse;
                        diffuse[2] = rPulse;
                    }
                    if (CheckStyle(pMaterial->pulseID, SPECULAR)) {
                        specular[0] = rPulse;
                        specular[1] = rPulse;
                        specular[2] = rPulse;
                    }
                    if (CheckStyle(pMaterial->pulseID, EMISSIVE)) {
                        emissive[0] = rPulse;
                        emissive[1] = rPulse;
                        emissive[2] = rPulse;
                    }
                }
            }

            glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient[0]);
            glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse[0]);
            glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular[0]);
            glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emissive[0]);

            glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, pMaterial->shininess * rShine);
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #191 on: January 04, 2020, 06:39:29 pm »
Everything seems to be working nicely, thank 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: Animated Backgrounds?
« Reply #192 on: January 04, 2020, 06:45:03 pm »
Cumulative works as espected, and emissive could produce some kind of nice glow when used sparingly.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
BusterDrone
« Reply #193 on: January 04, 2020, 08:44:03 pm »
To see the cumulative effects in action...
« Last Edit: January 04, 2020, 08:58:44 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #194 on: January 04, 2020, 08:58:33 pm »
Aha! But where's the attachment?! :o

Oh, there it is! ;D

!!! COOL !!!  :D
« Last Edit: January 04, 2020, 09:04:12 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)