; Shaders Script file
; Copyright (c) 2001-2003 Crytek Studios. All Rights Reserved.
; Author: Honich Andrey


Version (1.00)

// low spec shader shader (with pixel shader support)
#define LOWSPEC_WATER_SHADER                 \    
  HW 'Seq'  \
  (         \    
    Array (Verts 3 FLOAT Vertex)  \      
    ShadeLayer  \
    (       \
      CGVProgram  = CGVProgLowMedWater  \
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')  \
      CGVPParam ( Name = TexShiftRipple Comp = 1 Comp = 1 Comp 'time 0.01' Comp 'time 0.01')  \
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) \
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0) \
      CGVPParam ( Name = TexDetailScale Comp = 0.2 Comp = 0.2  Comp = 0 Comp = 2.0)  \      
      CGPShader   = CGRCLowMedWater   \
      CGPSParam ( Name = Matrix Comp = 0.02 Comp = 0 Comp = 0 Comp = 0.02 )   \
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp = 0.4 )   \
      CGPSParam ( Name = WaterColor Comp = 0.5 Comp = 0.7 Comp = 1.0 User 'LowSpecOpacity')   \
      Layer '0'   \
      ( \
        TexType = DSDTBump  \
        TexFilter = TriLinear  \
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop )  \
        TexColorOp = NoSet \
      ) \
      Layer '1' \
      (         \            
        Map =  waterbump.dds   \
        TexColorOp = NoSet            \
        DepthWrite = 0                \
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'  \        
      )             \
    )               \
  )                 \

// water refraction shared parameters    
#define WATER_REFRACTION_PARAMS     \
    float 'ColorR' (0.1)  \
    float 'ColorG' (0.35) \
    float 'ColorB' (0.36) \    
    float 'AnimSpeed' (0.5) \
    float 'RefrTillingAmount' (2.5) \
    float 'RefrBumpAmount' (0.05) \
    float 'LowSpecOpacity' (1.0) \
    
// water refraction pass (cheap)
#define WATER_REFRACTION                 \        
    ShadeLayer  \
    (     \
      CGVProgram  = CGVProgOutdoorWaterRefraction \
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')      \
      CGVPParam ( Name = ScreenSize Comp 'ScreenSize pos 0' Comp 'ScreenSize pos 1' Comp = 0 Comp = 0)  \      
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.06' Comp 'time 0.12')  \
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)   \
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)   \
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')       \                  
      CGPShader   = CGRCOutdoorWaterRefraction  \
      CGPSParam ( Name = Matrix Comp =0.025 Comp = 0 Comp = 0 Comp =0.025 ) \
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp =1 ) \
      CGPSParam ( Name = WaterColor User 'ColorR' User 'ColorG' User 'ColorB' Comp =1 )   \
      Layer '0' \
      (          \
        Map =   fire_noise.dds  \
        TexType = DSDTBump  \
      ) \      
      Layer '1' \
      ( \
        Projected \
        Map =  $ScreenTexMap                                  \
        TexColorOp = NoSet  \
        DepthWrite = 0             \
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'  \
      ) \
    )   \
        
// really low spec shader shader... (no pixel shaders support)
Shader 'LowSpecWaterOutdoor_FP'
(
  Public
  (
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    NoLight
    IgnoreResourceState
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    ShadeLayer
    (
      Layer '0'
      (
        Map = textures/animated/water/caust_xb_00
          
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.225 Comp = 0 Comp = 0 Comp 'time 0.1')
          PlaneT (Comp = 0 Comp = 0.225 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate
        TexAlphaOp = Add
        TexColorArg0 = Diffuse
        TexColorArg1 = Texture
        TexAlphaArg0 = Diffuse
        TexAlphaArg1 = Constant
      )
    
      Layer '1'  
      (
        Map = textures/animated/water/caust_xb_00

        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.160 Comp = 0 Comp = 0 Comp 'time -0.1')
          PlaneT (Comp = 0 Comp = 0.160 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate
        RgbGen 'Fixed' (1 1 1 0.2)

        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        DepthWrite = 0
      )
    )
    
    // add environment mapping    
    ShadeLayer  
    ( 
      Matrix 'GL_TEXTURE'
      {      
        TexStage = 0
        Matrix 'TranspCameraMatrix'       
        Coords = 3
      }
      
      Layer '0'          
      (  
        //RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 User 'LowSpecOpacity')
        RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 Comp=0.2)        
        Map = textures/animated/water/caust_xb_00
        
        TexGen = HW_Reflection
        
        TexColorOp = Modulate
        TexAlphaOp = Replace
        TexColorArg0 = Texture        
        TexColorArg1 = Diffuse
        TexAlphaArg0 = Constant                
        TexAlphaArg1 = Diffuse
        //Blend 'DST_COLOR ONE' 
        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA' 
        DepthWrite = 0   
      )      
    )
  )
)

// really low spec shader shader... (no pixel shaders support)
Shader 'LowSpecWaterIndoor_FP'
(
  Public
  (
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    NoLight
    IgnoreResourceState
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    ShadeLayer
    (
      Layer '0'
      (
        Map = textures/animated/water/caust_xb_00
          
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.225 Comp = 0 Comp = 0 Comp 'time 0.1')
          PlaneT (Comp = 0 Comp = 0.225 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate
        TexAlphaOp = Add
        TexColorArg0 = Diffuse
        TexColorArg1 = Texture
        TexAlphaArg0 = Diffuse
        TexAlphaArg1 = Constant
      )
    
      Layer '1'  
      (
        Map = textures/animated/water/caust_xb_00

        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.160 Comp = 0 Comp = 0 Comp 'time -0.1')
          PlaneT (Comp = 0 Comp = 0.160 Comp = 0 Comp = 0)
        }       
        
        RgbGen 'Fixed' (1 1 1 0.5)
        TexColorOp = Modulate
        TexAlphaOp = Modulate
        TexColorArg0 = Previous
        TexColorArg1 = Texture
        TexAlphaArg0 = Previous
        TexAlphaArg1 = Constant                

        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        DepthWrite = 0
      )
    )
    
    // add environment mapping    
    ShadeLayer  
    ( 
      Matrix 'GL_TEXTURE'
      {      
        TexStage = 0
        Matrix 'TranspCameraMatrix'       
        Coords = 3
      }
      
      Layer '0'          
      (  
        //RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 User 'LowSpecOpacity')
        //RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 Comp=0.75)        
        Map = textures/animated/water/caust_xb_00
        //        Map = water_lm //textures/animated/water/caust_xb_00
        
        TexGen = HW_Reflection
        
        TexColorOp = Modulate //AddSigned
        TexAlphaOp = Replace
        TexColorArg0 = Texture        
        TexColorArg1 = Diffuse                
        TexAlphaArg0 = Constant                
        TexAlphaArg1 = Diffuse
        Blend 'ZERO SRC_COLOR'  
        //Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        
        DepthWrite = 0   
      )      
    )
  )
)

/*
// really low spec shader shader... (no pixel shaders support)
Shader 'LowSpecWater_FP'
(
  Public
  (
    float 'LowSpecOpacity' (0.85)
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    NoLight
    IgnoreResourceState
  )

  HW 'Seq'  
  ( 
    Array (Verts 3 FLOAT Vertex)  
    Array (Color 4 BYTE Color)  
    

    // add environment mapping    
    ShadeLayer  
    ( 
      Matrix 'GL_TEXTURE'
      {      
        TexStage = 0
        Matrix 'TranspCameraMatrix'       
        Coords = 3
      }
      
      Layer '0'          
      (  
        //RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 User 'LowSpecOpacity')
        RgbGen 'Comp' (Comp =0.2  Comp =0.4 Comp=0.5 Comp=1)
        TexFilter = TriLinear
        Map = textures/animated/water/caust_xb_00
        
        TexGen = HW_Reflection
        
        TexColorOp = Modulate
        TexAlphaOp = Modulate
        TexColorArg0 = Texture        
        TexColorArg1 = Diffuse                
        TexAlphaArg0 = Diffuse                
        TexAlphaArg1 = Diffuse
        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'  
        DepthWrite = 0   
      )      
    )
    
    ShadeLayer
    (
      Layer '0'
      (      
        Map = textures\animated\water\CAUST_XB_00
          
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'time 0.2')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
        }       
        RgbGen 'Fixed' (1 1 1 1)
        //RgbGen 'Comp' (Comp =1  Comp =1 Comp=1 User 'LowSpecOpacity')
        
        TexColorOp = Modulate
        TexAlphaOp = Replace
        TexColorArg0 = Diffuse
        TexColorArg1 = Texture
        TexAlphaArg0 = Constant        
      )
    
      Layer '1'  
      (
        Map = textures\animated\water\CAUST_XB_00

        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.060 Comp = 0 Comp = 0 Comp 'time -0.2')
          PlaneT (Comp = 0 Comp = 0.060 Comp = 0 Comp = 0)
        }       
        
        TexColorOp = Modulate
        TexAlphaOp = Modulate
        TexColorArg0 = Texture
        TexColorArg1 = Previous
        TexAlphaArg0 = Diffuse
        TexAlphaArg1 = Diffuse
        
        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'        
        DepthWrite = 0
      )
    )    
  )   
)

*/

