/******************************************************************************/
/*                                                                            */
/*       Module Name          : glow_ps.c                                     */
/*                                                                            */
/*       Author               : S.Chapman                                     */
/*                                                                            */
/*       Comment              : Simple Pixel Shader for implementing glowing  */
/*                              points within a texture such as windows on    */
/*                              building at night.                            */
/*                                                                            */
/******************************************************************************/


/******************************************************************************/
/* Declare the required Texture Stages.                                       */
/******************************************************************************/
sampler text1 : register( s0);         /* Bilinear Filtered.                  */
sampler text2 : register( s1);         /* Point Sampled.                      */

/******************************************************************************/
/* Declare the Glow contant.                                                  */
/******************************************************************************/
vector  glow_colour     : register( c0);

/******************************************************************************/
/* Declare the Input parameters.                                              */
/******************************************************************************/
struct PS_INPUT
{
   vector diffuse   :COLOR0;
   vector specular  :COLOR1;
   float2 text1     :TEXCOORD0;
};

/******************************************************************************/
/* Declare the Output parameters.                                             */
/******************************************************************************/
struct PS_OUTPUT
{
   vector diffuse : COLOR0;
};

/******************************************************************************/
/* Glow Pixel Shader Entry function.                                          */
/******************************************************************************/
PS_OUTPUT main( PS_INPUT  input)
{
   /* Declare and initialise the output.                                      */
   PS_OUTPUT output = ( PS_OUTPUT)0.0;

   /* Retrieve the colour values from the texture stages.                     */
   vector text_colour1 = tex2D( text1, input.text1);
   vector text_colour2 = tex2D( text2, input.text1);

   /* If the alpha value is set then adopt the glow colour value.             */
   if( text_colour2.a > 0.0f)
   {
      output.diffuse = glow_colour;

   }                                   /* End of if( text_colour2.r == ...    */
   else
   {
      output.diffuse = ( text_colour1 * input.diffuse) + input.specular;

   }                                   /* End of ..else( text_colour2.r == ...*/

   return output;

}                                      /* End of main.                        */
