/******************************************************************************/
/*                                                                            */
/*       Module Name          : leaf_ps.c                                     */
/*                                                                            */
/*       Author               : S.Chapman                                     */
/*                                                                            */
/*       Comment              : Simple Pixel Shader for implementing leaves   */
/*                              on a tree where full transparency is required.*/
/*                                                                            */
/******************************************************************************/

/******************************************************************************/
/* Declare Constants.                                                         */
/******************************************************************************/

/******************************************************************************/
/* Declare the required Texture Stages.                                       */
/******************************************************************************/
sampler text1 : register( s0);

/******************************************************************************/
/* 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;

   /* Retrieve the colour values from the first texture stage.                */
   vector text_colour = tex2D( text1, input.text1);

   /* If the colour is white then the pixel is transparent.                   */
   if(( text_colour.r >= 0.90f)&&
      ( text_colour.g >= 0.90f)&&
      ( text_colour.b >= 0.90f))
   {
      output.diffuse.a = 0.0;

   }                                   /* End of if( text_colour.r == ...     */
   else
   {
      output.diffuse.a = 1.0;
      output.diffuse.rgb = ( text_colour * input.diffuse);// + input.specular;

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

   return output;

}                                      /* End of main.                        */
