Author Topic: Animated Backgrounds?  (Read 78190 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #165 on: December 30, 2019, 06:40:26 pm »
Cool! ;D
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 #166 on: December 31, 2019, 08:59:56 am »
Re. Reply #156 on: December 28,

Patrice,

I do not know what you are talking about. It's been years since PPL became OR's default rendering pipeline, and its Blinn-Phong shader (the one that draws some mesh materials that don't use bumpmaps while other meshes do) is the shader that displays your illum 3 reflections, both"ambient" (wallpapered) and local (refl'ed in a specific material). And Use fixed pipeline, which is OR's prehistoric immediate-mode pipeline, stays unchecked at all times unless it comes across a mammoth-aged model that never used a single bumpmap in any of its materials.

PPL reflections are drawn with better quality than FFP ones, and they have smoother surfaces and superior, more uniform lighting. I cannot understand why you keep on clutching onto that deprecated pipeline. Gimme just one single example of a model that would need it to be rendered at least as good as it is rendered in PPL. Alas, you Planar and Chromosaurus both fail that simple comparison. ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #167 on: December 31, 2019, 10:08:55 am »
Yes i am speaking of
the one that draws some mesh materials that don't use bumpmaps while other meshes do
using illum 3 or illum 4

Try using only this material with planar.

And add a zTrace into the FFP and PPL.

#multilight
#wallpaper @sanctuary.fs
#alphatocoverage
#playaudio Uncertain-Future.mp3 50 loop

newmtl planar
#rotate 0.15 0 1 0
Ka 1 1 1
Kd 1 1 1
Ks 3.5 2.5 2.5
Ns 512
d 0.9
illum 3
refl smoke.png


Then you will see that it is rendered into the drawUsingFixedFunctionPipeline

if you add this to force PPL

#multilight
#wallpaper @sanctuary.fs
#alphatocoverage
#playaudio Uncertain-Future.mp3 50 loop

newmtl planar
#rotate 0.15 0 1 0
Ka 1 1 1
Kd 1 1 1
Ks 3.5 2.5 2.5
map_bump neutral_bump.png
Ns 512
d 0.9
illum 3
refl smoke.png


Then it is rendered into the drawUsingProgrammablePipeline
loosing the reflection, even changing the other un-orthodoxe settings being used (shown in blue).
So far i am unable to recreate the same effects in PPL than in FFP.

illum 3 and illum 4, are currently not working in PPL mode, that was my point.

Added:
More exactly, it works in PPL mode, ONLY, if using the menu "Render" then "Ambient reflection". ;)
The gP.bSpecular flag seems to be enabled only when the menu is used, while it should be set also from the materail file.
Investigating...

« Last Edit: December 31, 2019, 12:28:47 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #168 on: December 31, 2019, 01:25:58 pm »
No, you are not correct, my friend!

If halo-less planar.obj is loaded without the bumpmap, it is rendered by FFP on default (menu is checked). But if you uncheck the menu to force PPL, FFP is cancelled, and the figure and cylinder are rendered by PPL's upper part that is called the Blinn-Phong shader. It comes in the drawUsingProgrammablePipeline() under this condition:

........
            // 12-09-2015 ML: !!! can't do "Specular mode" in multishader !!!
            // ML 01-18-2018: diffuse only mapping for billboards for now

            if (!pMaterial->bumpMapID || bSpecular || isBillboard) {

                // Bind the color map texture.  // ML: 11-26-2015
                glActiveTexture(GL_TEXTURE0);
                glEnable(GL_TEXTURE_2D);
........


It utilizes the shader that's called gR.blinnPhongShader:

........
                    goto doneBillboard;
                }

                // Per fragment Blinn-Phong code path.
                glUseProgram(gR.blinnPhongShader);
// MLL 02-27-2018: bypass billboard code above

                // Update shader parameters.
                glUniform1f(glGetUniformLocation(gR.blinnPhongShader, "rDoFlat"), rDoFlat); // MLL 03-17-2019:
                glUniform1f(glGetUniformLocation(gR.blinnPhongShader, "rDoWire"), rDoWire); // MLL 07-01-2019:
                glUniform1i(glGetUniformLocation(gR.blinnPhongShader, "diffMap"), 0);
                glUniform1i(glGetUniformLocation(gR.blinnPhongShader, "nLights"), nLights); // ML: 12-11-2015
                glUniform1i(glGetUniformLocation(gR.blinnPhongShader, "nLightFlags"), nLightFlags); // ML 02-01-2018:
                glUniform1i(glGetUniformLocation(gR.blinnPhongShader, "bDoSpherical"), bDoSpherical); // ML: 11-26-2015
........


and it uses the bDoSpherical boolean uniform to switch on automatic spherical coordinate generation in the shader, which is equivalent to the legacy immediate mode

........
                        glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
                        glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
                        glEnable(GL_TEXTURE_GEN_S);
                        glEnable(GL_TEXTURE_GEN_T);
........


commands.

On the other hand, if you try and add a bumpmap to the planar material, then spherical coord autogeneration becomes impossible, and the material is rendered through gR.normalMapShader in the lower else-branch of PPL material evaluation:

........
            } else {

                // Normal mapping code path.
                glUseProgram(gR.normalMapShader);

                // Bind the emission map texture. // MLL 12-08-2018:
                glActiveTexture(GL_TEXTURE6); bFlagBump = TRUE;
........


So, both FFP and PPL have built-in automatics to sense reflective materials with both global (wallpaper-based) and local (refl-based) "ambient" reflectance. The pipelines can simply be toggled with the Use fixed pipeline menu.

And finally, the Render->Ambient reflection menu is meant for any model with any set of materials to be optionally rendered entirely in the global wallpaper-based fancy "ambient" reflection mode. To me (and I am an average user in this case) it's as useless and pure fancy as any other shader in that section (gooch, cartoon, x-ray, etc.).

Hopefully, now you understand how "ambient reflection" works in OR and how entirely worthless its immediate mode is against the almighty programmable pipeline. ;)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #169 on: December 31, 2019, 01:55:50 pm »
Quote
On the other hand, if you try and add a bumpmap to the planar material, then spherical coord autogeneration becomes impossible, and the material is rendered through gR.normalMapShader in the lower else-branch of PPL material evaluation

Yes, i forgot that bumpmap and reflection are incompatible, probably because of the nasty neurone decimation i have encountered since falling down from my roof.  ::)

« Last Edit: December 31, 2019, 02:19:04 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #170 on: December 31, 2019, 02:32:00 pm »
It's not that bad at all, my friend! :D

Tell you what: bumpmapping and reflection are incompatible only in the normal-map ubershader we're currently using for our most advanced materials including transparencies.

When we switch over to dedicated shaders for reflection/refraction materials like glass and water or mirrors, normal maps are going to become standard means for emulating complex-profile transparent reflective/refractive surfaces:
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #171 on: December 31, 2019, 02:50:49 pm »
yes, this is what i was looking for :D
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #172 on: December 31, 2019, 10:01:23 pm »
Good afternoon gentlemen...

Daisy, Daisy...

BTW, the shader "#wallpaper IntoThelight.fs" blows up OR, when started from a material file  ???
« Last Edit: January 01, 2020, 11:56:56 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #173 on: December 31, 2019, 11:54:42 pm »
Hehe...  ;D Do you think such a small computer would be able to control the entire spaceship? I think it used to be the size of a mainframe.

IntoTheLight.fs works as-is by D&D. And it also works if renamed to IntoTheLite.fs and used locally:

#wallpaper @intothelite.fs

But it fails if specified as a global wallpaper regardless of name:

#wallpaper intothelite.fs

or

#wallpaper intothelight.fs

 :o ??? :-\

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 #174 on: January 01, 2020, 12:49:33 am »
There is one glitch with Hal: if you zoom it out far enough, you will notice its logo HAL9000 disappear from time to time at certain distances. The same can be seen when it's zooming in via Animate reset on model load.

Is it possibly z-buffer fighting between the logo and leather mesh surfaces? :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #175 on: January 01, 2020, 10:08:53 am »
Quote
But it fails if specified as a global wallpaper regardless of name:
Yes, because it is the ame problem we already have

in the case of a wallpaper starting with a i intothelight.fs
it shokes in Mobj_importMaterials on

        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;


Here is one solution to protect use agains the NULL pointer causing the havoc.

        case 'i': // illum
            fscanf(pFile, "%d", &nIllum);
            if (nIllum) { // PAT: 01-01-2020 avoid NULL pointer
                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;
« Last Edit: January 01, 2020, 10:28:18 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #176 on: January 01, 2020, 10:40:04 am »
No, I suggest

........
        case 'i': // illum
            if (strstr(szBuffer, "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;
........


and all the problems with locality or name are gone. Besides, it matches how other cases isolate their parameters.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #177 on: January 01, 2020, 11:19:25 am »
No, try with illumination.fs or just illum.fs
strstr alone is not enough even combined with a length of 5, because there could be no value following "illum".

illum is the only one assigning directly a pointer.

I have attached the new HAL version, indeed it is the hal monolith ;)

« Last Edit: January 01, 2020, 12:00:21 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Animated Backgrounds?
« Reply #178 on: January 01, 2020, 03:00:47 pm »
No Patrice,

Your inference on pointers is completely wrong here!

&nIllum will always be non-NULL because nIllum is a valid long temp var that we allocate on the stack and pre-assign with a value of 0. If the fscanf() call fails, i.e. it is not a valid illum assignment but an unlucky chance of shader being called illum.fs or similar, then nIllum will still stay 0, which is still a valid illum value! See the reference table in renderers.h near line 455:

........
            //0 Color on and Ambient off
........


So, the only legit way to check if fscanf() worked as it should is to check its return value that will be non-zero if it is a valid illum assignment, and zero if it is just a clash of names and there is no any numeric parameter following the "illum" string:

........
        case 'i': // illum
            if (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;
........


The new Hal's logo behaves better indeed and disappears only once at its extreme far distance. 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: 1992
    • zapsolution
Re: Animated Backgrounds?
« Reply #179 on: January 01, 2020, 03:29:23 pm »
Quote
if (fscanf(pFile, "%d", &nIllum)) {

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