
//
// Asura_DeferredShading.h
//
// Created by DMR 13/02/07
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
// Handles deferred lighting passes
//

#ifndef __ASURA_DEFERREDSHADING_H__
#define __ASURA_DEFERREDSHADING_H__

#ifdef ASURA_TARGET_SM3

#include "Core/Asura_Maths.h"


class Asura_DeferredShading
{

public:
	static void Initialise(void);
	static void Shutdown(void);
	static void Reset(void);
	static void Render(void);
	static void RenderDebugOutput(void);

	static void AddConsoleCommands();
	
	// Debug modes enabled?
	static bool IsShowingDeferredBuffers(void)			{return s_bShowingDeferredBuffers;}
	static bool IsRenderingPhotonOutlines(void)			{return s_bShowingPhotonOutlines;}

	static bool IsShowingProjectorFrustums(void)		{return s_bShowProjectorFrustums;}	
	static bool IsShowingLightingComplexity(void)		{return s_bShowLightingComplexity;}
	static bool IsUsingZBufferOptimization(void)		{return s_bUseZBufferOptimization;}
	static bool GetUseCubesForPhotons(void)				{return s_bCubesForPhotons;}
	static bool GetUseStencilBuffer(void)				{return s_bUseStencilBuffer;}
	static bool GetShowStencils(void)					{return s_bShowStencils;}

	static void SetShowDeferredBuffers(bool bEnable)    {s_bShowingDeferredBuffers=bEnable;}
	static void SetRenderPhotonOutlines(bool bEnable)	{s_bShowingPhotonOutlines=bEnable;}

	// Functions to calculate primitives to be rendered...
	static void CalculateSphereData(const int iSphereRadialSegments, const int iSphereVerticalSegments, int& iNumVerts);
	static void CreateSphere(Asura_Vector_3 *pxVerts, const int iNumVerts, const int iSphereRadialSegments, const int iSphereVerticalSegments, const float fSphereRadiusScale);

	static void CalculateIndexedSphereData(const int iSphereRadialSegments, const int iSphereVerticalSegments, int& iNumVerts, int& iNumIndices);
	static void CreateIndexedSphere(Asura_Vector_2* pxVerts, const int iNumVerts, u_short* pusIndices, const int iNumIndices, const int iSphereRadialSegments, const int iSphereVerticalSegments);

	static void CalculateIndexedSphereSegmentData(const int iSphereRadialSegments, const int iSphereVerticalSegments, int& iNumVerts, int& iNumIndices);
	static void CreateIndexedSphereSegment(Asura_Vector_3* pxVerts, const int iNumVerts, u_short* pusIndices, const int iNumIndices, const int iSphereRadialSegments, const int iSphereVerticalSegments);

private:
	static void Platform_Initialise(void);
	static void Platform_Shutdown(void);
	static void Platform_Reset(void);	
	static void Platform_RenderDebugOutput(void);

	static void Platform_BeginRender(void);
	static void Platform_EndRender(void);

	static void RenderPhotons(bool bWithDarkeningShadows, bool bWithRealShadows, bool bWithNoShadows);
	static void Platform_RenderPhotons(bool bWithDarkeningShadows, bool bWithRealShadows, bool bWithNoShadows);	

	static Asura_Vector_3 GetPointOnSphere(float fElev,float fRad);

	static bool s_bShowingDeferredBuffers;
	static bool s_bShowingPhotonOutlines;
	static bool s_bShowProjectorFrustums;
	static bool s_bShowLightingComplexity;
	static bool s_bUseZBufferOptimization;
	static bool s_bCubesForPhotons;
	static bool s_bUseStencilBuffer;
	static bool s_bShowStencils;
};



#endif // ASURA_TARGET_SM3

#endif // __ASURA_DEFERREDSHADING_H__