Shader 'TerrainWater_CM_PS20'
(
  Public
  (
    float 'WaveSpeedX' (0.1)
    float 'WaveSpeedY' (0.2)
    float 'NoiseSpeed' (0.1)
    float 'FadeBias' (0.5)
    float 'FadeExp' (6.0)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
    float 'Opacity' (1.0)
  )
  Params
  (
    Sort = Water
    Cull = TwoSided  
  )

  HW 'Seq'  
  ( 
    Array (Verts 3 FLOAT Vertex)  
    Array (Color 4 BYTE Color)  
        
    ShadeLayer  
    ( 
      CGPShader = CGRCWater_PS20
      CGPSParam (Name = FadeParams User 'FadeBias' User 'FadeExp')
      CGPSParam (Name = TimeParams Comp 'Time 1' User 'WaveSpeedX' User 'WaveSpeedY' User 'NoiseSpeed')
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' User 'Opacity')
      
      CGVProgram = CGVProgWater_VS20
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = Normal Comp=0 Comp=0 Comp=1)
      CGVPParam ( Name = Scale Comp=0.1 Comp=0.1 Comp=0.1)

      Layer '0' 
      ( 
        Map = $NoiseVolume
        TexFilter = TriLinear
        TexType = Volume
      ) 
      Layer '1'
      (
        Map = TEXTURES\water
        TexType = CubeMap   
        TexColorOp = NoSet
        TexFilter = TriLinear

        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA' 
        DepthWrite = 0  
      )
    )  
  )   
)



Shader 'TemplWater_CM_PS20'
(
  Public
  (
    float 'WaveSpeedX' (0.1)
    float 'WaveSpeedY' (0.2)
    float 'NoiseSpeed' (0.1)
    float 'FadeBias' (0.5)
    float 'FadeExp' (6.0)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
    float 'WaveScaleX' (0.1)
    float 'WaveScaleY' (0.1)
    float 'WaveScaleZ' (0.1)
  )
  Params
  (
  )

  HW 'Seq'  
  ( 
    Array (Verts 3 FLOAT Vertex)  
    Array (Color 4 BYTE Color)  
        
    ShadeLayer  
    ( 
      CGPShader = CGRCWater_PS20
      CGPSParam (Name = FadeParams User 'FadeBias' User 'FadeExp')
      CGPSParam (Name = TimeParams Comp 'Time 1' User 'WaveSpeedX' User 'WaveSpeedY' User 'NoiseSpeed')
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' Comp 'Opacity')
      
      CGVProgram = CGVProgWater2_VS20
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = Scale User 'WaveScaleX' User 'WaveScaleY' User 'WaveScaleZ')

      Layer '0' 
      ( 
        Map = $NoiseVolume
        TexType = Volume
      ) 
      Layer '1'
      (
        Map = $Cubemap
        TexType = CubeMap   
        TexColorOp = NoSet
      )
    )  
  )   
)

Shader 'TemplWater_RTCM_PS20'
(
  Public
  (
    float 'WaveSpeedX' (0.1)
    float 'WaveSpeedY' (0.2)
    float 'NoiseSpeed' (0.1)
    float 'FadeBias' (0.5)
    float 'FadeExp' (6.0)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
    float 'WaveScaleX' (0.1)
    float 'WaveScaleY' (0.1)
    float 'WaveScaleZ' (0.1)
  )
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawDetailTextures
    DrawWater
    FullDetailTerrain
    DrawTerrain
  }
  Params
  (
  )

  HW 'Seq'  
  ( 
    Array (Verts 3 FLOAT Vertex)  
    Array (Color 4 BYTE Color)  
        
    ShadeLayer  
    ( 
      CGPShader = CGRCWater_PS20
      CGPSParam (Name = FadeParams User 'FadeBias' User 'FadeExp')
      CGPSParam (Name = TimeParams Comp 'Time 1' User 'WaveSpeedX' User 'WaveSpeedY' User 'NoiseSpeed')
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' Comp 'Opacity')
      
      CGVProgram = CGVProgWater2_VS20
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = Scale User 'WaveScaleX' User 'WaveScaleY' User 'WaveScaleZ')

      Layer '0' 
      ( 
        Map = $NoiseVolume
        TexType = Volume
      ) 
      Layer '1'
      (
        Map = $EnvironmentCubeMap
        TexType = CubeMap   
        TexColorOp = NoSet
      )
    )  
  )   
)

Shader 'TerrainWater_CM'
(
  Public
  {
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'FresnelBias' (0.2)
    float 'FresnelScale' (2)
    float 'FresnelPower' (2)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
  }
  HW 'Seq'
  (
    ShadeLayer
    (
      CGPShader = CGRCWaterReflectCMap
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' Comp 'Opacity')

      CGVProgram = CGVProgWaterBumpReflCM_PS
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = Binormal Comp = 0 Comp = -1 Comp = 0 ) // Binormal
      CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1 )  // Normal
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12' Comp=0)  // xy = ripple uv ADDer
      CGVPParam ( Name = ObjToCubeSpace InvObjMatrix)
      CGVPParam ( Name = BumpScale User 'BumpAmountX' User 'BumpAmountY')
      CGVPParam ( Name = Fresnel User 'FresnelPower' User 'FresnelScale' User 'FresnelBias' Comp=0)
      CGVPParam ( Name = ObjMatrix ObjMatrix)

      Layer '0'
      (
        TexType = Bump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = textures/Water
        TexType = Cubemap
        TexColorOp = NoSet
        Blend   'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
)

Shader 'TemplWater_CM'
(
  Public
  {
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'FresnelBias' (0.2)
    float 'FresnelScale' (2)
    float 'FresnelPower' (2)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
  }
  HW 'Seq'
  (
    ShadeLayer
    (
      CGPShader = CGRCWaterReflectCMap
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' Comp 'Opacity')

      CGVProgram = CGVProgWater2BumpReflCM_PS
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = ObjToCubeSpace InvObjMatrix)
      CGVPParam ( Name = BumpScale User 'BumpAmountX' User 'BumpAmountY')
      CGVPParam ( Name = Fresnel User 'FresnelPower' User 'FresnelScale' User 'FresnelBias' Comp=0)
      CGVPParam ( Name = ObjMatrix ObjMatrix)

      Layer '0'
      (
        Map = $Bump
        TexType = Bump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = $Cubemap
        TexType = Cubemap
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'TemplWater_RTCM'
(
  Public
  {
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'FresnelBias' (0.2)
    float 'FresnelScale' (2)
    float 'FresnelPower' (2)
    float 'Color_R' (0.5)
    float 'Color_G' (0.5)
    float 'Color_B' (0.5)
  }
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawDetailTextures
    DrawWater
    FullDetailTerrain
    DrawTerrain
  }
  HW 'Seq'
  (
    ShadeLayer
    (
      CGPShader = CGRCWaterReflectCMap
      CGPSParam (Name = WaterColor User 'Color_R' User 'Color_G' User 'Color_B' Comp 'Opacity')

      CGVProgram = CGVProgWater2BumpReflCM_PS
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = ObjToCubeSpace InvObjMatrix)
      CGVPParam ( Name = BumpScale User 'BumpAmountX' User 'BumpAmountY')
      CGVPParam ( Name = Fresnel User 'FresnelPower' User 'FresnelScale' User 'FresnelBias' Comp=0)
      CGVPParam ( Name = ObjMatrix ObjMatrix)

      Layer '0'
      (
        Map = $Bump
        TexType = Bump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = $EnvironmentCubeMap
        TexType = Cubemap
        TexColorOp = NoSet
      )
    )
  )
)
     
Shader 'TerrainWater'
(
  Public
  (
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
    float 'WaveAmplitude' (0.1)
    float 'ReflectAmount' (0.9)
    float 'ReflectAddAmount' (0.2)
    float 'Opacity' (1)   
    
    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back    
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    //UpdateFactor = 0.001
    FullDetailTerrain
    DrawTerrain
  }

  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)


    // water refraction pass (cheap)
#ifdef PROJECTEDENVBUMP
    WATER_REFRACTION
#endif    

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        //Sequence(Maps = textures/animated/water/caust## Time = 0.05 Loop)
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp 'MinDistance')
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp 'MinLightDistance')
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 150 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          //BumpHighRes
          BumpAmount = 0.1
          //TexLodBias = 1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'  
      (
        TexType = DSDTBump 
        TexFilter = TriLinear 
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop ) 
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )


//#ifdef SUPPORT_PROFILE_PS_2_0
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 30 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          //BumpHighRes
          BumpAmount = 0.1
          //TexLodBias = 1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
//#endif



//#ifdef OTHER
/*
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.8  Comp = 0.8 Comp = 0.3 Comp = 1 )

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          BumpHighRes
          BumpAmount = 0.8
          TexLodBias = 0.5
          Sequence (Maps = textures/animated/water/caust##00_31 Time = 0.05 Loop)
          TexColorOp = NoSet
        )

        Layer '1'
        (
          Map = $None
          TexColorOp = NoSet
        )

        Layer '2'
        (
          Blend 'ONE ONE'        
          Map = $Phong_35
          TexLodBias = 1
          TexColorOp = NoSet
        )
      )
    )
//#endif
*/
  )

  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainWater_PS20'
(
  Public
  (
    float 'BumpAmountX' (0.01)
    float 'BumpAmountY' (0.01)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
    float 'WaveAmplitude' (0.0)
    float 'ReflectAmount' (1.0)
    float 'Opacity' (1)   
    float 'WaveSpeedX' (0.05)
    float 'WaveSpeedY' (0.1)
    float 'NoiseSpeed' (0.1)
    float 'FadeBias' (0.25)
    float 'FadeExp' (4.0)
    float 'WaveScaleX' (0.1)
    float 'WaveScaleY' (0.15)
    float 'WaveScaleZ' (0.1)
    
    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back    
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    //UpdateFactor = 0.001
    FullDetailTerrain
    DrawTerrain
  }

  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)


    // water refraction pass (cheap)
