/*******************************************************************/
/*                                                                 */
/* Module: flora_vs.cg                                             */
/*                                                                 */
/* Author: John Buckley                                            */
/*                                                                 */
/* Description:                                                    */
/*                                                                 */
/*   Flora Material Class - Vertex Shader                          */
/*                                                                 */
/* Copyright 2005 Sony Online Entertainment.  All rights reserved. */
/*                                                                 */
/*******************************************************************/

#include"flora_common.cg"

/**********************************/
/* Vertex Shader                  */
/**********************************/

Fragment_Flora main( Vertex_Flora     In, 
                            uniform float4x4 WorldViewProjMat,
                            uniform float3   LightAmbient,
                            uniform float2   SubTexScale,
                            uniform float    FogFar,
                            uniform float    FogRange )
{
  Fragment_Flora  Out;

  /* Transform position to clip space */

  Out.Pos = mul(WorldViewProjMat, float4(In.Pos.xyz, 1.0f));
  
  /* Vertex Lighting */

  Out.Diff.rgb  = LightAmbient.rgb;
  Out.Diff.a    = 1.0f;
  
  /* Texture Coordinates */
  
  //Out.ColorUV = In.UV0.xy;

  /* Unpack UV */
  
  Out.ColorUV.y = floor(In.Pos.w * (1.f / 16.f));
  Out.ColorUV.x = In.Pos.w - 16.f * Out.ColorUV.y;

  Out.ColorUV.xy *= SubTexScale;

  /* Fog */

  Out.FogDepth = saturate(1.0f - (FogFar - Out.Pos.w) * FogRange);

  return Out;
}

/* End of File */

