Author Topic: custom shader fading  (Read 4350 times)

optear

  • Posts: 67
  • Turrets: +0/-0
custom shader fading
« on: March 26, 2007, 01:16:04 am »
server sets EF_MOVER_STOP bit if basi stops
Code: [Select]
   legs.hModel = ci->nonSegModel;
    legs.customSkin = ci->nonSegSkin;

    if( es->weapon == WP_ALEVEL1_UPG )
    {
      //ZOMG UBER HACK
      if( es->eFlags & EF_MOVER_STOP)
      {
        if(!cent->invis)
        {
          cent->invisTime = cg.time;
          cent->invis = qtrue;
        }
      }
      else
      {
        if(cent->invis)
        {
          cent->invisTime = cg.time;
          cent->invis = qfalse;
        }
      }

      if( cent->invis)
      { //fade out in 1 second shader time is 0
        legs.shaderTime = cent->invisTime/1000.0f;
        if( cg.time - cent->invisTime < 1000  )
          legs.customShader = cgs.media.invisFadeShader;
        else
          legs.customShader = cgs.media.invisShader;
      }
      else
      {
        if( cg.time - cent->invisTime < 500  )
        { //fade in in .5 second :: shaderTime is 2 - .5
          legs.shaderTime = (cent->invisTime+500.0)/1000.0;
          legs.customShader = cgs.media.invisFadeShader;
        }
      }
    }

and the corresponding shaders are

Code: [Select]
gfx/invisfade
{
  {
    map models/players/level1/level1upg.jpg
    blendFunc GL_ONE GL_ONE
    // sin wave of amp 1 and base 0 (usual sinwave)
    // starts from .25 -> PI/2 -> sinx = 1
    // .5 cycles per second -> period 2 second
    rgbgen wave sin 0.0 1.0 0.25 0.5
  }
  {
    animmap 24 gfx/invis.jpg gfx/invisa.jpg
    blendFunc GL_ONE GL_ONE
    tcmod scale 2 2
    tcMod scroll 0.2 -0.2
    //tcGen environment
  }
}
gfx/invis
{
  nopicmip
  {
    animmap 24 gfx/invis.jpg gfx/invisa.jpg
    blendFunc GL_ONE GL_ONE
    tcmod scale 2 2
    tcMod scroll 0.2 -0.2
    //tcGen environment
  }
}


I want to learn if there is a better way of fading shaders manually or another way of doing this
This works good so far ie when you stand still basi becomes invisible slowly and when you move it appears again a little faster
quote]if timbo is the father of tremulous, norfenstein - mother, and overflow, jex, stannum, tjw, ... children. I am the grandfather. Because I created NS. [/quote]