Invulnerability effect doesn't work in Software OpenGL <=2.x

Sat Nov 10, 2018 7:34 pm

By the way in Gzdoom g3.7vpre-67-g098603c83 the invulnerability effect does not work correctly in Poly or Software render mode without the MESA3D library.

With MESA3D:


Without MESA3D:

Re: Doom 64 style lighting improvements

Sat Nov 10, 2018 7:39 pm

That pretty much demonstrates to a tee the deprecated state of the OpenGL 2 tree. It only happens when in legacy mode. The code to do that correctly in OpenGL 2 was never made. Nevertheless, I will split this and move it to Software bugs, but this will probably never be fixed.

Re: Invulnerability effect doesn't work in Software OpenGL <

Sat Nov 10, 2018 7:46 pm

I solved it some time ago when the first Legacy version came out, but I need, the github of the current gzdoom legacy.

Re: Invulnerability effect doesn't work in Software OpenGL <

Sat Nov 10, 2018 8:00 pm

https://github.com/drfrag666/gzdoom/tree/legacy

Re: Invulnerability effect doesn't work in Software OpenGL <

Sat Nov 10, 2018 9:02 pm

Ok this fixes the bug:

In gl_20.cpp you have to make the following change:
Code:
//==========================================================================
//
//
//
//==========================================================================

void gl_SetTextureMode(int type)
{
   if (type == TM_SWCANVAS)
   {
      int shader = V_IsTrueColor() ? 2 : 0;
      float c1[4], c2[4];

      //Old code
      /*if (gl_RenderState.mColormapState > CM_DEFAULT && gl_RenderState.mColormapState < CM_MAXCOLORMAP)
      {
         FSpecialColormap *scm = &SpecialColormaps[gl_RenderState.mColormapState - CM_FIRSTSPECIALCOLORMAP];
         for (int i = 0; i < 3; i++)
         {
            c1[i] = scm->ColorizeStart[i];
            c2[i] = scm->ColorizeEnd[i] - scm->ColorizeStart[i];
         }
         c1[3] = 0;
         c2[3] = 0;
         shader++;
      }*/

      //[GEC] Specials colormaps Fix
      if (gl_RenderState.mColormapState >= CM_FIRSTSPECIALCOLORMAP && gl_RenderState.mColormapState < CM_MAXCOLORMAPFORCED)
      {
         //Printf("ColormapState %i\n", gl_RenderState.mColormapState - CM_FIRSTSPECIALCOLORMAPFORCED);
         auto colormapState = gl_RenderState.mColormapState + CM_FIRSTSPECIALCOLORMAP - CM_FIRSTSPECIALCOLORMAPFORCED;
         if (colormapState < CM_MAXCOLORMAP)
         {
            FSpecialColormap *scm = &SpecialColormaps[colormapState - CM_FIRSTSPECIALCOLORMAP];
            for (int i = 0; i < 3; i++)
            {
               c1[i] = scm->ColorizeStart[i];
               c2[i] = scm->ColorizeEnd[i] - scm->ColorizeStart[i];
            }
            c1[3] = 0;
            c2[3] = 0;
            shader++;
         }
      }

      // Type 2 (unaltered true color) can be done without activating the shader.
      if (shader != 2)
      {
         GLRenderer->legacyShaders->BindShader(shader, c1, c2);
         return;
      }
      else type = TM_MODULATE;
   }
   glUseProgram(0);
   if (type == TM_MASK)
   {
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
   }
   else if (type == TM_OPAQUE)
   {
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
   }
   else if (type == TM_INVERSE)
   {
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
   }
   else if (type == TM_INVERTOPAQUE)
   {
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
   }
   else // if (type == TM_MODULATE)
   {
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   }
}


Now try to fix in open gl mode.


swgl works well on my pc, the question is can be used with open gl, how to add Brightmaps?

Re: Invulnerability effect doesn't work in Software OpenGL <

Sun Nov 11, 2018 12:39 am

If you talk about the software renderer, good luck with brightmaps. They essentially need a completely new set of drawers that can read from two sources and combine them. This never was implemented because it'd massively slow down things.

Another note: The fixed colormaps are already applied to the paletted output at the source. You have to make sure that you do not end up applying it twice.

Re: Invulnerability effect doesn't work in Software OpenGL <

Sun Nov 11, 2018 2:17 pm

Erick194 wrote:Ok this fixes the bug

You could do a PR or i could apply the patch manually. So it's okay to apply this patch?
I hadn't noticed this problem until now.

Re: Invulnerability effect doesn't work in Software OpenGL <

Sun Nov 11, 2018 3:58 pm

Go ahead you can take the code, just put [GEC], like the others who have collaborated with the port.

Re: Invulnerability effect doesn't work in Software OpenGL <

Wed Nov 14, 2018 1:23 pm

Thanks, just pushed it:
https://github.com/drfrag666/gzdoom/com ... 55261a2d7b

BTW do you know how to use Git/TortoiseGit, create Git diff patches or do PRs? That would be far better.