vertex_program UnderwaterEffectVP cg
{
    source underwater.cg
    entry_point main_vp
    profiles vs_1_1 arbvp1

    default_params 
    {
        param_named_auto worldViewProj worldviewproj_matrix
    }
}


fragment_program UnderwaterEffectFP_NoMRT cg
{
    source underwater.cg
    entry_point main_fp_nomrt
    profiles ps_2_0 arbfp1
}

fragment_program UnderwaterEffectFP cg
{
    source underwater.cg
    entry_point main_fp
    profiles ps_2_0 arbfp1
}

vertex_program Water_VP cg
{
    source water.cg
    entry_point main_vp
    profiles vs_2_x arbvp1

    default_params
    {
        param_named_auto wvpMat worldviewproj_matrix
    }
}

fragment_program Water_FP cg
{
    source water.cg
    entry_point main_fp
    profiles ps_2_x arbfp1
}

material Water
{
    technique
    {
        pass
        {
            cull_hardware none

            vertex_program_ref Water_VP
            {
                param_named_auto camPosObjSpace camera_position_object_space
            }
            fragment_program_ref Water_FP
            {
                param_named_auto time time 0.1
                //param_named_auto fogColour fog_colour
                //param_named_auto fogParams fog_params
                param_named_auto renderTargetFlipping render_target_flipping
                param_named_auto far far_clip_distance
                param_named_auto lightPosObjSpace0 light_position_object_space 0
                param_named_auto lightSpecularColour0 light_specular_colour 0
                param_named isUnderwater float 0
            }

            texture_unit reflectionMap
            {
                texture WaterReflection
                tex_address_mode clamp
            }

            texture_unit refractionMap
            {
                tex_address_mode clamp
            }

            texture_unit depthMap
            {
                tex_address_mode clamp
            }

            texture_unit normalMap
            {
                texture WaterNormal2.tga
            }
        }
    }

    technique
    {
        scheme Fallback
        pass
        {
            cull_hardware none
            scene_blend alpha_blend
            depth_write off
            diffuse 0 0 0 1
            emissive 0.6 0.7 1.0
            ambient 0 0 0
            texture_unit
            {
                // texture names set via code
                scale 0.1 0.1
                alpha_op_ex source1 src_manual src_current 0.7
            }
        }
    }

}

material Water_Fallback
{
    technique
    {
        scheme Fallback
        pass
        {
            cull_hardware none
            scene_blend alpha_blend
            depth_write off
            diffuse 0 0 0 1
            emissive 0.6 0.7 1.0
            ambient 0 0 0
            texture_unit
            {
                // texture names set via code
                scale 0.1 0.1
                alpha_op_ex source1 src_manual src_current 0.7
            }
        }
    }
}

material Water/CompositorNoMRT
{
    technique
    {
        pass
        {
            depth_check off
            vertex_program_ref UnderwaterEffectVP
            {
                param_named_auto timeVal time 0.25
                param_named scale float 0.1
            }

            fragment_program_ref UnderwaterEffectFP_NoMRT
            {
            }

            texture_unit RT
            {
                    tex_coord_set 0
                tex_address_mode clamp
                filtering linear linear linear
            }

            texture_unit
            {
                texture WaterNormal2.tga 2d
                        tex_coord_set 1
                //tex_address_mode clamp
                filtering linear linear linear
            }
            texture_unit
            {
                texture caustic_0.png 2d
                        tex_coord_set 2
                //tex_address_mode clamp
                filtering linear linear linear
            }
        }
    }
}

material Water/Compositor
{
    technique
    {
        pass
        {
            depth_check off
            vertex_program_ref UnderwaterEffectVP
            {
                param_named_auto timeVal time 0.25
                param_named scale float 0.1
            }

            fragment_program_ref UnderwaterEffectFP
            {
                param_named_auto far far_clip_distance
            }

            texture_unit RT
            {
                tex_coord_set 0
                tex_address_mode clamp
            }

            texture_unit
            {
                texture WaterNormal2.tga 2d
                tex_coord_set 2
            }
            texture_unit
            {
                texture caustic_0.png 2d
                tex_coord_set 3
            }

            texture_unit DepthMap
            {
            }
        }
    }
}