#ifdef PROJECTEDENVBUMP
    WATER_REFRACTION
#endif    

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        //Sequence(Maps = textures/animated/water/caust## Time = 0.05 Loop)
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader = CGRCWater_PS20
      CGPSParam (Name = FadeParams User 'FadeBias' User 'FadeExp')
      CGPSParam (Name = TimeParams User 'WaveSpeedX' User 'WaveSpeedY' User 'NoiseSpeed' Comp 'Time 1')
      CGPSParam (Name = BumpScale User 'BumpAmountX' User 'BumpAmountY' )
      CGPSParam (Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      
      CGVProgram = CGVProgWater_VS20
      CGVPParam (Name = Scale User 'WaveScaleX' User 'WaveScaleY' User 'WaveScaleZ')
      CGVPParam (Name = Normal Comp = 0 Comp = 0 Comp = 1)
      CGVPParam (Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam (Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam (Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam (Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam (Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam (Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0' 
      ( 
        Map = $NoiseVolume
        TexType = Volume
        //TexFilter = TriLinear
        TexColorOp = NoSet
      ) 
      Layer '1'
      (
        Map = $WaterMap
        //Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 30 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          BumpAmount = 0.1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainWater_TempleRiver'
(
  Public
  (
    float 'BumpAmountX' (0.07)
    float 'BumpAmountY' (0.42)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
    float 'WaveAmplitude' (0.1)
    float 'ReflectAmount' (0.9)
    float 'ReflectAddAmount' (0.2)
    float 'Opacity' (1)    
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    //ClipPlane = Back
  )
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    //DrawIndoors
    UpdateFactor = 0.001
    FullDetailTerrain
    DrawTerrain
  }

  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Refr
      CGPSParam ( Name = Matrix User 'RefrBumpAmountX' Comp = 0 Comp = 0 User 'RefrBumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color

      CGVProgram = CGVProgWater_Refr
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12' Comp = 0.5)  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )

      Layer '1'
      (
        Map = $EnvironmentTexture
        Projected
          
        //Texgen = Projection
        TexColorOp = NoSet
      )
    )

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        //Sequence(Maps = textures/animated/water/caust## Time = 0.05 Loop)
        Map = water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'  
      (
        TexType = DSDTBump 
        TexFilter = TriLinear 
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop ) 
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm //water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  // low/med spec shader
  LOWSPEC_WATER_SHADER  
)

Shader 'TerrainWater_FP'
(
  Public
  (
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '0'
      (
        Sequence
        (
          Maps = textures/animated/water/caust_xb_##00_00
          Time = 0.5 
          Loop
        ) 
          
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'time 0.1')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
        }       
        TexColorOp = modulate
        TexAlphaOp = add
        TexColorArg0 = Diffuse
        TexColorArg1 = Texture
        TexAlphaArg0 = Diffuse
        TexAlphaArg1 = Constant
      )
    
      Layer '1'  
      (
        Sequence
        (
          Maps = textures/animated/water/caust_xb_##00_00
          Time = 0.5 
          Loop
        ) 

        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.060 Comp = 0 Comp = 0 Comp 'time -0.1')
          PlaneT (Comp = 0 Comp = 0.060 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate
        RgbGen 'Fixed' (1 1 1 0.2)

        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        DepthWrite = 0
      )
    )
  )
)

Shader 'TerrainWaterNoRefl'
(
  Public
  (
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '0'
      (
        Map = water_simple
          
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'time 0.1')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate
      )
    
      Layer '1'  
      (
        Sequence
        (
          Maps = textures/animated/water/caust##00_31
          Time = 0.05 
          Loop
        ) 

        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.062 Comp = 0 Comp = 0 Comp 'time -0.1')
          PlaneT (Comp = 0 Comp = 0.062 Comp = 0 Comp = 0)
        }       
        TexColorOp = Modulate

        Blend 'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        DepthWrite = 0
      )
    )
  )
)

Shader 'TerrainRiver'
(
  Public
  (
    float 'BumpAmountX' (0.15)
    float 'BumpAmountY' (0.2)
    float 'WaveAmplitude' (0.1)    
  )
  
  Params
  (
    Sort = Water
    //Cull = TwoSided
    ClipPlane = Front    
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawDetailTextures
    UpdateFactor = 0.001
  }
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_Lake
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        Sequence(Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TemplMirror'
(
  Params
  (
    Sort = Opaque
    //Cull = TwoSided
    ClipPlane = Front
  )
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawDetailTextures
    UpdateFactor = 0.001
    DrawPlayer
  }
  
  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader = CGRCMirror
      CGPSParam ( Name = Color Comp = 1 Comp = 1 Comp = 1 Comp = 0.85)  // Water color

      CGVProgram = CGVProgMirror
      CGVPParam ( Name = TexMatrix TranspTexViewProjMatrix = 0)  // Texture matrix for projection

      Layer '0'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'TerrainLake'
(
  Public
  (
    float 'BumpAmountX' (0.04)
    float 'BumpAmountY' (0.06)
    float 'WaveAmplitude' (0.1)
    float 'Opacity' (0.9)
    float 'ReflectAmount' (1)
  )
  
  Params
  (
    Sort = Water
    //Cull = TwoSided
    ClipPlane = Front
  )
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawWater
    DrawDetailTextures
    DrawDetailObjects
    FullDetailTerrain
    DrawTerrain
    UpdateFactor = 0.001
  }
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }
    }
      
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 FLOAT Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_Lake
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm_lake
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainLake_NoFresnel'
(
  Public
  (
    float 'BumpAmountX' (0.04)
    float 'BumpAmountY' (0.06)
    float 'WaveAmplitude' (0.1)
    float 'Opacity' (0.9)
    float 'ReflectAmount' (1)    
  )
  
  Params
  (
    Sort = Water
    //Cull = TwoSided
    ClipPlane = Front
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawWater
    DrawDetailTextures
    DrawDetailObjects
    FullDetailTerrain
    DrawTerrain
    UpdateFactor = 0.001
  }
  
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }
    }
      
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 FLOAT Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_Lake
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = white
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm_lake
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainLake_Deformed'
(
  Public
  (
    float 'BumpAmountX' (0.15)
    float 'BumpAmountY' (0.2)
    float 'WaveAmplitude' (0.1)
    float 'Opacity' (0.9)
    float 'ReflectAmount' (1)    
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Front
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawWater
    DrawDetailTextures
    DrawDetailObjects
    FullDetailTerrain
    DrawTerrain
    UpdateFactor = 0.001
  }
  
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_Lake
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        Sequence(Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TemplLake'
(
  Public
  (
    float 'BumpAmountX' (0.015)
    float 'BumpAmountY' (0.02)
    float 'WaveAmplitude' (0.01)
    float 'Opacity' (0.9)
    float 'ReflectAmount' (1)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)

    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Front
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawWater
    DrawDetailTextures
    DrawDetailObjects
    FullDetailTerrain
    DrawTerrain
    UpdateFactor = 0.001
  }
  
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    WATER_REFRACTION
    
    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_LakeNoMove
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        Map = $Bump
        TexType = DSDTBump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Lake
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater_LakeNoMove
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        Map = $Bump
        TexType = DSDTBump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $EnvironmentTexture
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        //DepthWrite = 1
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  // include shader low spec water shader
  LOWSPEC_WATER_SHADER  
)

Shader 'TemplLakeRefr'
(
  Public
  (
    float 'BumpAmountX' (0.15)
    float 'BumpAmountY' (0.2)
    float 'WaveAmplitude' (0.1)
    float 'Opacity' (0.9)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawWater
    DrawDetailTextures
    DrawDetailObjects
    FullDetailTerrain
    DrawTerrain
    UpdateFactor = 0.001
  }
  
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterRefractions = 1
      }
    }  
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Refr
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color

      CGVProgram = CGVProgWater_LakeRefr
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        Map = $Bump
        TexColorOp = NoSet
      )

      Layer '1'
      (
        Map = $EnvironmentTexture
          
        //Texgen = Projection
        TexColorOp = NoSet
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {        
        r_WaterRefractions = 1
      }
    }  
    
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 Float Texture0)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPShader   = CGRCWater_Refr
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color

      CGVProgram = CGVProgWater_LakeRefr
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        Map = $Bump
        TexColorOp = NoSet
      )

      Layer '1'
      (
        Map = $EnvironmentTexture
          
        //Texgen = Projection
        TexColorOp = NoSet
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER    
)

Shader 'TerrainWater_OnlySky'
(
  Public
  (
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
    float 'WaveAmplitude' (0.1)
    float 'ReflectAmount' (0.9)
    float 'ReflectAddAmount' (0.2)
    float 'Opacity' (1)
    
    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back
  )
  
  RenderParams
  {
    FullDetailTerrain
    DrawTerrain
  }
  
  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    // water refraction pass (cheap)
#ifdef PROJECTEDENVBUMP
    WATER_REFRACTION
#endif    

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        //Sequence(Maps = textures/animated/water/caust## Time = 0.05 Loop)
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 30 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          //BumpHighRes
          BumpAmount = 0.1
          //TexLodBias = 1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'  
      (
        TexType = DSDTBump 
        TexFilter = TriLinear 
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop ) 
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
/*
#ifdef SUPPORT_PROFILE_PS_2_0
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 30 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          //BumpHighRes
          BumpAmount = 0.1
          //TexLodBias = 1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
#endif
*/
//#ifdef OTHER
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.8  Comp = 0.8 Comp = 0.3 Comp = 1 )

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          BumpHighRes
          BumpAmount = 0.8
          TexLodBias = 0.5
          Sequence (Maps = textures/animated/water/caust##00_31 Time = 0.05 Loop)
          TexColorOp = NoSet
        )

        Layer '1'
        (
          Map = $None
          TexColorOp = NoSet
        )

        Layer '2'
        (
          Blend 'ONE ONE'        
          Map = $Phong_35
          TexLodBias = 1
          TexColorOp = NoSet
        )
      )
    )
