Forum

Qrack's "Nightmare mode"

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Qrack's "Nightmare mode"

Postby Baker » Sat May 14, 2011 4:23 am

Qrack's gl_nightmaremode does a couple of things, one of which is turns the world to shades of gray. I haven't looked, but my guess is that it converts world textures (world texture = textures that are part of the map) to black and white.

I remember last year when GoldQuake emulated the DOS feature of the tinted palette, Spike mentioning something about FTEQW doing about the same using a shader.

Anyway, is there a way to manipulate the color buffer to gray scale it or even "gray scale + green it" (a night vision type of effect). Just wondering since I can't think of any blending function that would achieve that.

OpenGL documentation in my opinion sucks, maybe the biggest liability of the graphics api is that since the documentation sucks you have to rely on stuff like Nehe tutorials and Google and I find myself using MSDN docs. (I imagine Direct3D has very high quality documentation like anything Microsoft does).
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby r00k » Sat May 14, 2011 5:56 am

Actually all its doing is a fullscreen gl_quad with a call to
glCopyTexImage2D.

Depending on your format you can get a varied effect...
I've changed it to be "RED" ala "PainKiller"
Code: Select all
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RED, glx, gly, vwidth, vheight, 0);


I think the grey was GL_LUMINANCE or GL_LUMINANCE_ALPHA

To answer your question yes, GL_GREEN..

This is the motion blur code that is used for gl_nightmare...
Code: Select all
void R_RenderSceneBlur (float alpha, GLenum format)
{
   extern int   sceneblur_texture;
   int vwidth = 2, vheight = 2;
   float vs, vt;

   if (alpha < 0.1)
      alpha = 0.1;

   while (vwidth < glwidth)
   {
      vwidth *= 2;
   }
   while (vheight < glheight)
   {
      vheight *= 2;
   }

   glViewport (glx, gly, glwidth, glheight);

   GL_Bind(sceneblur_texture);

   // go 2d
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity ();
   glOrtho  (0, glwidth, 0, glheight, -99999, 99999);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity ();

   vs = ((float)glwidth / vwidth);
   vt = ((float)glheight / vheight) ;

   glDisable (GL_DEPTH_TEST);
   glDisable (GL_CULL_FACE);
   glEnable(GL_BLEND);

   glColor4f(1, 1, 1, alpha);//<-- alpha of blur     

   glBegin(GL_QUADS);
      glTexCoord2f(0, 0);
      glVertex2f(0, 0);
      glTexCoord2f(vs , 0);
      glVertex2f(glwidth, 0);
      glTexCoord2f(vs , vt);
      glVertex2f(glwidth, glheight);
      glTexCoord2f(0, vt);
      glVertex2f(0, glheight);
   glEnd();

   glEnable(GL_DEPTH_TEST);
   glDepthMask(1);
   glColor3f (1,1,1);   
    glDisable (GL_BLEND);   

   glMatrixMode(GL_PROJECTION);
   glPopMatrix();      
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();      

   glCopyTexImage2D(GL_TEXTURE_2D, 0, format, glx, gly, vwidth, vheight, 0);

//   glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);        
}


and the call

Code: Select all
         if ((cl.items & IT_INVULNERABILITY)&&(gl_nightmare.value))
         {
            R_RenderSceneBlur (gl_nightmare.value, GL_RED);
         }


There would be a more elegant way of doing this though with a shader. Plus to allow entities to glow a bright yellow when viewed with the night vision goggles.
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby mh » Thu May 19, 2011 6:22 am

glColorMask. ;)
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest