//==============================================================================================================================
bool MaterialShader::Initialize()
{
    ConstantBuffer<ZShadeSandboxLighting::cbMaterialShadingBuffer> shadingCB(m_pD3DSystem);
    shadingCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbMaterialShadingBuffer)));
    m_pShadingCB = shadingCB.Buffer();

    ConstantBuffer<cbMatrixBufferLight> matrixCB(m_pD3DSystem);
    matrixCB.Initialize(PAD16(sizeof(cbMatrixBufferLight)));
    m_pMatrixCB = matrixCB.Buffer();

    ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
    lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
    m_pLightCB = lightCB.Buffer();

    ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
    sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
    m_pSunCB = sunCB.Buffer();

    ClearInputLayout();

    LoadPixelShader("MaterialShaderPS");
    LoadPixelShader("MaterialShaderWireframePS");

    SetInputLayoutDesc("MaterialShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
    LoadVertexShader("MaterialShaderVS");
    AssignVertexShaderLayout("MaterialShader");

    SetInputLayoutDesc("MaterialShaderInstance", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex_instance, 4);
    LoadVertexShader("MaterialShaderInstanceVS");
    AssignVertexShaderLayout("MaterialShaderInstance");

    return true;
}
//==============================================================================================================================
bool TerrainTessellationQuadShadowShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();
	
	ConstantBuffer<cDomainConstBuffer> domainCB(m_pD3DSystem);
	domainCB.Initialize(PAD16(sizeof(cDomainConstBuffer)));
	m_pDomainCB = domainCB.Buffer();

	ConstantBuffer<cMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();
	
	ClearInputLayout();
	SetInputLayoutDesc("TerrainTessellationQuadShadowShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_tex, 2);
	
	LoadVertexShader("TerrainTessellationQuadVS");
	LoadHullShader("TerrainTessellationQuadShadowHS");
	LoadDomainShader("TerrainTessellationQuadDS");
	LoadPixelShader("TerrainTessellationShadowPS");
	
	AssignVertexShaderLayout("TerrainTessellationQuadShadowShader");
	
	return true;
}
//==============================================================================================================================
bool DeferredShader::Initialize()
{
	ConstantBuffer<cbPackBuffer> packCB(m_pD3DSystem);
	packCB.Initialize(PAD16(sizeof(cbPackBuffer)));
	m_pPackCB = packCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer> matrixCB(m_pD3DSystem);
	matrixCB.Initialize(PAD16(sizeof(cbMatrixBuffer)));
	m_pMatrixCB = matrixCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer2> matrix2CB(m_pD3DSystem);
	matrix2CB.Initialize(PAD16(sizeof(cbMatrixBuffer2)));
	m_pMatrix2CB = matrix2CB.Buffer();
	
	ClearInputLayout();
	
	SetInputLayoutDesc("DeferredShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("DeferredShaderVS");
	LoadPixelShader("DeferredShaderPS");
	LoadPixelShader("DeferredShaderWireframePS");
	
	AssignVertexShaderLayout("DeferredShader");
	
	return true;
}
//==============================================================================================================================
bool ShadowMapBuildShader::Initialize()
{
	ConstantBuffer<cbShadowMapConst> shadowMapCB(m_pD3DSystem);
	shadowMapCB.Initialize(PAD16(sizeof(cbShadowMapConst)));
	m_pShadowMapCB = shadowMapCB.Buffer();
	
	ClearInputLayout();
	//SetInputLayoutDesc("ShadowMapBuildShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos, 1);
	SetInputLayoutDesc("ShadowMapBuildShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("ShadowMapBuilderVS");
	LoadPixelShader("ShadowMapBuilderPS");
	
	AssignVertexShaderLayout("ShadowMapBuildShader");
	
	return true;
}
//==============================================================================================================================
bool OBJMeshShader::Initialize()
{
	ConstantBuffer<cbOBJShadingConst> objShadingCB(m_pD3DSystem);
	objShadingCB.Initialize(PAD16(sizeof(cbOBJShadingConst)));
	m_pOBJShadingCB = objShadingCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cbMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();
	
	ClearInputLayout();
	SetInputLayoutDesc("OBJMeshShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("OBJMeshVS");
	LoadPixelShader("OBJMeshPS");
	LoadPixelShader("OBJMeshWireframePS");
	
	AssignVertexShaderLayout("OBJMeshShader");
	
	return true;
}
//==============================================================================================================================
bool TriMaterialTessellationShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();
	
	ConstantBuffer<Const_Per_Frame> perFrameCB(m_pD3DSystem);
	perFrameCB.Initialize(PAD16(sizeof(Const_Per_Frame)));
	m_pPerFrameCB = perFrameCB.Buffer();
	
	ConstantBuffer<Const_Per_Object> perObjectCB(m_pD3DSystem);
	perObjectCB.Initialize(PAD16(sizeof(Const_Per_Object)));
	m_pPerObjectCB = perObjectCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
	m_pLightCB = lightCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
	sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
	m_pSunCB = sunCB.Buffer();
	
	ClearInputLayout();
	
	SetInputLayoutDesc("TriMaterialTessellationShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("MaterialTessellationShaderVS");
	LoadHullShader("TriMaterialTessellationShaderHS");
	LoadDomainShader("TriMaterialTessellationShaderDS");
	LoadPixelShader("MaterialTessellationShaderPS");
	LoadPixelShader("MaterialTessellationShaderWireframePS");
	
	AssignVertexShaderLayout("TriMaterialTessellationShader");
	
	bFlipHorizontally = false;
	bFlipVertically = false;
	
	return true;
}
//==============================================================================================================================
bool TerrainTessellationQuadSSAOShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();

	ConstantBuffer<cDomainConstBuffer> domainCB(m_pD3DSystem);
	domainCB.Initialize(PAD16(sizeof(cDomainConstBuffer)));
	m_pDomainCB = domainCB.Buffer();

	ConstantBuffer<cMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();

	ConstantBuffer<cShadingConstBuffer> shadingCB(m_pD3DSystem);
	shadingCB.Initialize(PAD16(sizeof(cShadingConstBuffer)));
	m_pShadingCB = shadingCB.Buffer();

	ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
	m_pLightCB = lightCB.Buffer();

	ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
	sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
	m_pSunCB = sunCB.Buffer();

	ClearInputLayout();
	SetInputLayoutDesc("TerrainTessellationQuadSSAOShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_tex, 2);

	LoadVertexShader("TerrainTessellationQuadVS");
	LoadHullShader("TerrainTessellationQuadShadowHS");
	LoadDomainShader("TerrainTessellationQuadDS");
	LoadPixelShader("TerrainTessellationNormalDepthPS");

	AssignVertexShaderLayout("TerrainTessellationQuadSSAOShader");

	return true;
}
//==============================================================================================================================
bool MaterialTessellationShader::Initialize()
{
	ConstantBuffer<ZShadeSandboxLighting::cbMaterialTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbMaterialTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbMaterialDomainBuffer> domainCB(m_pD3DSystem);
	domainCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbMaterialDomainBuffer)));
	m_pDomainCB = domainCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbMaterialShadingBuffer> shadingCB(m_pD3DSystem);
	shadingCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbMaterialShadingBuffer)));
	m_pShadingCB = shadingCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
	m_pLightCB = lightCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
	sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
	m_pSunCB = sunCB.Buffer();
	
	ClearInputLayout();
	SetInputLayoutDesc("MaterialTessellationShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	switch (mType)
	{
		case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
		{
			LoadVertexShader("QuadMaterialTessellationVS");
			LoadHullShader("QuadMaterialTessellationHS");
			LoadDomainShader("QuadMaterialTessellationDS");
			LoadPixelShader("QuadMaterialTessellationPS");
			LoadPixelShader("QuadMaterialTessellationWireframePS");
		}
		break;
		case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
		{
			LoadVertexShader("TriMaterialTessellationVS");
			LoadHullShader("TriMaterialTessellationHS");
			LoadDomainShader("TriMaterialTessellationDS");
			LoadPixelShader("TriMaterialTessellationPS");
			LoadPixelShader("TriMaterialTessellationWireframePS");
		}
		break;
	}
	AssignVertexShaderLayout("MaterialTessellationShader");
	
	// Instancing
	SetInputLayoutDesc("MaterialTessellationShaderInstance", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex_instance, 4);
	switch (mType)
	{
		case ZShadeSandboxLighting::EMaterialTessellationType::Type::eQuad:
		{
			LoadVertexShader("QuadMaterialTessellationInstanceVS");
		}
		break;
		case ZShadeSandboxLighting::EMaterialTessellationType::Type::eTri:
		{
			LoadVertexShader("TriMaterialTessellationInstanceVS");
		}
		break;
	}
	AssignVertexShaderLayout("MaterialTessellationShaderInstance");
	
	return true;
}