//#endif
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainWater_OnlySky_NoTerrain'
(
  Public
  (
    float 'BumpAmountX' (0.012)
    float 'BumpAmountY' (0.010)
    float 'RefrBumpAmountX' (0.012)
    float 'RefrBumpAmountY' (0.010)
    float 'WaveAmplitude' (0.1)
    float 'ReflectAmount' (0.9)
    float 'ReflectAddAmount' (0.2)
    float 'Opacity' (1)
    
    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back
  )
  
  RenderParams
  {
  }
  
  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    // water refraction pass (cheap)
#ifdef PROJECTEDENVBUMP
    WATER_REFRACTION
#endif    

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'
      (
        TexType = DSDTBump
        TexFilter = TriLinear
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        //Sequence(Maps = textures/animated/water/caust## Time = 0.05 Loop)
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 0
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    //Array (Texture0 2 Float Texture0)

    ShadeLayer
    (
      CGPShader   = CGRCWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp = 1 Comp = 1 Comp = 1 Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'Opacity')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color

      CGVProgram = CGVProgWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection

      Layer '0'  
      (
        TexType = DSDTBump 
        TexFilter = TriLinear 
        Sequence (Maps = textures/animated/water/caust##00_31_ddt Time = 0.05 Loop ) 
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = Defaults/fresnel14
        ClampTexCoords
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = water_lm
        TexColorOp = NoSet
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

/*
#ifdef SUPPORT_PROFILE_PS_2_0
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow_VS20
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow_PS20
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.6  Comp = 0.6 Comp = 0.4 Comp = 30 )
        CGPSParam ( Name = BumpAmount User 'BumpAmountX' User 'BumpAmountY' Comp=1)

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          //BumpHighRes
          BumpAmount = 0.1
          //TexLodBias = 1
          Sequence (Maps = textures/animated/water/caust##00_31_ddn Time = 0.05 Loop)
          TexColorOp = NoSet
          Blend 'ONE ONE'
        )
      )
    )
#endif
*/

//#ifdef OTHER
    Light
    (         
      ShadeLayer
      (
        CGVProgram = CGVProgBumpSunGlow
        CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
        CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
        CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
        CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
        CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1)  // Normal
        CGVPParam ( Name = Tangent Comp = 0 Comp = -1 Comp = 0 ) // Tangent

        CGPShader = CGRCBumpSunGlow
        //CGPSParam ( Name = Specular Comp 'SpecLightColor[0]'  Comp 'SpecLightColor[1]' Comp 'SpecLightColor[2]' Comp = 1 )
        CGPSParam ( Name = Specular Comp = 0.8  Comp = 0.8 Comp = 0.3 Comp = 1 )

        Layer '0'
        (
          TexType = Bumpmap
          //Map = test8
          BumpHighRes
          BumpAmount = 0.8
          TexLodBias = 0.5
          Sequence (Maps = textures/animated/water/caust##00_31 Time = 0.05 Loop)
          TexColorOp = NoSet
        )

        Layer '1'
        (
          Map = $None
          TexColorOp = NoSet
        )

        Layer '2'
        (
          Blend 'ONE ONE'        
          Map = $Phong_35
          TexLodBias = 1
          TexColorOp = NoSet
        )
      )
    )
//#endif

  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)

Shader 'TerrainDeepWater'
(
  Public
  (
    float 'BumpAmountX' (0.25)
    float 'BumpAmountY' (0.25)
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back
  )
  ClientEffect 'Ocean'
  {
    Depth = 1
    Gravity = 9.81
    Speed = 0.2
    WindDirection = 3.14
    WindSpeed = 45
    WaveHeight = 64
    DirectionalDependence = 4
    ChoppyWaveFactor = 0.0025
    SuppressSmallWavesFactor = 0.000001
  }
  RenderParams
  {
    //DrawFarSprites
    //DrawStaticObjects
    //DrawParticles
    //DrawEntities
    //DrawIndoors
    //DrawDetailTextures
    //UpdateFactor = 0.001
    FullDetailTerrain
    DrawTerrain
  }
  
  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterReflections = 1
      }
    }
    
    ShadeLayer
    (
      CGPShader   = CGRCOcean
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor0 Comp = 0.04 Comp = 0.148 Comp = 0.26 Comp = 1)  // Water color
      CGPSParam ( Name = WaterColor1 Comp = 0.16 Comp = 0.38 Comp = 0.45 Comp = 1)  // Water color

      CGVProgram = CGVProgOcean
      CGVPParam ( Name = CameraPos  Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0)
      CGVPParam ( Name = ColorMinFresnel Comp = 0.1 Comp = 0.1 Comp = 0.05 Comp = 1)  // Water color fresnel range
      CGVPParam ( Name = ColorMaxFresnel Comp = 1.2 Comp = 1.2 Comp = 1.05 Comp = 1)  // Water color fresnel range
      CGVPParam ( Name = RippleTexGen0 Comp = 0.0078125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 128')  // Ripple texgen
      CGVPParam ( Name = RippleTexGen1 Comp = 0 Comp = 0.0078125 Comp = 0 Comp 'CameraPos pos 1 / 128')  // Ripple texgen
      CGVPParam ( Name = WaterParams Comp 'WaterLevel' Comp = 0 Comp = 0.066 Comp = 0.5)  // Water level
      CGVPParam ( Name = PosScale Comp = 256 Comp = 256 Comp = 6 Comp = 1)  // Mesh Scale
      CGVPParam ( Name = Constants Comp = 0.000001 Comp = 8 Comp = -1 Comp = 8)                                // Curvature, power factor for fresnel term approximation
      CGVPParam ( Name = ReflectMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection
      
      Layer '0'
      (
        Map    = $FromRE
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $WaterMap
        Projected
        TexColorOp = NoSet
      )
    )
  )

  HW 'Seq'
  (
    ShadeLayer
    (      
      CGPShader   = CGRCOcean_NoRefl
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor0 Comp = 0.04 Comp = 0.148 Comp = 0.26 Comp = 1)  // Water color
      CGPSParam ( Name = WaterColor1 Comp = 0.16 Comp = 0.38 Comp = 0.45 Comp = 1)  // Water color

      CGVProgram = CGVProgOcean_NoRefl
      CGVPParam ( Name = CameraPos  Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0)
      CGVPParam ( Name = ColorMinFresnel Comp = 0.1 Comp = 0.1 Comp = 0.05 Comp = 1)  // Water color fresnel range
      CGVPParam ( Name = ColorMaxFresnel Comp = 1.2 Comp = 1.2 Comp = 1.05 Comp = 1)  // Water color fresnel range
      CGVPParam ( Name = RippleTexGen0 Comp = 0.0078125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 128')  // Ripple texgen
      CGVPParam ( Name = RippleTexGen1 Comp = 0 Comp = 0.0078125 Comp = 0 Comp 'CameraPos pos 1 / 128')  // Ripple texgen
      CGVPParam ( Name = WaterParams Comp 'WaterLevel' Comp = 0 Comp = 0.066 Comp = 0.5)  // Water level
      CGVPParam ( Name = PosScale Comp = 256 Comp = 256 Comp = 6 Comp = 1)  // Mesh Scale
      CGVPParam ( Name = Constants Comp = 0.00001 Comp = 8 Comp = -1 Comp = 8)                                // Curvature, power factor for fresnel term approximation
      CGVPParam ( Name = ReflectMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection
      CGVPParam ( Name = BaseTexGen0 Comp = 0.015625 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 64')  // Base texgen
      CGVPParam ( Name = BaseTexGen1 Comp = 0 Comp = 0.015625 Comp = 0 Comp 'CameraPos pos 1 / 64')  // Base texgen

      Layer '0'
      (
        Map    = $FromRE
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = water_lm          
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'TerrainOcean2'
(
  Public
  (
    float 'DynamicRange' (4)
  )
  Params
  (
    Sort = Water
    Cull = TwoSided
    //ClipPlane = Back
  )
  ClientEffect 'Ocean'
  {
  }
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors
    DrawDetailTextures
    UpdateFactor = 0.001
  }
  
  HW 'Seq'
  (
    //Array (Verts 3 FLOAT Vertex)
    //Array (Texture0 2 Float Texture0)
    //Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGPSHader = CGRCOcean2
      CGPSParam ( Name = WaterColor0 Comp = 0.64 Comp = 0.798 Comp = 0.86 Comp = 1)  // Water color
      CGPSParam ( Name = WaterColor1 Comp = 0.763 Comp = 1 Comp = 1 Comp = 1)  // Water color

      CGVProgram = CGVProgOcean2
      CGVPParam ( Reg = 4  Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0)
      CGVPParam ( Reg = 5 Comp = 0 Comp = 0.5 Comp = 1 Comp = 2)          // Constants
      CGVPParam ( Reg = 6 Comp = 1 Comp = 0 Comp = 0 Comp = 1)            // Constants
      CGVPParam ( Reg = 8 Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')  // Ripple texgen
      CGVPParam ( Reg = 9 Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')  // Ripple texgen
      CGVPParam ( Reg = 10 Comp 'time 0.06' Comp 'time 0.12')  // xy = ripple uv ADDer
      CGVPParam ( Reg = 11 Comp = 512 Comp = 512 Comp = 4 Comp = 1)  // Mesh Scale
      CGVPParam ( Reg = 13 Comp = 0.00001)                                // Curvature
      CGVPParam ( Reg = 14 Comp = 8)                                      // power factor for fresnel term approximation
      CGVPParam ( Reg = 15 User 'DynamicRange' Comp = 0.25  Comp = 0.15)  // factor for dynamic range of env map
      
      Layer '0'
      (
        TexType = Bumpmap
        Map = t00/white //test8
        //Sequence (Maps = textures/animated/water/caust## Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = $EnvironmentCubemap
        TexType = Cubemap
        TexColorOp = NoSet
      )
    )
  )
)

//==================================================================
//==================================================================
//==================================================================

Shader 'DuckWeed'
(
  Public
  (
    float 'WaveAmplitude' (0.1)
  )
  Params
  (
    Sort = WaterBeach
    Cull  = TwoSided
  )
  
  
  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    Array (Texture0 2 FLOAT Texture0)

    ShadeLayer
    (
      CGPShader = CGRCWater_DuckWeed
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      //MAIN WAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Translate and Scale waves are !!!synchronized!!! except that Scale is a bit lag behind translate to make waves scale down after(!!!) it reaches the sand
      CGVPParam
      (
        Name = TexShift
        
        // Translate
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.0025 Phase = 0.0  Freq = 0.5 }
        // Scale
        Comp 'Wave' { Type = sin Level = 1.5 Amp = 0  Phase = 0.15 Freq = 0.1 }
        // Noise
        Comp 'Wave' { Type = sin Level = 0.1 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )
      
      Layer '0'
      (
        Map      = OBJECTS\Natural\swamp_set\sw_duckweed_a
        //ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'TerrainWaterBeach'
(
  Public
  (
    float 'WaveAmplitude' (0.1)
    float 'AnimSpeed' (0.5)
    float 'RefrTillingAmount' (2.5)
    float 'RefrBumpAmount' (0.05)
  )
  Params
  (
    Sort = WaterBeach
    Cull  = TwoSided
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterBeachRefractions = 1
      }
    }
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    Array (Texture0 2 FLOAT Texture0)

    ShadeLayer
    (
      CGPShader = CGRCWater_Beach_Refr
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      CGPSParam ( Name = Matrix Comp =0.05 Comp = 0 Comp = 0 Comp =0.05 )
      
      CGVProgram = CGVProgWater_Beach_Refr
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.06' Comp 'time 0.12')
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')

      //MAIN WAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Translate and Scale waves are !!!synchronized!!! except that Scale is a bit lag behind translate to make waves scale down after(!!!) it reaches the sand
      CGVPParam
      (
        Name = TexShift
        
        // Translate
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.0  Freq = 0.1 }
        // Scale
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.15 Freq = 0.1 }
        // Noise
        Comp = 0
        Comp = 1
      )
      
      Layer '0'
      (      
        Map =   fire_noise.dds
        TexType = DSDTBump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map      = wave1
        ClampTexCoords
        TexColorOp = NoSet
        DepthWrite = 0
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

    //COPY OF MAIN WAVE!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach_Refr
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)      
      CGPSParam ( Name = Matrix Comp =0.05 Comp = 0 Comp = 0 Comp =0.05 )
      
      CGVProgram = CGVProgWater_Beach_Refr
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.06' Comp 'time 0.12')
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.4 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.55 Freq = 0.1 }
        Comp = 0
        Comp = 1
      )
      
      Layer '0'
      (      
        Map =   fire_noise.dds
        TexType = DSDTBump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map      = wave1
        ClampTexCoords
        TexColorOp = NoSet
        DepthWrite = 0
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

    //another COPY OF MAIN WAVE(detail )!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach_Refr
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      CGPSParam ( Name = Matrix Comp =0.05 Comp = 0 Comp = 0 Comp =0.05 )
      
      CGVProgram = CGVProgWater_Beach_Refr
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.06' Comp 'time 0.12')
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.5 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9 Phase = 0.65 Freq = 0.1 }
        Comp = 0
        Comp = 1
      )
      
      Layer '0'
      (      
        Map =   fire_noise.dds
        TexType = DSDTBump
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map      = wave1
        ClampTexCoords
        TexColorOp = NoSet
        DepthWrite = 0
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )

    // Moving detail layer!!!!!!!!!!!!!!!!!!!
    ShadeLayer
    (
      CGVProgram = CGVProgWater_Beach_Shift
      CGVPParam ( Name = TexShift Comp = 0 Comp 'time 0.2') // xy = wavepos, z = 0, w = amplitude
      CGVPParam ( Name = TexScale Comp = 1.25 Comp = 3) // xy = wavepos, z = 0, w = amplitude
      
      Layer '0'
      (
        Map      = water2.tga

        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = Modulate
      )
    )
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    Array (Texture0 2 FLOAT Texture0)

    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      //MAIN WAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Translate and Scale waves are !!!synchronized!!! except that Scale is a bit lag behind translate to make waves scale down after(!!!) it reaches the sand
      CGVPParam
      (
        Name = TexShift
        
        // Translate
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.0  Freq = 0.1 }
        // Scale
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.15 Freq = 0.1 }
        // Noise
        Comp 'Wave' { Type = sin Level = 0.2 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )
      
      Layer '0'
      (
        Map      = wave1
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    //COPY OF MAIN WAVE!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.4 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.55 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 0.1 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )
      
      Layer '0'
      (
        Map      = wave1
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    //another COPY OF MAIN WAVE(detail )!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.5 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9 Phase = 0.65 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 0.3 Amp = 0 Phase = 0 Freq = 0.1    }
        Comp = 0.5
      )
      
      Layer '0'
      (
        Map      = water1

        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    // Moving detail layer!!!!!!!!!!!!!!!!!!!
    ShadeLayer
    (
      CGVProgram = CGVProgWater_Beach_Shift
      CGVPParam ( Name = TexShift Comp = 0 Comp 'time 0.2') // xy = wavepos, z = 0, w = amplitude
      CGVPParam ( Name = TexScale Comp = 1.25 Comp = 3) // xy = wavepos, z = 0, w = amplitude
      
      Layer '0'
      (
        Map      = water2.tga

        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = Modulate
      )
    )
  )
)

//==============================================================================================================
//==============================================================================================================
Shader 'TerrainWaterBeachResearch'
(
  Public
  (
    float 'WaveAmplitude' (0.1)
  )
  Params
  (
    Sort = WaterBeach
    Cull  = TwoSided
  )
  
  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    Array (Texture0 2 FLOAT Texture0)

    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      //MAIN WAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Translate and Scale waves are !!!synchronized!!! except that Scale is a bit lag behind translate to make waves scale down after(!!!) it reaches the sand
      CGVPParam
      (
        Name = TexShift
        
        // Translate
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.0  Freq = 0.1 }
        // Scale
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.15 Freq = 0.1 }
        // Noise
        Comp 'Wave' { Type = sin Level = 0.2 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )
      
      Layer '0'
      (
        Map      = wave2
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    //COPY OF MAIN WAVE!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.4 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.55 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 0.1 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )
      
      Layer '0'
      (
        Map      = wave2
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    //another COPY OF MAIN WAVE(detail )!! shifted phase  to make it move different 
    ShadeLayer
    (
      CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.5 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9 Phase = 0.65 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 0.3 Amp = 0 Phase = 0 Freq = 0.1    }
        Comp = 0.5
      )
      
      Layer '0'
      (
        Map      = water1

        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )

    // Moving detail layer!!!!!!!!!!!!!!!!!!!
    ShadeLayer
    (
      CGVProgram = CGVProgWater_Beach_Shift
      CGVPParam ( Name = TexShift Comp = 0 Comp 'time 0.2') // xy = wavepos, z = 0, w = amplitude
      CGVPParam ( Name = TexScale Comp = 1.25 Comp = 3) // xy = wavepos, z = 0, w = amplitude
      
      Layer '0'
      (
        Map      = water2.tga

        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = Modulate
      )
    )
  )
)

//==============================================================================================================

//==============================================================================================================

Shader 'TerrainWaterBeach_FP'
(
  Public
  (
    float 'WaveAmplitude' (0.1)
  )
  Params
  (
    Sort = WaterBeach
    Cull  = TwoSided
  )
  HW
  (
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    Array (Texture0 2 FLOAT Texture0)

    ShadeLayer
    (
      //CGPShader = CGRCWater_Beach
      //CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      //CGVProgram = CGVProgWater_Beach
      //CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      //MAIN WAVE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Translate and Scale waves are !!!synchronized!!! except that Scale is a bit lag behind translate to make waves scale down after(!!!) it reaches the sand
      /*
      CGVPParam
      (
        Name = TexShift
        
        // Translate
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.0  Freq = 0.1 }
        // Scale
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.15 Freq = 0.1 }
        // Noise
        Comp 'Wave' { Type = sin Level = 0.2 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )*/
      
      Matrix 'GL_TEXTURE'
      {
  	    TexStage = 0
        Identity
        Translate (Comp = 0 Comp 'Wave' { Type = sin Level = 0.1 Amp = 0.25 Phase = 0  Freq = 0.1 } Comp = 0)
        Scale (Comp=1 Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.15 Freq = 0.1 } Comp=1)
      }
      Layer '0'
      (
        Map      = wave1
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = Modulate        
      )
    )

    //COPY OF MAIN WAVE!! shifted phase  to make it move different 
    ShadeLayer
    (
      /*CGPShader = CGRCWater_Beach
      CGPSParam ( Name = Ambient Comp = 1 Comp = 1 Comp = 1 Comp = 1)
      
      CGVProgram = CGVProgWater_Beach
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam
      (
        Name = TexShift
        Comp 'Wave' { Type = sin Level = 0 Amp = 0.25 Phase = 0.4 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 2 Amp = 0.9  Phase = 0.55 Freq = 0.1 }
        Comp 'Wave' { Type = sin Level = 0.1 Amp = 0  Phase = 0.0  Freq = 0.1 }
        Comp = 1
      )*/
      
      Matrix 'GL_TEXTURE'
      {
  	    TexStage = 0
        Identity
        Translate (Comp = 0 Comp 'Wave' { Type = sin Level = 0.1 Amp = 0.25 Phase = 0.1  Freq = 0.1 } Comp = 0)
        Scale (Comp=1 Comp=2 Comp=1)
      }
      Layer '0'
      (
        Map      = wave1
        ClampTexCoords
        Blend     'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'WaterSimple1'
(
  HW 'Seq'
  (
    ShadeLayer
    (
      CGPShader = CGReflectCMap

      CGVProgram = CGVProgWaterBumpReflCM_PS
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = Binormal Comp = 0 Comp = -1 Comp = 0 ) // Binormal
      CGVPParam ( Name = Normal Comp = 0 Comp = 0 Comp = 1 )  // Normal
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.06' Comp 'time 0.12' Comp=0)  // xy = ripple uv ADDer

      CGVPParam ( Name = Matrix InvObjMatrix)

      Layer '0'
      (
        TexType = Base
        Sequence (Maps = textures/animated/water/caust## Time = 0.05 Loop)
        TexColorOp = NoSet
      )
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet
      )
      Layer '3'
      (
        Map = Skys/Sky4/box
        TexType = Cubemap
        TexColorOp = NoSet
      )
    )
  )
)

Shader 'TerrainWaterBottom'
(
  Params
  (
    Sort = Opaque
//    Cull                   = TwoSided
  )
  
  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)
    //Array (Color 4 BYTE Color)

    ShadeLayer
    (
      CGVProgram = CGVProgTerrainCaust
      CGVPParam ( Name = BaseTexGen0 Comp = 0 Comp 'FromRE[2]' Comp = 0 Comp 'FromRE[0]')  // TexGen S
      CGVPParam ( Name = BaseTexGen1 Comp 'FromRE[2]' Comp = 0 Comp = 0 Comp 'FromRE[1]')  // TexGen T
      CGVPParam ( Name = WaterLevel Comp 'WaterLevel')  
      CGVPParam ( Name = CaustTexGen0 Comp = 0.125 Comp = 0 Comp = 0 Comp 'time 0.06')
      CGVPParam ( Name = CaustTexGen1 Comp = 0 Comp = 0.125 Comp = 0 Comp 'time 0.12')
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.0125)  // .w - 1 / caustics view dist

      CGPShader = CGRCTerrain_Caust
      // Ambient
      CGPSParam ( Name = Ambient Comp 'WorldColor[0]'  Comp 'WorldColor[1]' Comp 'WorldColor[2]' Comp = 1 )
      Layer '0'
      (
        Map = terrain/water/oceanfloorcolor.bmp
        TexColorOp = NoSet
      )

      Layer '1'
      (
        Sequence (Maps = textures/animated/water/causq## Time = 0.05 Loop)
        TexColorOp = NoSet
        
        
      )
    )
  )
)


Shader 'TerrainWaterBottom_FP'
(
  Params
  (
    Sort = Opaque
//    Cull                   = TwoSided
  )
  HW
  (
    Array (Verts 3 FLOAT Vertex)
    //Array (Color 4 BYTE Color)

    ShadeLayer
    (
      /*
      CGVProgram = CGVProgTerrainCaust
      CGVPParam ( Name = BaseTexGen0 Comp = 0 Comp 'FromRE[2]' Comp = 0 Comp 'FromRE[0]')  // TexGen S
      CGVPParam ( Name = BaseTexGen1 Comp 'FromRE[2]' Comp = 0 Comp = 0 Comp 'FromRE[1]')  // TexGen T
      CGVPParam ( Name = WaterLevel Comp 'WaterLevel')  
      CGVPParam ( Name = CaustTexGen0 Comp = 0.125 Comp = 0 Comp = 0 Comp 'time 0.06')
      CGVPParam ( Name = CaustTexGen1 Comp = 0 Comp = 0.125 Comp = 0 Comp 'time 0.12')
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.0125)  // .w - 1 / caustics view dist

      CGPShader = CGRCTerrain_Caust
      // Ambient
      CGPSParam ( Name = Ambient Comp 'WorldColor[0]'  Comp 'WorldColor[1]' Comp 'WorldColor[2]' Comp = 1 )
      */
      Layer '0'
      (
        Map = terrain/water/oceanfloorcolor.bmp
        TexColorOp = NoSet
      )

      Layer '1'
      (
        Sequence (Maps = textures/animated/water/causq## Time = 0.05 Loop)
        TexColorOp = NoSet
      )
    )
  )
)

// Lava Volume Shader
Shader 'LavaVolume'
(
  Public
  (
    float 'TillingAmountX' (2.0)
    float 'TillingAmountY' (2.0)
    float 'BumpAmountX' (0.02)
    float 'BumpAmountY' (0.02)
    float 'MoveSpeedX' (0.2)
    float 'MoveSpeedY' (0.2)
    float 'ColorR' (0.8)
    float 'ColorG' (0.55)
    float 'ColorB' (0.0)
    float 'OverlayAmount' (0.32)
    float 'DetailTillingAmountX' (1.0)
    float 'DetailTillingAmountY' (1.0)
    float 'DetailMoveSpeedX' (0.2)
    float 'DetailMoveSpeedY' (0.2)                               
    float 'WaveAmplitude' (0.1)    
  )  
                  
  HW 'Seq'
  (              
    Array (Verts 3 FLOAT Vertex)
            
    ShadeLayer
    (       

      CGVProgram  = CGVProgLava
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = TexShiftRipple User 'MoveSpeedX' User 'MoveSpeedY' Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexDetailScale User 'TillingAmountX' User 'TillingAmountY')
      CGVPParam ( Name = BumpMatrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )      
      CGVPParam ( Name = DetailTexParams User 'DetailTillingAmountX' User 'DetailTillingAmountY' User 'DetailMoveSpeedX' User 'DetailMoveSpeedY')
      CGPShader   = CGRCLava
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp = 1)
      CGPSParam ( Name = LavaColor User 'ColorR'  User 'ColorG' User 'ColorB' User 'OverlayAmount')      


      Layer '0'
      (
        Map = $Diffuse
        TexColorOp = NoSet 
      )
      
      Layer '1'
      (                
        Map = WaterBump.dds        
        TexColorOp = NoSet
        TexType = DSDTBump                  
      )

      Layer '2'
      (                
        Map = Defaults/white_plain_d                       
        TexColorOp = NoSet       
      )                  
    )
  )  
)

// Lava Volume Shader
Shader 'LavaVolume_FP'
(
  Public
  (
    float 'TillingAmountX' (2.0)
    float 'TillingAmountY' (2.0)
  )
  Params
  (
    Sort = Water
    Cull = TwoSided  
    NoLight
  )

                 
  HW 'Seq'
  (              
    Array (Verts 3 FLOAT Vertex)
            
    ShadeLayer
    (       
      Layer '0'
      (               
        TexType = Base
        TexFilter = TriLinear        
        Sequence (Maps = textures/animated/water/caust## Time = 0.05 Loop)
                
        TexGen               'HW_ObjectLinear'  
        { 
          Mask = 3  
          PlaneS (User 'TillingAmountX' Comp = 0 Comp = 0 Comp = 0)
          PlaneT (Comp = 0 User 'TillingAmountY' Comp = 0 Comp = 0)
        } 
        
        RgbGen 'Comp' (Comp =1  Comp =0.6 Comp=0.2 Comp = 1)
        
        TexColorOp = AddSigned
        TexAlphaOp = Replace  
        TexColorArg0 = Texture        
        TexColorArg1 = Constant        
        TexAlphaArg0 = Previous
        
        Blend 'ONE SRC_COLOR'  
        //DepthWrite = 0   
        
      )      
    )
  )  
)


// Fire Shader 
Shader 'FireVolume'
(
  Public
  (
    float 'BumpAmountX' (0.2)
    float 'BumpAmountY' (0.02)
   
    float 'Saturation' (0.0)
    float 'Brightness' (0.2)
    float 'FireOpacity' (1.0)

    float 'DetailTillingAmountX' (2.0)
    float 'DetailTillingAmountY' (5.0)
    float 'DetailMoveSpeedX' (20.0)
    float 'DetailMoveSpeedY' (0.0)                               
  )  
  
  Params
  (
    Sort = TerrainParticles
  )
        
  HW 'Seq'
  (              
    Array (Verts 3 FLOAT Vertex)
    Array (Texture0 2 FLOAT Texture0)    
    Array (Color 4 BYTE Color)
                
    ShadeLayer
    (       
      CGVProgram  = CGVProgFire
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = TexShiftRipple Comp =1 Comp = 1 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)             
      CGVPParam ( Name = DetailTexParams User 'DetailTillingAmountX' User 'DetailTillingAmountY' User 'DetailMoveSpeedX' User 'DetailMoveSpeedY')
      
      CGPShader   = CGRCFire
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )      
      CGPSParam ( Name = LavaColor Comp = 1 Comp = 1 Comp = 1 User 'FireOpacity')      
      CGPSParam ( Name = ColorParams Comp = 1 Comp = 1 User 'Brightness' User 'Saturation')      
                  
      Layer '0'
      (                
        Map = fire_noise.dds        
        TexColorOp = NoSet
      )

      Layer '1'
      (                
        Map = fire_static.dds
        TexColorOp = NoSet       
        ClampTexCoords
        
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        AlphaFunc  = GT0
        DepthWrite = 0        
      )                              
    )
  )  
)

Shader 'TerrainWaterBottomSimple'
(
  Params
  (
    Sort = Opaque
    Cull = TwoSided
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)

    ShadeLayer
    (
      CGVProgram = CGVProgTexGen_1Unit
	    CGVPParam ( Name = BaseTexGen0 Comp = 0.05 Comp = 0 Comp = 0 Comp = 0 )  // TexGen S
		  CGVPParam ( Name = BaseTexGen1 Comp = 0 Comp = 0.05 Comp = 0 Comp = 0 )  // TexGen T
      CGVPParam ( Name = ObjMatrix TranspObjMatrix)
		  
#ifdef HDR
      CGPShader = CGRC_HDR_AmbBase_Fog_PS20
#endif
		  
      Layer '0'
      (
        //Map = terrain/water/oceanfloorcolor.bmp
        Map = $FromRE
        TexColorOp = Replace
      )    
    )
  )
)

Shader 'TerrainWaterBottomSimple_FP'
(
  Params
  (
    Sort = Opaque
    Cull = TwoSided
  )

  HW 'Seq'
  (
    Array (Verts 3 FLOAT Vertex)

    ShadeLayer
    (
      Layer '0'
      (
        Map = $FromRE
        TexGen 'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.05 Comp = 0 Comp = 0 Comp = 0)
          PlaneT (Comp = 0 Comp = 0.05 Comp = 0 Comp = 0)
        }
		  
        TexColorOp = Replace
      )    
    )
  )
)

