//=============================================================================
//// Shader uses position and texture
//=============================================================================
SamplerState samLin
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Mirror;
    AddressV = Mirror;
};

Texture2D gTexture;
float gNumScanlines = 3;
float gSmoothness = 0.2f;
float gIntensity = 0.1f;

/// Create Depth Stencil State (ENABLE DEPTH WRITING)
DepthStencilState stencilState
{
    DepthEnable = true;
};
/// Create Rasterizer State (Backface culling) 
RasterizerState backCulling
{
    CullMode = BACK;
};

//IN/OUT STRUCTS
//--------------
struct VS_INPUT
{
    float3 Position : POSITION;
	float2 TexCoord : TEXCOORD0;

};

struct PS_INPUT
{
    float4 Position : SV_POSITION;
	float2 TexCoord : TEXCOORD1;
};

//VERTEX SHADER
//-------------
PS_INPUT VS(VS_INPUT input)
{
	PS_INPUT output = (PS_INPUT)0;
    output.Position = float4(input.Position.xy, 0, 1);
    output.TexCoord = input.TexCoord;
	
	return output;
}


//PIXEL SHADER
//------------
float4 PS(PS_INPUT input): SV_Target
{
    float4 color = gTexture.Sample(samLin, input.TexCoord);
    float3 origScanline = (input.TexCoord.y * gNumScanlines) % 1;
    float3 hardScanline = round(origScanline);
    hardScanline = 1 - hardScanline * gIntensity;
    return float4(color.rgb * hardScanline, 1);
}


//TECHNIQUE
//---------
technique11 Blur
{
    pass P0
    {
		// Set states...
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader(CompileShader(ps_4_0, PS()));

        SetRasterizerState(backCulling);
        SetDepthStencilState(stencilState, 0);
    }
}