// Common functions and definitions shared by legacy NVR environment
// variants of shader pair:
//      LIT_VS
//      LIT_PS

///////////////////////////////////////////////////////////////////////////////

// Four blend materials use either uv1 from the vertex or they
// use calculated map relative uv coords to read the height blend map
#if defined(FOUR_BLEND)
    #if defined(USE_TERRAIN_BLEND)
        #define FOUR_BLEND_USES_MAP_UV      1
    #else
        #define FOUR_BLEND_USES_VERTEX_UV   1
    #endif
#endif

#ifdef MOD2X_COLORMAP
    // We will need to read from the colormap for this mode except if
    // not supported with other settings
    #if defined(FOUR_BLEND) || defined(DECAL) || !defined(FOG_QUALITY_LOW)
        #define READ_COLORMAP 1
    #endif
#endif

// Do we need to display a terrain brush in the terrain editor?
// If so we will need map relative uv coords for the brush.
#if defined(TERRAIN_EDITOR) && (defined(USE_TERRAIN_BLEND) || defined(MOD2X_COLORMAP))
    #define NEED_TERRAIN_BRUSH  1
#endif

// Do we need an interpolator with map relative uv location of this vertex?
// Note that four blend could potentially lookup into both the mod2x colormap (for lighting)
// and the height blend map.
#if defined(READ_COLORMAP) || defined(FOUR_BLEND_USES_MAP_UV) || defined(NEED_TERRAIN_BRUSH)
    #define NEED_MAP_UV     1
#endif

///////////////////////////////////////////////////////////////////////////////

// NOTE: We try to combine multiple values into single hardware interpolators.
// We jump through these hoops to minimize the number of interpolators
// used since they can be an expensive hidden cost during rasterization.

struct INTERPOLANTS
{
    float4 m_Position : POSITION;
    float4 m_TexCoord0 : TEXCOORD0;
#ifndef DISABLE_SHADOWS
    float4 m_TexCoord3 : TEXCOORD1;
#endif
    float4 fowUV : TEXCOORD2;
#if NEED_MAP_UV
 #if FOUR_BLEND_USES_VERTEX_UV
   float4 mapUV_vertexUV1  : TEXCOORD3;  // combine map uv and vertex uv1 here to avoid using an extra interpolator
 #else
   float2 mapUV            : TEXCOORD3;
 #endif
#elif FOUR_BLEND_USES_VERTEX_UV
  float2 vertexUV1           : TEXCOORD3;
#endif


#if !defined(MOD2X_COLORMAP) || defined(VERTEX_ALPHA)
    float4 m_Color0 : COLOR0;
#endif
    float4 m_Color1 : COLOR1;
#if defined(VERTEX_FOG)
    float m_Fog : FOG;
#endif
};


#if defined(QUALITY_LOW) && defined(MOD2X_COLORMAP)
// optimize value pass from vertex shader
// for the low quality mod2x no shadows variant
struct Interpolants_LowestQuality
{
    float4 m_Position   : POSITION;
    float4 m_TexCoord0  : TEXCOORD0;

#if NEED_MAP_UV
 #if FOUR_BLEND_USES_VERTEX_UV
   float4 mapUV_vertexUV1  : TEXCOORD1;  // combine map uv and vertex uv1 here to avoid using an extra interpolator
 #else
   float2 mapUV            : TEXCOORD1;
 #endif
#elif FOUR_BLEND_USES_VERTEX_UV
   float2 vertexUV1           : TEXCOORD1;
#endif

    float4 m_Color0     : COLOR0;
};
#endif

///////////////////////////////////////////////////////////////////////////////