// generic indoor water shader (using difuse component for color)
Shader 'WaterVolume'
(
  Public
  (
    // artists should tweak this..
    
    // reflection parameters        
    float 'ReflTillingAmount' (0.2)       // set reflection texture tilling amount
    float 'ReflBumpAmount' (0.5)          // set reflection bump amount
    float 'ReflAmount' (0.5)              // set reflection opacity
    float 'ReflSpecularAmount' (0.75)     // set reflection specular amount

    // animation parameters
    float 'AnimSpeed' (10.0)              // water animation speed
                
    // artists/designers dont need to tweak this, but if they want fell free..            
                    
    // refraction parameters
    float 'RefrTillingAmount' (2.0)       // refraction texture tilling amount
    float 'RefrBumpAmount' (0.05)         // refraction texture bump amount    
    
    float 'LowSpecOpacity' (0.85)
  )     
  
  Params
  (
    Sort= Water
    Cull = TwoSided
  )

// no support for perspective correct projected environment bump mapping? then no refraction..
#ifdef PROJECTEDENVBUMP 
      
  // hi/med spec shader                        
  HW 'Seq'
  (              
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }            
    }
  
    Array (Verts 3 FLOAT Vertex)
     
    // refraction pass
    ShadeLayer
    (    
      CGVProgram  = CGVProgIndoorWater_final      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')      
      CGVPParam ( Name = ScreenSize Comp 'ScreenSize pos 0' Comp 'ScreenSize pos 1' Comp = 0 Comp = 0)
      
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')     
                  
      CGPShader   = CGRCIndoorWater_final
      //CGPSParam ( Name = Matrix User 'RefrBumpAmount' Comp = 0 Comp = 0 User 'RefrBumpAmount' )
      // using now always fixed refraction amount..
      CGPSParmRect ( Name = Matrix Comp= 0.05 Comp = 0 Comp = 0 Comp = 0.05 )      
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp =1 )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' Comp =1 )
      

      Layer '0'
      (         
        Map =   fire_noise.dds
        TexType = DSDTBump  
      )
      
      Layer '1'
      (
        Projected
        Map =  $ScreenTexMap
                                
        TexColorOp = NoSet
        DepthWrite = 0        
      )
    )
 
    // reflection pass      
    ShadeLayer
    (       
      CGVProgram  = CGVProgIndoorWaterSpec      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexDetailScale User 'ReflTillingAmount' User 'ReflTillingAmount'  Comp = 0 User 'AnimSpeed')
      
      CGPShader   = CGRCIndoorWaterSpec
      CGPSParam ( Name = Matrix User 'ReflBumpAmount' Comp = 0 Comp = 0 User 'ReflBumpAmount' )
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' User 'ReflSpecularAmount' )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' User 'ReflAmount')  

      Layer '0'
      (        
        Map =  fire_noise.dds
        TexType = DSDTBump  
      )

      Layer '1'
      (                      
        Map = Defaults/white_plain_d                      
        TexColorOp = NoSet               
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )            
    )
  )  
  
#endif
  
  // render low spec water..
  LOWSPEC_WATER_SHADER    
)



// generic indoor water shader (using difuse component for color)
Shader 'WaterVolume2'
(
  Public
  (
    // artists should tweak this..
    
    // reflection parameters        
    float 'ReflTillingAmount' (0.2)       // set reflection texture tilling amount
    float 'ReflBumpAmount' (0.5)          // set reflection bump amount
    float 'ReflAmount' (0.4)              // set reflection opacity
    float 'ReflSpecularAmount' (0.75)     // set reflection specular amount

    // animation parameters
    float 'AnimSpeed' (5.0)              // water animation speed
                
    // artists/designers dont need to tweak this, but if they want fell free..            
                    
    // refraction parameters
    float 'RefrTillingAmount' (2.0)       // refraction texture tilling amount
    float 'RefrBumpAmount' (0.05)         // refraction texture bump amount    
    
    float 'LowSpecOpacity' (0.85)
  )     
  
  Params
  (
    Sort= Water
    Cull = TwoSided
  )

// no support for perspective correct projected environment bump mapping? then no refraction..
#ifdef PROJECTEDENVBUMP 
      
  // hi/med spec shader                        
  HW 'Seq'
  (              
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }            
    }
  
    Array (Verts 3 FLOAT Vertex)
     
    // refraction pass
    ShadeLayer
    (    
      CGVProgram  = CGVProgIndoorWater_final      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')      
      CGVPParam ( Name = ScreenSize Comp 'ScreenSize pos 0' Comp 'ScreenSize pos 1' Comp = 0 Comp = 0)
      
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')     
                  
      CGPShader   = CGRCIndoorWater_final
      //CGPSParam ( Name = Matrix User 'RefrBumpAmount' Comp = 0 Comp = 0 User 'RefrBumpAmount' )
      // using now always fixed refraction amount..
      CGPSParmRect ( Name = Matrix Comp= 0.05 Comp = 0 Comp = 0 Comp = 0.05 )      
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[4]'  Comp 'WorldObjColor[4]' Comp 'WorldObjColor[4]' Comp =1 )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' Comp =1 )
      

      Layer '0'
      (         
        Map =   fire_noise.dds
        TexType = DSDTBump  
      )
      
      Layer '1'
      (
        Projected
        Map =  $ScreenTexMap
                                
        TexColorOp = NoSet
        DepthWrite = 0        
      )
    )
 
    // reflection pass      
    ShadeLayer
    (       
      CGVProgram  = CGVProgIndoorWaterSpec      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexDetailScale User 'ReflTillingAmount' User 'ReflTillingAmount'  Comp = 0 User 'AnimSpeed')
      
      CGPShader   = CGRCIndoorWaterSpec
      CGPSParam ( Name = Matrix User 'ReflBumpAmount' Comp = 0 Comp = 0 User 'ReflBumpAmount' )
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[4]'  Comp 'WorldObjColor[4]' Comp 'WorldObjColor[4]' User 'ReflSpecularAmount' )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' User 'ReflAmount')  

      Layer '0'
      (        
        Map =  fire_noise.dds
        TexType = DSDTBump  
      )

      Layer '1'
      (                      
        Map = Defaults/white_plain_d                      
        TexColorOp = NoSet               
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )            
    )
  )  
  
#endif
  
  // render low spec water..
  LOWSPEC_WATER_SHADER    
)



// generic indoor water shader (using difuse component for color)
Shader 'WaterVolume3'
(
  Public
  (
    // artists should tweak this..
    
    // reflection parameters        
    float 'ReflTillingAmount' (0.0)       // set reflection texture tilling amount
    float 'ReflBumpAmount' (0.8)          // set reflection bump amount
    float 'ReflAmount' (0.2)              // set reflection opacity
    float 'ReflSpecularAmount' (0.75)     // set reflection specular amount

    // animation parameters
    float 'AnimSpeed' (5.0)              // water animation speed
                
    // artists/designers dont need to tweak this, but if they want fell free..            
                    
    // refraction parameters
    float 'RefrTillingAmount' (0.8)       // refraction texture tilling amount
    float 'RefrBumpAmount' (0.0)         // refraction texture bump amount    
    
    float 'LowSpecOpacity' (0.0)
  )     
  
  Params
  (
    Sort= Water
    Cull = TwoSided
  )

// no support for perspective correct projected environment bump mapping? then no refraction..
#ifdef PROJECTEDENVBUMP 
      
  // hi/med spec shader                        
  HW 'Seq'
  (              
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }            
    }
  
    Array (Verts 3 FLOAT Vertex)
     
    // refraction pass
    ShadeLayer
    (    
      CGVProgram  = CGVProgIndoorWater_final      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')      
      CGVPParam ( Name = ScreenSize Comp 'ScreenSize pos 0' Comp 'ScreenSize pos 1' Comp = 0 Comp = 0)
      
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')     
                  
      CGPShader   = CGRCIndoorWater_final
      //CGPSParam ( Name = Matrix User 'RefrBumpAmount' Comp = 0 Comp = 0 User 'RefrBumpAmount' )
      // using now always fixed refraction amount..
      CGPSParmRect ( Name = Matrix Comp= 0.05 Comp = 0 Comp = 0 Comp = 0.05 )      
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[4]'  Comp 'WorldObjColor[4]' Comp 'WorldObjColor[4]' Comp =1 )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' Comp =1 )
      

      Layer '0'
      (         
        Map =   eauverte.dds
        TexType = DSDTBump  
      )
      
      Layer '1'
      (
        Projected
        Map =  $ScreenTexMap
                                
        TexColorOp = NoSet
        DepthWrite = 0        
      )
    )
 
    // reflection pass      
    ShadeLayer
    (       
      CGVProgram  = CGVProgIndoorWaterSpec      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0) 
      CGVPParam ( Name = TexDetailScale User 'ReflTillingAmount' User 'ReflTillingAmount'  Comp = 0 User 'AnimSpeed')
      
      CGPShader   = CGRCIndoorWaterSpec
      CGPSParam ( Name = Matrix User 'ReflBumpAmount' Comp = 0 Comp = 0 User 'ReflBumpAmount' )
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[4]'  Comp 'WorldObjColor[3]' Comp 'WorldObjColor[5]' User 'ReflSpecularAmount' )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' User 'ReflAmount')  

      Layer '0'
      (        
        Map =  eauverte.dds
        TexType = DSDTBump  
      )

      Layer '1'
      (                      
        Map = Defaults/white_plain_d                      
        TexColorOp = NoSet               
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )            
    )
  )  
  
#endif
  
  // render low spec water..
  LOWSPEC_WATER_SHADER    
)


// indoor water volume, using static reflection environment cube mapping + refraction (alternate version to: TemplBumpReflCM)
// (using difuse component for color) and cube map amount
Shader 'WaterVolumeBumpReflCM'
(
  Public
  (
    // artists should tweak this..
    float 'BumpScale' (0.2)                             
    float 'ReflAmount' (0.5)              // set reflection opacity            
    
    // artists/designers dont need to tweak this, but if they want fell free..     
    
    // refraction parameters
    float 'RefrTillingAmount' (2.0)       // refraction texture tilling amount
    float 'RefrBumpAmount' (0.05)         // refraction texture bump amount
    
    // animation parameters
    float 'AnimSpeed' (20.0)              // water animation speed
    
    float 'LowSpecOpacity' (0.85)
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
  )
 
// no support for perspective correct projected environment bump mapping? then no refraction..
#ifdef PROJECTEDENVBUMP 
  // hi/med spec shader       
  HW 'Seq'
  (  
    Conditions
    {
      Vars
      {        
        r_WaterReflections = 1
      }            
    }
      
    // refraction pass
    ShadeLayer
    (    
      CGVProgram  = CGVProgIndoorWater_final      
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')      
      CGVPParam ( Name = ScreenSize Comp 'ScreenSize pos 0' Comp 'ScreenSize pos 1' Comp = 0 Comp = 0)
      
      CGVPParam ( Name = TexShiftRipple Comp = 0 Comp = 0 Comp 'time 0.01' Comp 'time 0.01') 
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  
      CGVPParam ( Name = TexDetailScale User 'RefrTillingAmount' User 'RefrTillingAmount'  Comp = 0 User 'AnimSpeed')     
                  
      CGPShader   = CGRCIndoorWater_final
      //CGPSParam ( Name = Matrix User 'RefrBumpAmount' Comp = 0 Comp = 0 User 'RefrBumpAmount' )
      // using now always fixed refraction amount..
      CGPSParam ( Name = Matrix Comp= 0.05 Comp = 0 Comp = 0 Comp = 0.05 )
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp =1 )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' Comp =1 )

      Layer '0'
      (         
        Map =   fire_noise.dds
        TexType = DSDTBump  
      )
      
      Layer '1'
      (
        Projected
        Map =  $ScreenTexMap
                        
        TexColorOp = NoSet
        DepthWrite = 0        
      )
    )
    
    // reflection pass
    ShadeLayer
    (
      CGPShader = CGWaterVolumeReflCM
      CGPSParam ( Name = Ambient Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp =1 )      
      CGPSParam ( Name = WaterColor Comp 'DiffuseColor[0]'  Comp 'DiffuseColor[1]' Comp 'DiffuseColor[2]' User 'ReflAmount' )
      
      CGVProgram = CGVProgWaterVolumeReflCM
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2')
      CGVPParam ( Name = ObjToCubeSpace InvObjMatrix)
      CGVPParam ( Name = BumpScale User 'BumpScale')      
      CGVPParam ( Name = AnimProperties Comp 'time 0.01' Comp 'time 0.01' Comp = 1 User 'AnimSpeed')

      Layer '0'
      (
        Map = $Bump
        TexType = BumpMap
        TexColorOp = NoSet
      )
      
      Layer '1'
      (
        Map = $None
        TexColorOp = NoSet
      )
      
      Layer '2'
      (
        Map = $None
        TexColorOp = NoSet        
      )
      
      Layer '3'
      (
        Map = $Cubemap
        TexType = Cubemap
        TexColorOp = NoSet
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'        
      )      
    )         
  )
#endif
  
  // render low spec water..
  LOWSPEC_WATER_SHADER    
)

Shader 'OceanWater'
(
  Public
  (
    float 'BumpAmountX' (0.5)
    float 'BumpAmountY' (0.5)
    float 'WaveAmplitude' (0.2)
    float 'ReflectAmount' (1.0)
    float 'Opacity' (1)   
    
    // water refraction shared parameters    
    WATER_REFRACTION_PARAMS
  )
  
  Params
  (
    Sort = Water
    Cull = TwoSided
    ClipPlane = Back    
  )
  
  RenderParams
  {
    DrawFarSprites
    DrawStaticObjects
    DrawParticles
    DrawEntities
    DrawIndoors    
    FullDetailTerrain
    DrawTerrain
  }

  HW
  (
    Conditions
    {
      Vars
      {
        r_PolygonMode = 2
      }
    }
    
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)

    ShadeLayer
    (
      Layer '1'
      (
        Map                  = Textures/liquids/W01blue03
        //Procedure            = HeavyRain01
        TexGen               'HW_ObjectLinear'
        {
          Mask = 3
          PlaneS (Comp = 0.125 Comp = 0 Comp = 0 Comp 'CameraPos pos 0 / 8')
          PlaneT (Comp = 0 Comp = 0.125 Comp = 0 Comp 'CameraPos pos 1 / 8')
        }
        Blend                'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
        //RgbGen               'Fixed' (0.6 0.6 0.6 0.6)
        TexColorOp = Modulate
        DepthWrite = 1
      )
    )
  )

  HW 'Seq'
  (
    Conditions
    {
      Vars
      {
        r_WaterRefractions = 1
        r_WaterReflections = 1
      }
    }
  
    Array (Verts 3 FLOAT Vertex)
    Array (Color 4 BYTE Color)
    
    // water refraction pass (cheap)
#ifdef PROJECTEDENVBUMP
    WATER_REFRACTION
#endif    

    ShadeLayer
    (
      CGPShader   = CGRCOceanWater
      CGPSParam ( Name = Matrix User 'BumpAmountX' Comp = 0 Comp = 0 User 'BumpAmountY' )
      CGPSParam ( Name = WaterColor Comp 'WorldObjColor[0]'  Comp 'WorldObjColor[1]' Comp 'WorldObjColor[2]' Comp = 1)  // Water color
      CGPSParam ( Name = ReflectAmount User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount' User 'ReflectAmount')  // Water color
      CGPSParam ( Name = ReflectAddAmount User 'ReflectAddAmount' User 'ReflectAddAmount' User 'ReflectAddAmount' Comp = 1)  // Water color
      CGPSParam ( Name = SpecularSun Comp 'SunColor[0]'  Comp 'SunColor[1]' Comp 'SunColor[2]' Comp = 1 )

      CGVProgram = CGVProgOceanWater
      CGVPParam ( Name = CameraPos Comp 'OSCameraPos pos 0' Comp 'OSCameraPos pos 1' Comp 'OSCameraPos pos 2' Comp = 0.15)
      CGVPParam ( Name = LightPos Comp 'SunFlarePos[0]' Comp 'SunFlarePos[1]' Comp 'SunFlarePos[2]' Comp=1)
      CGVPParam ( Name = AttenInfo Comp=100 Comp=0.01 Comp=0.5)
      CGVPParam ( Name = TexShiftRipple Comp 'time 0.0025' Comp 'time 0.0025')  // xy = ripple uv ADDer
      CGVPParam ( Name = TexGenRipple0 Comp = 0.125 Comp = 0 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexGenRipple1 Comp = 0 Comp = 0.125 Comp = 0 Comp = 0)  // Ripple texgen
      CGVPParam ( Name = TexDetailScale Comp = 0.08 Comp = 0.08 )  // xy = detail uv Scale
      CGVPParam ( Name = TexProjMatrix TranspTexViewProjMatrix = 1)  // Texture matrix for projection
      CGVPParam ( Name = BumpScale User 'BumpAmountX' User 'BumpAmountY' Comp=1)
      
      Layer '0'
      (
        TexType = Bumpmap
        TexFilter = TriLinear
        Map = waterbump        
        TexColorOp = NoSet
      )
      
      Layer '1'
      (
        Map = $WaterMap
        TexFilter = TriLinear
        Projected
        TexColorOp = NoSet
        Blend    'SRC_ALPHA ONE_MINUS_SRC_ALPHA'
      )
    )
  )
  
  // include shader low spec water shader
  LOWSPEC_WATER_SHADER
)
