Index: GTP/trunk/App/Demos/Illum/DepthOfField/.params0
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/.params0	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/.params0	(revision 760)
@@ -0,0 +1,7 @@
+----- RayTraceEffects: Saved parameters of the algorithm -----
+Bool values:
+0
+(Show Help; )
+Float values:
+50 	(Focal Distance, 0..100)
+50 	(Scale, 0..100)
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.h	(revision 760)
@@ -0,0 +1,35 @@
+#pragma once
+
+class Mesh
+{
+	//IDirect3DDevice9* pd3dDevice;
+	ID3DXMesh* pMesh;
+
+	DWORD numMaterials;
+	D3DXVECTOR3 originalSize; 
+	float originalDiameter;
+	float preferredDiameter;
+	D3DXVECTOR3 position;
+	D3DXVECTOR3 containerSize;
+
+	HRESULT hr;
+
+public:
+	Mesh(float preferredDiameter);
+	Mesh(LPCWSTR fileName, float preferredDiameter, D3DXVECTOR3 offset);
+	~Mesh();
+	void Move(D3DXVECTOR3 movement);
+
+	void Load(LPCWSTR fileName); 
+
+	HRESULT Draw();
+	
+	D3DXVECTOR3 GetMeshSize()   { return GetMeshScale() * originalSize; }
+	float GetMeshScale()		{ return preferredDiameter / originalDiameter; }
+	D3DXVECTOR3 GetMeshOffset()	{ return position; }
+	void SetContainerSize(D3DXVECTOR3 size) { containerSize = size; }
+	void computeTangent();
+	
+protected:
+	HRESULT CalculateMeshSize( );
+};
Index: GTP/trunk/App/Demos/Illum/DepthOfField/GetFilePath.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/GetFilePath.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/GetFilePath.h	(revision 760)
@@ -0,0 +1,243 @@
+
+/* 
+GetFilePath.h
+
+A convenient way to search the NVSDK for media files
+*/
+
+
+#ifndef H_GETFILEPATH_H
+#define H_GETFILEPATH_H
+
+#include <windows.h>
+#include <TCHAR.H>
+#include <string>
+#include "shared/NV_Common.h"
+#include "shared/NV_Error.h"
+#include "shared/nvFileSearch.h"
+
+typedef std::basic_string<TCHAR> tstring; 
+
+namespace GetFilePath
+{
+	static tstring strStartPath;
+
+	typedef tstring (*GetFilePathFunction)(const tstring &, bool bVerbose );
+	
+	// This variable allows us to recursively search for media
+	class NVMediaSearch : public NVFileSearch
+	{
+		public:
+		tstring m_strPath;
+		virtual bool FileFoundCallback(const WIN32_FIND_DATA& FindData, const tstring& strDir)
+		{
+			UNREFERENCED_PARAMETER(FindData);
+			m_strPath = strDir;
+			
+			return false;
+		}
+	};
+
+
+	static tstring GetModulePath() { return strStartPath; }
+	static void        SetModulePath(const tstring &strPath)
+	{
+		tstring::size_type Pos = strPath.find_last_of(_T("\\"), strPath.size());
+		if (Pos != strPath.npos)
+			strStartPath = strPath.substr(0, Pos);
+		else
+			strStartPath = _T(".");
+	}
+
+	static void		SetDefaultModulePath()
+	{
+		DWORD ret;
+		TCHAR buf[MAX_PATH];
+		ret = GetModuleFileName( NULL, buf, MAX_PATH );		// get name for current module
+		if( ret == 0 )
+		{
+			FMsg(TEXT("SetDefaultModulePath() GetModuleFileName() failed!\n"));
+			assert( false );
+		}
+
+		SetModulePath( buf );
+	}
+
+
+	
+	static tstring GetFullPath(const tstring &strRelativePath)
+	{
+		TCHAR buf[MAX_PATH];
+		TCHAR *pAdr;
+		GetFullPathName(strRelativePath.data(), MAX_PATH, buf, &pAdr);
+		return buf;
+	}
+
+	//a helper class to save and restore the currentDirectory
+	class DirectorySaver
+	{
+	private:
+		TCHAR savedDirectory[MAX_PATH];
+	public:
+		DirectorySaver( )
+		{
+			// Save current directory
+			GetCurrentDirectory(MAX_PATH, savedDirectory);
+		}
+		~DirectorySaver( )
+		{
+	  		// return to previous directory
+	        SetCurrentDirectory(this->savedDirectory);
+		}
+	};
+
+    // Recursively searchs the given path until it finds the file. Returns "" if 
+    // file can't be found
+    static tstring FindMediaFile(const tstring &strFilename, const tstring &mediaPath, bool bVerbose = false )
+    {
+        WIN32_FIND_DATA findInfo;
+        HANDLE hFind;
+        tstring result;
+    
+        
+		//save and auto restore the current working directory
+		DirectorySaver whenIGoOutOfScopeTheCurrentWorkingDirectoryWillBeRestored;
+		
+        if (!SetCurrentDirectory(mediaPath.data()))
+		{
+			// DWORD tmp2 = GetLastError();
+			if( bVerbose )
+			{	
+				FMsg(TEXT("FindMediaFile Couldn't SetCurrentDirectory to [%s].  Returning empty string\n"), mediaPath.c_str() );
+			}
+            return _T("");
+		}
+
+        // check if file is in current directory
+        FILE *fp;
+        fp = _tfopen(strFilename.data(), _T("r"));
+        if (fp)
+        {
+            fclose(fp);
+            return mediaPath + _T("\\") + strFilename;
+        }
+		else
+		{	
+			if( bVerbose )
+			{
+				// report where the file is NOT
+				FMsg(TEXT("FindMediaFile: File [%s] is not in %s\n"), strFilename.c_str(), mediaPath.c_str() );
+			}
+		}
+    
+        // if file not in current directory, search for all directories
+        // and search inside them until the file is found
+        hFind = FindFirstFile( _T( "*.*" ) , &findInfo);
+        if (hFind == INVALID_HANDLE_VALUE)
+            return _T("");
+        
+        result = _T("");
+        do
+        {
+            if (findInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            {
+                // Make sure we don't try to delete the '.' or '..' directories
+                if ((_tcscmp(findInfo.cFileName, _T("..")) == 0) || (_tcscmp(findInfo.cFileName, _T(".")) == 0))
+                    continue;
+                
+				// Add directory to the media path
+				// Keep same original file name
+                result = FindMediaFile(strFilename, mediaPath + _T("\\") + findInfo.cFileName, bVerbose );
+                if (result != _T(""))
+                    break;                    
+            }
+        } while (FindNextFile(hFind, &findInfo));
+    
+        FindClose(hFind);
+        
+        return result;
+    }
+
+	//////////////////////////////////////////////////////////////////////////////
+	// Gets the full path to the requested file by searching in the MEDIA directory.
+    // (note: for a pointer to a 1-parameter version of this function, see below.)
+	static tstring GetFilePath(const tstring& strFileName, bool bVerbose )
+	{
+        // Check if strFilename already points to a file
+        FILE *fp;
+        fp = _tfopen(strFileName.data(), _T("r"));
+        if (fp)
+        {
+            fclose(fp);
+            return strFileName;
+        }
+
+		// You should call SetModulePath before using GetFilePath()
+		// If not, it will set the module path for you
+
+		tstring strMediaPath = GetModulePath();
+		if( strMediaPath.empty() == true )
+		{
+			SetDefaultModulePath();
+			strMediaPath = GetModulePath();
+		}
+
+		// Find the last occurrence of '\' or '/'
+		// This has the effect of backing up 4 directories, implying a direct dependence on
+		//  the location of the calling .exe in order to start looking for media in the right
+		//  place.  This is bad, so a more general search for the first subdirectory \MEDIA 
+		//  should be put in place
+		// TODO : see above
+    	strMediaPath = strMediaPath.substr(0, strMediaPath.find_last_of(_T("\\/")));
+	    strMediaPath = strMediaPath.substr(0, strMediaPath.find_last_of(_T("\\/")));
+	    strMediaPath = strMediaPath.substr(0, strMediaPath.find_last_of(_T("\\/")));
+	    strMediaPath = strMediaPath.substr(0, strMediaPath.find_last_of(_T("\\/")));
+        strMediaPath += _T("\\MEDIA");
+			
+		tstring result;
+        result = FindMediaFile(strFileName, strMediaPath, bVerbose);
+           
+        if (result != _T(""))
+            return result;
+
+        //////////////////// for local shaders /////////////////////////
+		strMediaPath = GetModulePath();
+        strMediaPath += _T("\\Shaders");
+
+        result = FindMediaFile(strFileName, strMediaPath, bVerbose);
+           
+        if (result != _T(""))
+            return result;
+
+        //////////////////// for local ../shaders /////////////////////////
+		strMediaPath = GetModulePath();
+    	strMediaPath = strMediaPath.substr(0, strMediaPath.find_last_of(_T("\\/")));
+        strMediaPath += _T("\\Shaders");
+
+        result = FindMediaFile(strFileName, strMediaPath, bVerbose);
+           
+        if (result != _T(""))
+            return result;
+
+		// If prog gets to here, the find has failed.
+		// Return the input file name so other apps can report the failure
+		//  to find the file.
+		if( bVerbose )
+			FMsg(TEXT("GetFilePath() Couldn't find : %s\n"), strFileName.c_str() );
+
+		return strFileName;
+	};
+
+    // Use these wrapper functions if you need to pass a pointer [callback] 
+    // to a 1-parameter version of the GetFilePath() function:
+    static tstring GetFilePath(const tstring& strFileName) {
+        return GetFilePath(strFileName, false);
+    }
+	static tstring GetFilePathVerbose(const tstring& strFileName) {
+        return GetFilePath(strFileName, true);
+    }
+
+};	 // namespace GetFilePath
+
+
+#endif
Index: GTP/trunk/App/Demos/Illum/DepthOfField/.matrix
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/.matrix	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/.matrix	(revision 760)
@@ -0,0 +1,9 @@
+
+World matrix:
+    0.9775    -0.1308     0.1657          0
+   0.07426     0.9478     0.3102          0
+   -0.1977    -0.2909     0.9361          0
+         0          0       6.82          1
+
+Camera position:
+  -1.13035   -2.11572   -6.38423
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.h	(revision 760)
@@ -0,0 +1,123 @@
+#pragma once
+
+#include <d3d9.h>
+
+class CDXTexture
+{
+	friend class CTextureManager;
+
+protected:	
+	LPDIRECT3DDEVICE9 m_Dev;
+	LPDIRECT3DSURFACE9 m_pBackBuffer;
+	IDirect3DSurface9*	m_OrigDepthStencil;
+	int m_RTindex;
+
+    D3DVIEWPORT9 m_OldViewport;
+	int m_Width, m_Height;
+	int m_ColorStage;
+
+	char m_Name[512];
+
+public:
+	IDirect3DTexture9* m_Tex;
+	IDirect3DSurface9*	m_Stencil;
+
+	void SetStage(int color)
+	{ m_ColorStage = color;	}
+
+	static void SetLinearFilters(LPDIRECT3DDEVICE9 dev, DWORD stage) {
+		dev->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+		dev->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+		dev->SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, 2);
+		dev->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
+	}
+	static void SetPointFilters(LPDIRECT3DDEVICE9 dev, DWORD stage) {
+		dev->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
+		dev->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_NONE);
+		dev->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+	}
+	
+	inline void CopyFromBackBuffer()
+	{
+		LPDIRECT3DSURFACE9 backBuffer;
+		m_Dev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
+		m_Dev->StretchRect(backBuffer, NULL, this->GetSurface(0), NULL, D3DTEXF_POINT);
+		SAFE_RELEASE(backBuffer);
+	}
+
+	inline void CopyToBackBuffer()
+	{
+		LPDIRECT3DSURFACE9 backBuffer;
+		m_Dev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
+		m_Dev->StretchRect(this->GetSurface(0), NULL, backBuffer, NULL, D3DTEXF_POINT);
+		SAFE_RELEASE(backBuffer);
+	}
+	virtual bool InitTex(LPDIRECT3DDEVICE9 dev, char* name, char* tex_name, D3DFORMAT format = D3DFMT_UNKNOWN);
+	virtual bool InitTex(LPDIRECT3DDEVICE9 dev, char* tex_name, int width, int height, D3DFORMAT format = D3DFMT_A8R8G8B8, bool mipmapped = false);
+
+
+	CDXTexture();
+	~CDXTexture(void);
+	virtual inline void Bind() 
+	{ m_Dev->SetTexture(m_ColorStage, m_Tex); }
+	virtual inline void Bind(int stage) 
+	{ m_Dev->SetTexture(stage, m_Tex); }
+	virtual inline void BindVertexSampler(int stage) 
+	{ m_Dev->SetTexture(D3DVERTEXTEXTURESAMPLER0 + stage, m_Tex); }
+
+	inline void BindColor() 
+	{ m_Dev->SetTexture(m_ColorStage, m_Tex); }
+
+	inline virtual void BindOther() {}
+
+	LPDIRECT3DSURFACE9 GetSurface(int level)
+	{
+		LPDIRECT3DSURFACE9 surface;
+		m_Tex->GetSurfaceLevel(level, &surface);
+		return surface;
+	}
+
+	inline void StartRender(bool depth = true, int RTindex = 0)
+	{
+		m_RTindex = RTindex;
+		// set new, funky viewport
+		D3DVIEWPORT9 newViewport;
+		newViewport.X = 0;
+	    newViewport.Y = 0;
+	    newViewport.Width  = m_Width;
+		newViewport.Height = m_Height;
+		newViewport.MinZ = 0.0f;
+		newViewport.MaxZ = 1.0f;	
+
+		if (m_RTindex == 0) {
+			m_Dev->GetViewport(&m_OldViewport);
+			m_Dev->SetViewport(&newViewport);
+			m_Dev->GetRenderTarget(0, &m_pBackBuffer);
+			m_Dev->GetDepthStencilSurface(&m_OrigDepthStencil);
+			if (depth)
+				m_Dev->SetDepthStencilSurface(m_Stencil);
+		}
+
+		LPDIRECT3DSURFACE9 surface;
+		m_Tex->GetSurfaceLevel(0, &surface);
+		m_Dev->SetRenderTarget(m_RTindex, surface);
+		
+		SAFE_RELEASE(surface);
+	}
+
+	inline void EndRender()
+	{
+		if (m_RTindex == 0){
+			m_Dev->SetRenderTarget(0, m_pBackBuffer);
+			m_Dev->SetDepthStencilSurface(m_OrigDepthStencil);
+			m_Dev->SetViewport(&m_OldViewport);
+			SAFE_RELEASE(m_pBackBuffer);
+			SAFE_RELEASE(m_OrigDepthStencil);
+		}
+		else
+			m_Dev->SetRenderTarget(m_RTindex, NULL);
+
+	}
+
+	void CopyToName(char* name);
+};
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.cpp	(revision 760)
@@ -0,0 +1,256 @@
+#include "dxstdafx.h" 
+#include "Parameters.h"
+
+float noconvert(float a) {
+	return a;
+}
+
+float convertToMinusOne_One(float a) {
+	return a*2.0f-1.0f;
+}
+
+float convertToZeroTo30(float a) {
+	return a*30.0f;
+}
+
+void OnChange() {
+}
+
+void Parameters::Setup( CDXUTDialog* g_HUD ) {
+	Setup(g_HUD, OnChange, OnChange, OnChange);
+}
+
+void Parameters::Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave, ONCHANGE_CALLBACK OnLoad )
+{
+	assert( g_HUD != NULL );
+	this->g_HUD = g_HUD;
+	g_HUD->GetDefaultElement( DXUT_CONTROL_STATIC, 0 )->dwTextFormat = DT_VCENTER | DT_LEFT;
+
+	for (int i=0; i<LAST_NUMBER; i++) {
+		ffunc[i] = noconvert;
+		chfunc[i] = OnChange;
+	}
+
+	int posX = 380; 
+	int posY = 50 + LAST_BOOL*16; 
+	g_HUD->AddButton( IDC_RESET_BUTTON, L"[R] Reset", posX, posY += 30, 60, 16, 'R' );
+	g_HUD->AddButton( IDC_SAVE_BUTTON,  L"[S] Save",  posX + 70, posY, 60, 16, 'S' );
+	g_HUD->AddButton( IDC_LOAD_BUTTON,  L"[L] Load",  posX + 140, posY, 60, 16, 'L' );
+	chfunc[ LAST_NUMBER ] = OnReset;
+	chfunc[ LAST_NUMBER+1 ] = OnSave;
+	chfunc[ LAST_NUMBER+2 ] = OnLoad;
+}
+
+bool Parameters::Get( bool_t i ) {
+	return bparam[i];
+}
+
+float Parameters::Get( number_t i ) {
+	//assert( ffunc[i] != NULL );
+	return ffunc[i]( (float)param[i] / numsteps[i] );	// 0..1
+}
+
+int Parameters::GetInt( number_t i ) {
+	//assert( ffunc[i] != NULL );
+	float r = (float)ffunc[i]( param[i] );
+	return (int)(r+0.5);	// 0..numsteps[i]
+}
+
+void Parameters::Add( bool_t ID, char* label, char cHotKey ) {
+	
+	assert( cHotKey != 'R' && cHotKey != 'S' && cHotKey != 'L' );
+	mbstowcs( bname[ID], label, CHARBUFFER_SIZE );
+
+	int posX = 380; 
+	int posY = 50; 
+	g_HUD->AddCheckBox( ID+checkboxID0, bname[ID], posX, posY + ID*16, 150, 16, false, cHotKey, 0 );
+	// checked=false
+}
+
+void Parameters::SetBool( bool_t ID, bool b ) {
+	bparam[ID] = b;
+
+	bSilent = true;
+	if( g_HUD->GetCheckBox( ID+checkboxID0 ) != NULL )
+		g_HUD->GetCheckBox( ID+checkboxID0 )->SetChecked( bparam[ID] );
+	bSilent = false;
+}
+
+void Parameters::SetFloat( number_t ID, float v ) {
+	SetInt( ID, (int)( v*numsteps[ID] + 0.5 ));
+}
+
+void Parameters::SetInt( number_t ID, int v ) {
+	param[ID] = v;
+	if ( param[ID] < 0 )	param[ID] = 0;
+	else if ( param[ID] > numsteps[ID] )	param[ID] = numsteps[ID];
+
+	bSilent = true;
+
+	// minden frissül
+	if( g_HUD->GetSlider( ID+sliderID0 ) != NULL )
+		g_HUD->GetSlider( ID+sliderID0 )->SetValue( v );
+
+	wchar_t text[30];
+	_sntprintf( text, 30, L"%.2f", Get( (number_t)ID ) );
+
+	if( g_HUD->GetStatic( ID+staticID0 ) != NULL )
+		g_HUD->GetStatic( ID+staticID0 )->SetText( text );
+
+	// user-defined callback
+	//assert( chfunc[ID] != NULL );
+	chfunc[ID]();
+
+	bSilent = false;
+}
+
+void Parameters::Add( number_t ID, char* label, int num_steps) {
+	Add( ID, label, num_steps, noconvert );
+}
+
+void Parameters::Add( number_t ID, char* label, int num_steps, CONVERTER ff, ONCHANGE_CALLBACK chf ) {
+	char cKeyDown = 0;
+	char cKeyUp = 0;
+	Add( ID, label, num_steps, cKeyDown, cKeyUp, ff, chf);
+}
+
+void Parameters::Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr, CONVERTER ff, ONCHANGE_CALLBACK chf ) {
+
+	assert( cKeyDecr != 'R' && cKeyDecr != 'S' && cKeyDecr != 'L' );
+	assert( cKeyIncr != 'R' && cKeyIncr != 'S' && cKeyIncr != 'L' );
+
+	mbstowcs( name[ID], label, CHARBUFFER_SIZE );
+	/*wchar_t val[30];
+	_sntprintf( val, 30, L"%.2f", param[ID] / 100.0f );	// nem kell */
+
+	//cHotKey
+	ffunc[ID] = ff;
+	chfunc[ID] = chf;
+	numsteps[ID] = num_steps;
+
+	int posX = 210; 
+	int posY = 50; 
+	g_HUD->AddStatic( 0, name[ID], posX-180, posY + ID*16, 120, 14 );
+	g_HUD->AddStatic( ID+staticID0, L"", posX-50, posY + ID*16, 120, 14 );
+	g_HUD->AddSlider( ID+sliderID0, posX, posY + ID*16, 120, 14, 0, num_steps,0 );
+	//UpdateFromHUD( ID+sliderID0 );
+
+	// hogy ne kelljen azt eltárolni, hogy melyik hotkey melyik sliderhez tartozik, 
+	// 2 láthatatlan checkboxot hozok létre ezekkel a hotkeyekkel.
+	// a checkbox id alapján azonosíthatom az érintett slidert.
+	CDXUTCheckBox* c;
+	g_HUD->AddCheckBox( ID+downID0, L"d", posX-20, posY + ID*16, 200, 16, 0, cKeyDecr, 0, &c );
+	c->m_bVisible = false;
+	g_HUD->AddCheckBox( ID+upID0, L"u", posX-20, posY + ID*16, 200, 16, 0, cKeyIncr, 0, &c );
+	c->m_bVisible = false;
+}
+
+void Parameters::UpdateFromHUD( int controlID ) {
+
+	//if (bSilent) return;
+
+	// Reset, Save & Load buttons
+	if (controlID == IDC_RESET_BUTTON ) {
+		LoadFromFile( ".params0" );
+		chfunc[ LAST_NUMBER ]();
+	} 
+	else if (controlID == IDC_SAVE_BUTTON ) {
+		SaveToFile( ".params" );
+		chfunc[ LAST_NUMBER+1 ]();
+	}
+	else if (controlID == IDC_LOAD_BUTTON ) {
+		LoadFromFile( ".params" );
+		chfunc[ LAST_NUMBER+2 ]();
+	}
+
+	// a checkbox
+	else if (controlID >= checkboxID0 && controlID < checkboxID0+LAST_BOOL) {
+		bool b = g_HUD->GetCheckBox( controlID )->GetChecked();
+		int ID = controlID - checkboxID0;
+		SetBool( (bool_t)ID, b);
+	}
+
+	// a slider
+	else if (controlID >= sliderID0 && controlID < sliderID0+LAST_NUMBER)	{
+		int v = g_HUD->GetSlider( controlID )->GetValue();
+		int ID = controlID - sliderID0;
+		SetInt( (number_t)ID, v);
+	}
+
+	// a hotkey (bound to an invisible checkbox) that decrements a slider
+	else if (controlID >= downID0 && controlID < downID0+LAST_NUMBER)	{	// down
+		int ID = controlID-downID0;
+		SetInt( (number_t)ID, param[ID]-1 );
+	}
+
+	// a hotkey (bound to an invisible checkbox) that increments a slider
+	else if (controlID >= upID0 && controlID < upID0+LAST_NUMBER) {			// up
+		int ID = controlID-upID0;
+		SetInt( (number_t)ID, param[ID]+1 );
+	}
+}
+
+void Parameters::SaveToFile( char* fileName ) {
+	FILE* fileS;
+	if( ( fileS = fopen( fileName, "wt" ) ) == NULL )
+	{
+		wchar_t wbuf[ CHARBUF ];
+		mbstowcs( wbuf, fileName, CHARBUF );
+		MessageBox( NULL, wbuf, L"File creation failed!", MB_ICONERROR );			// show error message
+		return;
+	}
+
+	fwprintf( fileS, L"----- RayTraceEffects: Saved parameters of the algorithm -----\n" );
+
+	fwprintf( fileS, L"Bool values:\n" );
+	for ( int i=0; i<LAST_BOOL; i++)
+		fwprintf( fileS, L"%i", (int)bparam[i] );
+	fwprintf( fileS, L"\n" );
+
+	fwprintf( fileS, L"(" );
+	for ( int i=0; i<LAST_BOOL; i++)
+		fwprintf( fileS, L"%s; ", bname[i] );
+	fwprintf( fileS, L")\n" );
+
+	fwprintf( fileS, L"Float values:\n" );
+
+	for ( int i=0; i<LAST_NUMBER; i++)
+		fwprintf( fileS, L"%i \t(%s, 0..%i)\n", param[i], name[i], numsteps[i] );
+
+	fclose(fileS);
+}
+
+void Parameters::LoadFromFile( char* fileName ) {
+	FILE* fileL; 
+    if( ( fileL = fopen( fileName, "rt" ) ) == NULL )
+	{
+		wchar_t wbuf[ CHARBUF ];
+		mbstowcs( wbuf, fileName, CHARBUF );
+		MessageBox( NULL, wbuf, L"File not found!", MB_ICONERROR );			// show error message
+		return;
+	}
+
+	char buf[ CHARBUF ];
+	fgets( buf, CHARBUF, fileL );			// skip comment
+	fgets( buf, CHARBUF, fileL );			// skip comment
+
+	for ( int i=0; i<LAST_BOOL; i++)
+	{
+		int num = fgetc( fileL ) - '0';
+		SetBool( (bool_t)i, num > 0 );
+	}
+
+	fgets( buf, CHARBUF, fileL );			// skip line
+	fgets( buf, CHARBUF, fileL );			// skip comment
+	fgets( buf, CHARBUF, fileL );			// skip comment
+
+	for ( int i=0; i<LAST_NUMBER; i++)
+	{
+		fgets( buf, CHARBUF, fileL );
+		int v;
+		sscanf( buf, "%i", &v );
+		SetInt( (number_t)i, v );
+	}
+
+	fclose(fileL);
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.sln
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.sln	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.sln	(revision 760)
@@ -0,0 +1,24 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DepthOfField", "DepthOfField.vcproj", "{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfiguration) = preSolution
+		Debug = Debug
+		Profile = Profile
+		Release = Release
+	EndGlobalSection
+	GlobalSection(ProjectConfiguration) = postSolution
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Debug.ActiveCfg = Debug|Win32
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Debug.Build.0 = Debug|Win32
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Profile.ActiveCfg = Profile|Win32
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Profile.Build.0 = Profile|Win32
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Release.ActiveCfg = Release|Win32
+		{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}.Release.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+	EndGlobalSection
+	GlobalSection(ExtensibilityAddIns) = postSolution
+	EndGlobalSection
+EndGlobal
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Parameters.h	(revision 760)
@@ -0,0 +1,65 @@
+#pragma once
+#include <assert.h>
+
+
+
+typedef enum { bShowHelp,/* bDisplacementOn,*/ LAST_BOOL } bool_t;
+typedef enum {fFocalDistance, fDisplacementScale, LAST_NUMBER } number_t;
+
+enum { IDC_RESET_BUTTON	= -3, IDC_SAVE_BUTTON, IDC_LOAD_BUTTON };
+
+#define CHARBUF	100				// The max length of a line in the save file
+
+typedef float (*CONVERTER)(float a);
+typedef void (*ONCHANGE_CALLBACK)(void);
+
+
+float noconvert(float a);	// { return a; }
+float convertToMinusOne_One(float a); // { return a*2.0-1.0;}
+float convertToZeroTo30(float a); // { return a*2.0-1.0;}
+void OnChange();			// {}
+
+
+class Parameters {
+	bool bparam[LAST_BOOL];
+	wchar_t bname[LAST_BOOL][CHARBUF];
+
+	int param[LAST_NUMBER];	// 0..100 (0..num_steps)
+	wchar_t name[LAST_NUMBER][CHARBUF];
+	int numsteps[LAST_NUMBER];
+
+	CONVERTER ffunc[LAST_NUMBER];
+	ONCHANGE_CALLBACK chfunc[LAST_NUMBER+3];
+
+	CDXUTDialog* g_HUD;
+
+	bool bSilent;
+	const static int CHARBUFFER_SIZE = 200;
+	enum { checkboxID0 = 1000, sliderID0 = 2000, staticID0 = 3000, upID0 = 4000, downID0 = 5000 };
+
+public:
+	void Setup( CDXUTDialog* g_HUD );
+	void Setup( CDXUTDialog* g_HUD, ONCHANGE_CALLBACK OnReset, ONCHANGE_CALLBACK OnSave = OnChange, ONCHANGE_CALLBACK OnLoad = OnChange);
+
+	bool Get( bool_t i );
+	float Get( number_t i );
+	int GetInt( number_t i );
+
+	void SetBool( bool_t ID, bool b );
+	void SetFloat( number_t ID, float v );
+	void SetInt( number_t ID, int v );
+
+	void Add( bool_t ID, char* label, char cHotKey = 0 );
+	void Add( number_t ID, char* label, int num_steps);
+
+	void Add( number_t ID, char* label, int num_steps, 
+		CONVERTER ff, ONCHANGE_CALLBACK chf = OnChange );
+
+	void Add( number_t ID, char* label, int num_steps, char cKeyDecr, char cKeyIncr, 
+		CONVERTER ff = noconvert, ONCHANGE_CALLBACK chf = OnChange );
+
+	void UpdateFromHUD( int controlID );
+
+	void SaveToFile( char* fileName );
+	void LoadFromFile( char* fileName );
+};
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField-ndsproperties.xml
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField-ndsproperties.xml	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField-ndsproperties.xml	(revision 760)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<NDSProject xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" supplier="Nokia">
+  <updateMmpFile>true</updateMmpFile>
+  <pkgFile>sis\DepthOfField.pkg</pkgFile>
+  <pkgUpdate>true</pkgUpdate>
+  <pkgGeneration>true</pkgGeneration>
+  <lang>EN</lang>
+  <updateContextHelp>true</updateContextHelp>
+</NDSProject>
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.vcproj
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.vcproj	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.vcproj	(revision 760)
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="DepthOfField"
+	ProjectGUID="{9C04CC2D-C188-4443-A185-CB0BCA6ED98D}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="1">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="Common"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;PROFILE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="0"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="3"
+				PrecompiledHeaderThrough="dxstdafx.h"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/IGNORE:4089"
+				AdditionalDependencies="dxerr9.lib dxguid.lib d3dx9d.lib d3d9.lib winmm.lib comctl32.lib"
+				OutputFile="$(OutDir)/DepthOfField.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/EnvMap.pdb"
+				SubSystem="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="1">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				OmitFramePointers="TRUE"
+				AdditionalIncludeDirectories="Common"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+				StringPooling="TRUE"
+				ExceptionHandling="FALSE"
+				RuntimeLibrary="4"
+				EnableFunctionLevelLinking="TRUE"
+				UsePrecompiledHeader="3"
+				PrecompiledHeaderThrough="dxstdafx.h"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/IGNORE:4089"
+				AdditionalDependencies="dxerr9.lib dxguid.lib d3dx9.lib d3d9.lib winmm.lib comctl32.lib"
+				OutputFile="$(OutDir)/DepthOfField.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Profile|Win32"
+			OutputDirectory="Profile"
+			IntermediateDirectory="Profile"
+			ConfigurationType="1"
+			CharacterSet="1">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				OmitFramePointers="TRUE"
+				AdditionalIncludeDirectories="Common"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;PROFILE"
+				StringPooling="TRUE"
+				ExceptionHandling="FALSE"
+				RuntimeLibrary="4"
+				EnableFunctionLevelLinking="TRUE"
+				UsePrecompiledHeader="3"
+				PrecompiledHeaderThrough="dxstdafx.h"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/IGNORE:4089"
+				AdditionalDependencies="dxerr9.lib dxguid.lib d3dx9.lib d3d9.lib winmm.lib comctl32.lib"
+				OutputFile="$(OutDir)/EnvMap.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+			<File
+				RelativePath="Common\directx.ico">
+			</File>
+			<File
+				RelativePath=".\DepthOfField.manifest">
+			</File>
+			<File
+				RelativePath=".\DepthOfField.rc">
+			</File>
+			<File
+				RelativePath="resource.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Common"
+			Filter="">
+			<File
+				RelativePath="Common\dxstdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Profile|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="Common\dxstdafx.h">
+			</File>
+			<File
+				RelativePath="Common\dxut.cpp">
+			</File>
+			<File
+				RelativePath="Common\dxut.h">
+			</File>
+			<File
+				RelativePath="Common\dxutenum.cpp">
+			</File>
+			<File
+				RelativePath="Common\dxutenum.h">
+			</File>
+			<File
+				RelativePath="Common\dxutgui.cpp">
+			</File>
+			<File
+				RelativePath="Common\dxutgui.h">
+			</File>
+			<File
+				RelativePath="Common\dxutMesh.cpp">
+			</File>
+			<File
+				RelativePath="Common\dxutMesh.h">
+			</File>
+			<File
+				RelativePath="Common\dxutmisc.cpp">
+			</File>
+			<File
+				RelativePath="Common\dxutmisc.h">
+			</File>
+			<File
+				RelativePath="Common\DXUTRes.cpp">
+			</File>
+			<File
+				RelativePath="Common\DXUTRes.h">
+			</File>
+			<File
+				RelativePath="Common\DXUTSettingsDlg.cpp">
+			</File>
+			<File
+				RelativePath="Common\DXUTSettingsDlg.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Shaders"
+			Filter="">
+			<File
+				RelativePath=".\shaders\BumpMapping.fx">
+			</File>
+			<File
+				RelativePath=".\shaders\CameraEffects.fx">
+			</File>
+			<File
+				RelativePath=".\shaders\illum.hlsl">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="">
+			<File
+				RelativePath=".\CameraEffects.h">
+			</File>
+			<File
+				RelativePath=".\DXTexture.h">
+			</File>
+			<File
+				RelativePath=".\Media.h">
+			</File>
+			<File
+				RelativePath=".\Mesh.h">
+			</File>
+			<File
+				RelativePath=".\Parameters.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Source Files"
+			Filter="">
+			<File
+				RelativePath=".\CameraEffects.cpp">
+			</File>
+			<File
+				RelativePath=".\DXTexture.cpp">
+			</File>
+			<File
+				RelativePath=".\Main.cpp">
+			</File>
+			<File
+				RelativePath=".\Mesh.cpp">
+			</File>
+			<File
+				RelativePath=".\Parameters.cpp">
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Cube.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Cube.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Cube.cpp	(revision 760)
@@ -0,0 +1,89 @@
+
+#include "dxstdafx.h"
+//#include "Params.h"
+#include "Cube.h"
+
+#define D3DFVF_CUSTOMVERTEX			(D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
+
+struct Vertex
+{
+	float x, y, z;
+	float nx, ny, nz;
+	float tu, tv;
+};
+
+Cube::Cube(IDirect3DDevice9* pd3dDevice)
+{
+	this->pd3dDevice = pd3dDevice;
+	
+	//pVertexBuffer
+
+	int vertexCnt = 24;
+	float s = 1;	// igazából mindegy a méret, mert csak a kocka skálázódik vele
+	
+	Vertex g_quadVertices[] =
+	{
+		// 1 lap = 2 háromszögbõl álló triangle_strip
+		// lapok körüljárási irányának megváltoztatása: a középsõ 2 vertex felcserélésével
+
+		//x  y  z	 normal		texcoord
+		{-s, s, s,   0,0,-1,	0,0 },
+		{-s,-s, s,   0,0,-1,	0,1 },
+		{ s, s, s,   0,0,-1,	1,0 },
+		{ s,-s, s,   0,0,-1,	1,1 },
+
+		// z érték -1-szeres + 2. és 3. vertex cseréje
+		{-s, s, -s,   0,0,1,	0,0 },
+		{ s, s, -s,   0,0,1,	1,0 },
+		{-s,-s, -s,   0,0,1,	0,1 },
+		{ s,-s, -s,   0,0,1,	1,1 },
+
+		// y,z csere
+		{-s,-s, s,    0,1,0,	0,0 },
+		{-s,-s, -s,   0,1,0,	0,1 },
+		{ s,-s, s,    0,1,0,	1,0 },
+		{ s,-s, -s,   0,1,0,	1,1 },
+
+		{-s, s, s,   0,-1,0,	0,0 },
+		{ s, s, s,   0,-1,0,	1,0 },
+		{-s, s,-s,   0,-1,0,	0,1 },
+		{ s, s,-s,   0,-1,0,	1,1 },
+
+		// x,z csere
+		{-s, s,-s,    1,0,0,	0,0 },
+		{-s,-s,-s,    1,0,0,	0,1 },
+		{-s, s, s,    1,0,0,	1,0 },
+		{-s,-s, s,    1,0,0,	1,1 },
+
+		{ s, s, -s,  -1,0,0,	0,0 },
+		{ s, s,  s,  -1,0,0,	1,0 },
+		{ s,-s, -s,  -1,0,0,	0,1 },
+		{ s,-s,  s,  -1,0,0,	1,1 },
+	};
+
+	pd3dDevice->CreateVertexBuffer( vertexCnt*sizeof(Vertex), D3DUSAGE_WRITEONLY, 
+									D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, 
+									&pVertexBuffer, NULL );
+	void *pVertices = NULL;
+
+	pVertexBuffer->Lock( 0, sizeof(g_quadVertices), (void**)&pVertices, 0 );
+	memcpy( pVertices, g_quadVertices, sizeof(g_quadVertices) );
+	pVertexBuffer->Unlock();
+}
+
+void Cube::PrepareDrawing()
+{
+	pd3dDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof(Vertex) );
+	pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
+}
+
+void Cube::DrawFace(int index)
+{
+	pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 4*index, 2 ); // startVertex, primitiveCnt
+}
+
+void Cube::Draw()
+{
+	for (int index = 0; index < 6; index++)
+		pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 4*index, 2 ); // startVertex, primitiveCnt
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.rc
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.rc	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.rc	(revision 760)
@@ -0,0 +1,85 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define IDC_STATIC -1
+#include <WinResRc.h>
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// RT_MANIFEST
+//
+
+1                       RT_MANIFEST             "DepthOfField.manifest"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_MAIN_ICON           ICON                    "Common\\directx.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#define IDC_STATIC -1\r\n"
+    "#include <winresrc.h>\r\n"
+    "\r\n"
+    "\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
Index: GTP/trunk/App/Demos/Illum/DepthOfField/.params
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/.params	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/.params	(revision 760)
@@ -0,0 +1,7 @@
+----- RayTraceEffects: Saved parameters of the algorithm -----
+Bool values:
+0
+(Show Help; )
+Float values:
+0 	(Focal Distance, 0..100)
+0 	(, 0..0)
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.manifest
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.manifest	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DepthOfField.manifest	(revision 760)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity
+    version="1.0.0.0"
+    processorArchitecture="*"
+    name="Microsoft.DirectX SDK.Displacement"
+    type="win32"
+/>
+<description>DirectX SDK Sample Program.</description>
+<dependency>
+    <dependentAssembly>
+        <assemblyIdentity
+            type="win32"
+            name="Microsoft.Windows.Common-Controls"
+            version="6.0.0.0"
+            processorArchitecture="*"
+            publicKeyToken="6595b64144ccf1df"
+            language="*"
+        />
+    </dependentAssembly>
+</dependency>
+</assembly>
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Cube.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Cube.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Cube.h	(revision 760)
@@ -0,0 +1,14 @@
+#pragma once
+
+class Cube
+{
+	IDirect3DDevice9* pd3dDevice;
+	IDirect3DVertexBuffer9 *pVertexBuffer;   
+	HRESULT hr;
+
+public:
+	Cube(IDirect3DDevice9* pd3dDevice);
+	void PrepareDrawing();
+	void Draw();
+	void DrawFace(int index);
+};
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Main.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Main.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Main.cpp	(revision 760)
@@ -0,0 +1,634 @@
+//--------------------------------------------------------------------------------------
+// Main.cpp:
+// - DirectX initialization
+// - create resources (textures)
+//--------------------------------------------------------------------------------------
+
+#include "dxstdafx.h" 
+#include "resource.h" 
+#include <math.h>
+#include <stdio.h>
+
+//#define DEBUG_VS   // Uncomment this line to debug vertex shaders 
+//#define DEBUG_PS   // Uncomment this line to debug pixel shaders  
+
+#include "Mesh.h"
+#include "Parameters.h"
+#include "CameraEffects.h"
+
+const int WIDTH = 512;
+const int HEIGHT = WIDTH;
+const int CHARBUFFER_SIZE = 200;
+
+//--------------------------------------------------------------------------------------
+// Global variables
+//--------------------------------------------------------------------------------------
+int currentMethod=0;
+int methodCount=1;
+bool showUI=true;
+CameraEffects PD;
+IDirect3DDevice9*			g_pd3dDevice = NULL;
+ID3DXEffect*				g_pEffect = NULL;
+
+CDXUTDialogResourceManager	g_DialogResourceManager;	// manager for shared resources of dialogs
+CD3DSettingsDlg				g_SettingsDlg;				// Device settings dialog
+CDXUTDialog					g_HUD;						// Dialog for sample specific controls
+
+ID3DXFont*					g_pFont = NULL;				// Font for drawing text
+ID3DXSprite*				g_pTextSprite = NULL;		// Sprite for batching draw text calls
+
+IDirect3DSurface9*			g_pSaveSurface;				// screenshot capturing support
+bool						bSavingScreenshot = false;
+int							counter = 0;
+
+D3DXVECTOR3 LightPosition;
+HRESULT hr;
+
+Parameters pp;							// managing parameters of the algorithm
+
+CModelViewerCamera camera;				// camera
+
+
+//--------------------------------------------------------------------------------------
+// Forward declarations (CALLBACK)
+//--------------------------------------------------------------------------------------
+bool    CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );
+bool	CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext );
+HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* g_pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
+HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* g_pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
+void    CALLBACK OnFrameMove( IDirect3DDevice9* g_pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
+void    CALLBACK OnFrameRender( IDirect3DDevice9* g_pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
+LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext );
+void    CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
+void    CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );
+void    CALLBACK OnLostDevice( void* pUserContext );
+void    CALLBACK OnDestroyDevice( void* pUserContext );
+void	InitApp();
+void	RenderText(); 
+
+//--------------------------------------------------------------------------------------
+// Forward declarations 
+//--------------------------------------------------------------------------------------
+
+void SaveCameraPosition( char* fileName );
+void LoadCameraPosition( char* fileName );
+int GenerateNewFileName( int& counter );
+
+//--------------------------------------------------------------------------------------
+// Entry point to the program. Initializes everything and goes into a message processing 
+// loop. Idle time is used to render the scene.
+//--------------------------------------------------------------------------------------
+INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
+{
+    // Enable run-time memory check for debug builds.
+#if defined(DEBUG) | defined(_DEBUG)
+    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
+
+    DXUTSetCallbackDeviceCreated( OnCreateDevice );
+    DXUTSetCallbackDeviceReset( OnResetDevice );
+    DXUTSetCallbackDeviceLost( OnLostDevice );
+    DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
+    DXUTSetCallbackMsgProc( MsgProc );
+    DXUTSetCallbackKeyboard( KeyboardProc );
+    DXUTSetCallbackFrameRender( OnFrameRender );
+    DXUTSetCallbackFrameMove( OnFrameMove );
+
+	InitApp();
+
+	// Show the cursor and clip it when in full screen
+    DXUTSetCursorSettings( true, true );
+
+	DXUTInit( true, true, true ); // Parse the command line, handle the default hotkeys, and show msgboxes
+    DXUTCreateWindow( L"Depth of Field Demo" );
+    DXUTCreateDevice( D3DADAPTER_DEFAULT, true, WIDTH, HEIGHT, IsDeviceAcceptable, ModifyDeviceSettings );
+
+	camera.SetButtonMasks( 0, MOUSE_WHEEL, MOUSE_LEFT_BUTTON );
+
+    DXUTMainLoop();
+
+    return DXUTGetExitCode();
+}
+
+void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
+{
+	pp.UpdateFromHUD( nControlID );
+}
+
+void OnLoad() {
+	LoadCameraPosition( ".matrix" );
+}
+
+void OnSave() {
+	SaveCameraPosition( ".matrix" );
+	bSavingScreenshot = true;
+}
+
+void OnReset() 
+{
+	LightPosition.x=-0.4f;
+	LightPosition.y=1.3f;	
+	LightPosition.z=9;
+}
+
+void InitApp()
+{
+	g_SettingsDlg.Init( &g_DialogResourceManager );
+	g_HUD.Init( &g_DialogResourceManager );
+	g_HUD.SetCallback( OnGUIEvent );	// Event handling
+
+	pp.Setup( &g_HUD, OnReset, OnSave, OnLoad);	// you can add callbacks to these actions
+	
+	pp.Add( bShowHelp, "Show Help", VK_F1 );
+	
+	PD.addUiParams(pp);
+	
+	pp.UpdateFromHUD( IDC_RESET_BUTTON );	// do a reset
+}
+
+//--------------------------------------------------------------------------------------
+// Rejects any devices that aren't acceptable by returning false
+//--------------------------------------------------------------------------------------
+bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, 
+                                  D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext )
+{
+    // Skip backbuffer formats that don't support alpha blending
+    IDirect3D9* pD3D = DXUTGetD3DObject(); 
+    if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType,
+                    AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, 
+                    D3DRTYPE_TEXTURE, BackBufferFormat ) ) )
+        return false;
+
+    return true;
+}
+
+//--------------------------------------------------------------------------------------
+// Before a device is created, modify the device settings as needed
+//--------------------------------------------------------------------------------------
+bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext )
+{
+	// VSync off
+	pDeviceSettings->pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+
+    // If device doesn't support HW T&L or doesn't support 1.1 vertex shaders in HW 
+    // then switch to SWVP.
+    if( (pCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
+         pCaps->VertexShaderVersion < D3DVS_VERSION(1,1) )
+		pDeviceSettings->BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+    else
+		pDeviceSettings->BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
+
+    // This application is designed to work on a pure device by not using 
+    // IDirect3D9::Get*() methods, so create a pure device if supported and using HWVP.
+    if ((pCaps->DevCaps & D3DDEVCAPS_PUREDEVICE) != 0 && 
+        (pDeviceSettings->BehaviorFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING) != 0 )
+        pDeviceSettings->BehaviorFlags |= D3DCREATE_PUREDEVICE;
+
+    // Debugging vertex shaders requires either REF or software vertex processing 
+    // and debugging pixel shaders requires REF.  
+#ifdef DEBUG_VS
+    if( pDeviceSettings->DeviceType != D3DDEVTYPE_REF )
+    {
+        pDeviceSettings->BehaviorFlags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING;
+        pDeviceSettings->BehaviorFlags &= ~D3DCREATE_PUREDEVICE;                            
+        pDeviceSettings->BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+    }
+#endif
+#ifdef DEBUG_PS
+    pDeviceSettings->DeviceType = D3DDEVTYPE_REF;
+#endif
+
+	// For the first device created if its a REF device, optionally display a warning dialog box
+    static bool s_bFirstTime = true;
+    if( s_bFirstTime )
+    {
+        s_bFirstTime = false;
+        if( pDeviceSettings->DeviceType == D3DDEVTYPE_REF )
+            DXUTDisplaySwitchingToREFWarning();
+    }
+	return true;
+}
+
+//--------------------------------------------------------------------------------------
+// Create any D3DPOOL_MANAGED resources here 
+//--------------------------------------------------------------------------------------
+HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
+{
+	::g_pd3dDevice = pd3dDevice;
+
+	HRESULT hr;
+
+    V_RETURN( g_DialogResourceManager.OnCreateDevice( g_pd3dDevice ) );
+    V_RETURN( g_SettingsDlg.OnCreateDevice( g_pd3dDevice ) );
+
+    // Initialize the font
+    V_RETURN( D3DXCreateFont( g_pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, 
+                         OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
+                         L"Arial", &g_pFont ) );
+
+	
+	
+	float initialEyeDist = 6.82f;
+	D3DXVECTOR3 vecEye(0, 0, -initialEyeDist);
+	D3DXVECTOR3 vecAt (0.0f, 0.0f, -0.0f);
+	camera.SetViewParams( &vecEye, &vecAt );
+
+	PD.OnCreateDevice(g_pd3dDevice);
+	PD.camera = &camera;
+
+	return S_OK;
+}
+
+//--------------------------------------------------------------------------------------
+// Release resources created in the OnCreateDevice callback here
+//--------------------------------------------------------------------------------------
+void CALLBACK OnDestroyDevice( void* pUserContext )
+{
+    g_DialogResourceManager.OnDestroyDevice();
+    g_SettingsDlg.OnDestroyDevice();
+    SAFE_RELEASE(g_pFont);	
+	PD.OnDestroyDevice();
+}
+
+
+//--------------------------------------------------------------------------------------
+// Create any D3DPOOL_DEFAULT resources here 
+//--------------------------------------------------------------------------------------
+HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* g_pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
+{ 
+    HRESULT hr;
+
+    V_RETURN( g_DialogResourceManager.OnResetDevice() );
+    V_RETURN( g_SettingsDlg.OnResetDevice() );
+
+    if( g_pFont )   V_RETURN( g_pFont->OnResetDevice() );
+  
+    // Create a sprite to help batch calls when drawing many lines of text
+    V_RETURN( D3DXCreateSprite( g_pd3dDevice, &g_pTextSprite ) );
+
+	// Create a surface to save screenshots
+	IDirect3DTexture9* pSaveTexture	= NULL;
+	V( D3DXCreateTexture( g_pd3dDevice, pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height, 1, 
+		D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pSaveTexture) );
+	pSaveTexture->GetSurfaceLevel( 0, &g_pSaveSurface );
+	SAFE_RELEASE( pSaveTexture );
+
+	// Setup the camera's projection parameters
+    float fAspectRatio = pBackBufferSurfaceDesc->Width / (FLOAT)pBackBufferSurfaceDesc->Height;
+
+	camera.SetProjParams( D3DX_PI/4, fAspectRatio, 0.1f, 100 );
+    camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
+	
+    // Position the on-screen dialog
+    g_HUD.SetLocation( 0, 0 );
+    g_HUD.SetSize( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
+
+	PD.OnResetDevice((D3DSURFACE_DESC*)pBackBufferSurfaceDesc);
+
+    return S_OK;
+}
+
+//--------------------------------------------------------------------------------------
+// Release resources created in the OnResetDevice callback here 
+//--------------------------------------------------------------------------------------
+void CALLBACK OnLostDevice( void* pUserContext )
+{
+    g_DialogResourceManager.OnLostDevice();
+    g_SettingsDlg.OnLostDevice();
+
+    if( g_pFont )	g_pFont->OnLostDevice();
+   
+    SAFE_RELEASE( g_pTextSprite );
+	SAFE_RELEASE( g_pSaveSurface );
+
+	PD.OnLostDevice();
+}
+
+LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext )
+{
+    // Always allow dialog resource manager calls to handle global messages
+    // so GUI state is updated correctly
+    *pbNoFurtherProcessing = g_DialogResourceManager.MsgProc( hWnd, uMsg, wParam, lParam );
+    if( *pbNoFurtherProcessing )
+        return 0;
+
+    if( g_SettingsDlg.IsActive() )
+    {
+        g_SettingsDlg.MsgProc( hWnd, uMsg, wParam, lParam );
+        return 0;
+    }
+
+	// Give the dialogs a chance to handle the message first
+    *pbNoFurtherProcessing = g_HUD.MsgProc( hWnd, uMsg, wParam, lParam );
+    if( *pbNoFurtherProcessing )
+        return 0;
+
+    // Pass all remaining windows messages to camera so it can respond to user input
+	camera.HandleMessages( hWnd, uMsg, wParam, lParam );
+
+    return 0;
+}
+
+//--------------------------------------------------------------------------------------
+// Handle updates to the scene
+//--------------------------------------------------------------------------------------
+void CALLBACK OnFrameMove( IDirect3DDevice9* g_pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
+{
+    camera.FrameMove( fElapsedTime );
+}
+
+//--------------------------------------------------------------------------------------
+// Render the scene 
+//--------------------------------------------------------------------------------------
+void CALLBACK OnFrameRender( IDirect3DDevice9* g_pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
+{    
+	/* // If the settings dialog is being shown, then
+    // render it instead of rendering the app's scene
+    if( g_SettingsDlg.IsActive() )
+    {
+        g_SettingsDlg.OnRender( fElapsedTime );
+        return;
+    }*/
+
+	IDirect3DSurface9* oldRenderTarget = NULL;
+	if (bSavingScreenshot) {
+		V( g_pd3dDevice->GetRenderTarget(0, &oldRenderTarget) );
+		V( g_pd3dDevice->SetRenderTarget(0, g_pSaveSurface) );
+	}
+
+	V( g_pd3dDevice->BeginScene() );
+
+
+			D3DXMATRIXA16 mView = *camera.GetViewMatrix();
+			D3DXMATRIXA16 mProj = *camera.GetProjMatrix();
+
+			V( g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(75, 75, 75), 1.0f, 0L) );
+
+			PD.currentmethod=currentMethod;
+			PD.camera = &camera;
+			PD.LightPos=&LightPosition;
+			PD.OnFrameRender(mView,mProj);
+
+			if (!bSavingScreenshot)
+			{
+				RenderText();
+				if(showUI)
+				{	
+					V( g_HUD.OnRender( fElapsedTime ) );
+				}
+			}
+
+	V( g_pd3dDevice->EndScene() );
+
+	if (bSavingScreenshot)
+	{
+		// saving surface
+		char buf[CHARBUFFER_SIZE];
+		wchar_t wbuf[CHARBUFFER_SIZE];
+
+		GenerateNewFileName( counter );
+		sprintf(buf, "shots\\%03i.png", counter);
+		mbstowcs( wbuf, buf, CHARBUFFER_SIZE );
+
+		D3DXSaveSurfaceToFileW(wbuf, D3DXIFF_PNG, g_pSaveSurface, NULL, NULL);
+
+		sprintf(buf, "shots\\%03i", counter);
+		pp.SaveToFile( buf );
+
+		sprintf(buf, "shots\\%03i.matrix", counter);
+		SaveCameraPosition( buf );
+
+		g_pd3dDevice->SetRenderTarget(0, oldRenderTarget);
+		bSavingScreenshot = false;
+	}
+}
+
+int GenerateNewFileName( int& counter )
+{
+	char buf[CHARBUFFER_SIZE];
+	FILE* f;
+	do {
+		sprintf(buf, "shots\\%03i.png", counter);
+		if ( (f = fopen(buf, "rt")) != NULL )
+		{
+			fclose( f );
+			counter++;
+		}
+	} while (f != NULL);
+	return counter;
+}
+
+//--------------------------------------------------------------------------------------
+// The framework does not remove the underlying keystroke messages,
+// which are still passed to the application's MsgProc callback.
+//--------------------------------------------------------------------------------------
+void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext )
+{
+	if( bKeyDown )
+    {
+		if ( nChar >= '0' && nChar <= '9' ) {
+			UINT whichMesh = nChar-'0';
+			PD.changeMesh(whichMesh);
+		}
+		switch(nChar)
+		{
+			case VK_SPACE:
+				showUI=!showUI;
+				break;
+			case VK_TAB:
+				currentMethod=(++currentMethod)%methodCount;
+				break;
+			case VK_DOWN:
+				LightPosition.z-=0.1f;
+				break;
+			case VK_UP:
+				LightPosition.z+=0.1f;
+				break;
+			case VK_LEFT:
+				LightPosition.x-=0.1f;
+				break;
+			case VK_RIGHT:
+				LightPosition.x+=0.1f;
+				break;
+			case VK_DELETE:
+				LightPosition.y+=0.1f;
+				break;
+			case VK_END:
+				LightPosition.y-=0.1f;
+				break;				
+			default:
+				break;
+		}
+	}
+}
+
+void SaveCameraPosition( char* fileName )
+{
+	// save parameters to file:
+	// world matrix (4x4)
+	// camera position (3)
+
+	// save world matrix
+	D3DXMATRIXA16 W = *camera.GetViewMatrix();
+
+	FILE* f;
+
+	if ((f = fopen(fileName, "wt")) == NULL)
+	{
+		wchar_t wbuf[CHARBUFFER_SIZE];
+		mbstowcs( wbuf, fileName, CHARBUFFER_SIZE );
+        MessageBox(NULL, wbuf, L"File creation failed!", MB_ICONEXCLAMATION);
+		return;
+	}
+
+	fprintf(f, "\n");
+	fprintf(f, "World matrix:\n");
+	fprintf(f, "%10.4g %10.4g %10.4g %10.4g\n", W._11, W._12, W._13, W._14);
+	fprintf(f, "%10.4g %10.4g %10.4g %10.4g\n", W._21, W._22, W._23, W._24);
+	fprintf(f, "%10.4g %10.4g %10.4g %10.4g\n", W._31, W._32, W._33, W._34);
+	fprintf(f, "%10.4g %10.4g %10.4g %10.4g\n", W._41, W._42, W._43, W._44);
+
+	// save camera position
+	fprintf(f, "\n");
+	fprintf(f, "Camera position:\n");
+	const D3DXVECTOR3* eye = camera.GetEyePt();
+	fprintf(f, "%10g %10g %10g", eye->x, eye->y, eye->z);
+	fprintf(f, "\n");
+
+	fclose(f);
+}
+
+void LoadCameraPosition( char* fileName )
+{
+	FILE* f; 
+
+	if ((f = fopen(fileName, "rt")) == NULL) {
+		wchar_t wbuf[CHARBUFFER_SIZE];
+		mbstowcs( wbuf, fileName, CHARBUFFER_SIZE );
+        MessageBox(NULL, wbuf, L"File not found!", MB_ICONEXCLAMATION);
+		return;
+	}
+
+	const int BufSize = 500;	// size of char buffers 
+	char buf[BufSize];
+	D3DXMATRIXA16 W;
+
+	fgets(buf, BufSize, f);		// skip comment
+	fgets(buf, BufSize, f);		// skip comment
+	fgets(buf, BufSize, f);		sscanf(buf, "%f %f %f %f", &W._11, &W._12, &W._13, &W._14);
+	fgets(buf, BufSize, f);		sscanf(buf, "%f %f %f %f", &W._21, &W._22, &W._23, &W._24);
+	fgets(buf, BufSize, f);		sscanf(buf, "%f %f %f %f", &W._31, &W._32, &W._33, &W._34);
+	fgets(buf, BufSize, f);		sscanf(buf, "%f %f %f %f", &W._41, &W._42, &W._43, &W._44);
+
+	// load camera position
+	D3DXVECTOR3 vecAt(0.0f, 0.0f, 0.0f);
+	D3DXVECTOR3 vecEye;
+	fgets(buf, BufSize, f);		// skip comment
+	fgets(buf, BufSize, f);		// skip comment
+	fgets(buf, BufSize, f);		sscanf(buf, "%f %f %f", &vecEye.x, &vecEye.y, &vecEye.z);
+
+	fclose(f);
+
+	camera.SetViewParams( &vecEye, &vecAt );
+
+	D3DXQUATERNION q;
+	D3DXQuaternionRotationMatrix(&q, &W);
+	camera.SetViewQuat(q);
+}
+
+//--------------------------------------------------------------------------------------
+// Util function.
+// Creates an empty texture. These textures will be used as render targets, therefore 
+// the Usage flag is set to D3DUSAGE_RENDERTARGET and consequently, the assigned
+// memory pool is D3DPOOL_DEFAULT.
+// Params: size and format (eg. D3DFMT_A32B32G32R32F) of the new texture.
+//--------------------------------------------------------------------------------------
+IDirect3DTexture9* CreateTexture( int size, D3DFORMAT Format )
+{
+	HRESULT hr;
+	IDirect3DTexture9* pTexture;
+	V( g_pd3dDevice->CreateTexture(	size, size,		// dimensions
+									1,				// mipmap levels
+									D3DUSAGE_RENDERTARGET, // usage
+									Format,			
+									D3DPOOL_DEFAULT,// memory pool
+									&pTexture, NULL ) );
+	return pTexture;
+}
+
+//--------------------------------------------------------------------------------------
+// Util function.
+// Creates an empty cubemap texture of the given resolution and format.
+//--------------------------------------------------------------------------------------
+
+IDirect3DCubeTexture9* CreateCubeTexture( int size, D3DFORMAT Format )
+{
+	HRESULT hr;
+	IDirect3DCubeTexture9* pCubeTexture;
+	V( g_pd3dDevice->CreateCubeTexture(	size, 1, D3DUSAGE_RENDERTARGET,
+										Format, D3DPOOL_DEFAULT, &pCubeTexture, NULL ) );
+	return pCubeTexture;
+}
+
+
+//--------------------------------------------------------------------------------------
+// Render the help and statistics text.
+//--------------------------------------------------------------------------------------
+void RenderText()
+{
+	const D3DSURFACE_DESC* backBufferDesc = DXUTGetBackBufferSurfaceDesc();
+
+    CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );
+    txtHelper.Begin();
+
+	txtHelper.SetInsertionPos( 5, 5 );
+	txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
+
+	if(showUI)
+	{
+		txtHelper.DrawFormattedTextLine( L"%.2f fps @ %i x %i", 
+		DXUTGetFPS(), backBufferDesc->Width, backBufferDesc->Height );
+		//txtHelper.DrawTextLine( DXUTGetFrameStats() );
+		txtHelper.DrawTextLine( DXUTGetDeviceStats() );
+		//txtHelper.DrawTextLine( L"" );
+		
+		txtHelper.SetInsertionPos( 5, 120 );
+		txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
+	
+		switch(currentMethod)
+		{
+			case 0:txtHelper.DrawFormattedTextLine( L"Method : Depth of Field with Circle of Confusion");break;
+		}
+	}
+	txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) );
+
+	if ( pp.Get( bShowHelp ) )
+	{
+		txtHelper.SetInsertionPos( backBufferDesc->Width - 260, backBufferDesc->Height-24*15 );
+
+		txtHelper.DrawTextLine( 
+				L"Controls (F1 to hide):\n\n"
+				L"___________________________________\n"
+				L"                     GENERAL CONTROLS\n"
+				L"Left click drag: Rotate mesh\n"
+				L"Mouse wheel: Zoom\n"
+				L"F3: Switch to REF device\n"
+				L"F8: Switch to Wireframe mode\n"
+				L"Space: Show/Hide UI Elements\n"
+				L"___________________________________\n"
+				L"                             ALGORITHM\n"
+				L"TAB: Turn Displacement On/Off\n"
+				L"___________________________________\n"
+				L"                             UTILITIES\n"
+				L"L: [L]oad view & eye params\n"
+				L"S: [S]ave view & eye params\n"
+				L"Alt+S: [S]ave Screenshot\n"
+				L"___________________________________\n"
+				L"                             Quit: ESC");
+	}
+	else
+	{
+	//	txtHelper.DrawTextLine( L"Press F1 for help" );
+	}
+	txtHelper.End();
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Media.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Media.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Media.h	(revision 760)
@@ -0,0 +1,12 @@
+#pragma once
+// macro definitions for all media paths
+
+// models for pixel displacement paths 
+#define pixelMESH0	L"Media\\Objects\\alagut.x"
+#define pixelMESH1	L"Media\\Objects\\kupola.x"
+
+
+// color and displacement texture paths
+#define COLOR_TEXTURE_PATH L"Media\\Maps\\alagut.bmp"
+#define DISPLACEMENT_TEXTURE_PATH L"Media\\Maps\\alagut_bump.bmp"
+#define DISTANCE_TEXTURE_PATH L"Media\\Maps\\lowrock_bump.bmp"
Index: GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.cpp	(revision 760)
@@ -0,0 +1,312 @@
+#include "dxstdafx.h"
+#include "media.h"
+#include ".\cameraeffects.h"
+
+CameraEffects::CameraEffects(void)
+{
+}
+
+CameraEffects::~CameraEffects(void)
+{
+}
+
+// Loads the selected mesh
+void CameraEffects::changeMesh(int meshid)
+{
+	if(meshid!=currentmesh)
+	{
+		switch (meshid)
+		{
+			case 1: mesh->Load(pixelMESH0);break;
+			case 2: mesh->Load(pixelMESH1);break;
+			default: return;
+		}
+		currentmesh=meshid;
+		mesh->computeTangent();	
+	}
+}
+
+void CameraEffects::OnCreateDevice( IDirect3DDevice9* pd3dDevice)
+{
+	this->pd3dDevice = pd3dDevice;		
+	mesh = new Mesh(pixelMESH0, 1, D3DXVECTOR3(0,0,0));
+	mesh->computeTangent();
+	// loading light sphere model
+	lightmesh = new Mesh(L"Media\\Objects\\light.x", 1, D3DXVECTOR3(0,0,0));
+	
+	ID3DXBuffer* errBuff = NULL;
+	// loading simple rendering shaders
+	if( FAILED(D3DXCreateEffectFromFile( pd3dDevice, L"shaders/BumpMapping.fx", NULL, NULL, NULL,
+		NULL, &g_pEffect, &errBuff )))
+	{
+		int BufSize = errBuff->GetBufferSize();
+		// displaying error message of arbitrary length
+		wchar_t* wbuf = new wchar_t[BufSize];
+		mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize );
+		MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR);		// show error message
+		delete wbuf;
+		exit(-1);
+	}
+	// loading Depth Of Field shaders
+	if( FAILED(D3DXCreateEffectFromFile( pd3dDevice, L"shaders/CameraEffects.fx", NULL, NULL, NULL,
+		NULL, &g_pPostEffect, &errBuff )))
+	{
+		int BufSize = errBuff->GetBufferSize();
+		// displaying error message of arbitrary length
+		wchar_t* wbuf = new wchar_t[BufSize];
+		mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize );
+		MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR);		// show error message
+		delete wbuf;
+		exit(-1);
+	}
+}
+
+void CameraEffects::OnDestroyDevice()
+{
+	delete mesh;
+	delete lightmesh;
+	SAFE_RELEASE( g_pEffect );
+	SAFE_RELEASE( g_pPostEffect );
+}
+
+void CameraEffects::OnResetDevice(D3DSURFACE_DESC* pBackBufferDesc)
+{
+	m_ScreenWidth = pBackBufferDesc->Width;
+	m_ScreenHeight = pBackBufferDesc->Height;
+
+	if( g_pEffect )
+        g_pEffect->OnResetDevice();
+	
+	// loading color texture
+	D3DXCreateTextureFromFile( pd3dDevice, COLOR_TEXTURE_PATH, &ColorTexture );
+	// loading height map and converting to (RGB - normal, A - height) format without mipmap creation
+	CreateBumpMap(false);
+	// Create full-screen texture for post-process effects (RGB)
+	FrameBufferTexture = new CDXTexture();
+	if (!FrameBufferTexture->InitTex(pd3dDevice, "framebuffer", m_ScreenWidth, m_ScreenHeight, D3DFMT_A8R8G8B8, false))
+	{
+		MessageBox(NULL, L"FrameBufferTexture creation failed!",L"", MB_OK);
+	}
+	// create full-screen texture for post-process effects (blurriness, depth)
+	FrameBufferDepthTexture = new CDXTexture();
+	if (!FrameBufferDepthTexture->InitTex(pd3dDevice, "framebufferdepth", m_ScreenWidth, m_ScreenHeight, D3DFMT_G16R16F, false))
+	{
+		MessageBox(NULL, L"FrameBufferDepthTexture creation failed!",L"", MB_OK);
+	}
+
+	// create vertex buffer for full-screen quad
+	pd3dDevice->CreateVertexBuffer(sizeof(float) * 18, D3DUSAGE_WRITEONLY, D3DFVF_XYZ, D3DPOOL_DEFAULT, &FullScreenQuad, 0);
+	float* snipet;
+	FullScreenQuad->Lock(0, 0, (void**)&snipet, D3DLOCK_DISCARD);
+	int index = 0;
+	snipet[index++] = -1; snipet[index++] = -1; snipet[index++] = 0; 
+	snipet[index++] =  1; snipet[index++] =  1; snipet[index++] = 0;  
+	snipet[index++] =  1; snipet[index++] = -1; snipet[index++] = 0;  
+
+	snipet[index++] = -1; snipet[index++] = -1; snipet[index++] = 0;  
+	snipet[index++] = -1; snipet[index++] =  1; snipet[index++] = 0;  
+	snipet[index++] =  1; snipet[index++] =  1; snipet[index++] = 0;  
+
+	FullScreenQuad->Unlock();
+}
+
+void CameraEffects::OnLostDevice()
+{
+	if( g_pEffect )
+        g_pEffect->OnLostDevice();
+	if( g_pPostEffect )
+        g_pPostEffect->OnLostDevice();
+
+	SAFE_RELEASE(DisplacementTexture);
+	SAFE_RELEASE(ColorTexture);
+	SAFE_RELEASE(FullScreenQuad);
+	delete FrameBufferTexture;
+	delete FrameBufferDepthTexture;
+}
+
+void CameraEffects::CreateBumpMap(bool createMipMaps)
+{
+	D3DXIMAGE_INFO info;
+	
+	// height field is loaded into temporal texture
+	LPDIRECT3DTEXTURE9 heightTex;
+	D3DXCreateTextureFromFileEx( 
+		pd3dDevice,
+		DISPLACEMENT_TEXTURE_PATH,
+		D3DX_DEFAULT, D3DX_DEFAULT,
+		createMipMaps ? D3DX_DEFAULT : 1,  // mipmap levels
+		0, 
+		D3DFMT_A8R8G8B8,
+		D3DPOOL_MANAGED,
+		D3DX_DEFAULT,
+		D3DX_DEFAULT,
+		NULL,
+		&info,
+		NULL,
+		&heightTex);
+
+	// texture creation
+	V(D3DXCreateTexture(pd3dDevice, info.Width, info.Height, createMipMaps ? D3DX_DEFAULT : 1, 0, D3DFMT_Q8W8V8U8, D3DPOOL_MANAGED, &DisplacementTexture));
+
+	// normal map számítás
+	V(D3DXComputeNormalMap(DisplacementTexture, heightTex, NULL, 0, D3DX_CHANNEL_RED, 5.0f));
+
+	D3DLOCKED_RECT rect1, rect2;
+	V(heightTex->LockRect(0, &rect2, 0, D3DLOCK_READONLY));
+	//
+	// copy height map to DisplacementTexture's alpha channel
+	// mipmap levels too, biased to [-128, +127]
+	//
+	int level = 0;
+	while (createMipMaps ? (pow(2, level) <= info.Height) : (level == 0)) {
+		V(DisplacementTexture->LockRect(level, &rect1, 0, 0));
+		char* target = (char*)rect1.pBits;
+		unsigned char* source = (unsigned char*)rect2.pBits;
+		int mul = (int)pow(2, level);
+		for (unsigned int i = 0; i < info.Height / mul; i++) {
+			for (unsigned int j = 0; j < info.Width / mul; j++) {
+				int index1 = i * rect1.Pitch / 4 + j;
+				
+				int index2a = i * mul * rect2.Pitch / 4 +  j * mul;
+				int index2b = (i*mul+mul/2) * rect2.Pitch / 4+ j*mul;
+				int index2c = i*mul * rect2.Pitch / 4+ j*mul + mul/2;
+				int index2d = (i*mul+mul/2) * rect2.Pitch / 4 + j*mul + mul/2;
+				
+				target[index1 * 4 + 3] =(char)((source[4*index2a]+source[4*index2b]+source[4*index2c]+source[4*index2d]) / 8.0f);
+			}
+		}
+		DisplacementTexture->UnlockRect(level);
+		level++;
+	}
+	heightTex->UnlockRect(0);
+	heightTex->Release();
+}
+
+
+// prepares the depth of field filter kernel array
+void CameraEffects::SetupFilterKernel()
+{
+	FLOAT dx = 1.0f / (FLOAT)m_ScreenWidth;
+	FLOAT dy = 1.0f / (FLOAT)m_ScreenHeight;
+
+	D3DXVECTOR4 v[12];
+	v[0]  = D3DXVECTOR4(-0.326212f * dx, -0.405805f * dy, 0.0f, 0.0f);
+	v[1]  = D3DXVECTOR4(-0.840144f * dx, -0.07358f * dy, 0.0f, 0.0f);
+	v[2]  = D3DXVECTOR4(-0.695914f * dx, 0.457137f * dy, 0.0f, 0.0f);
+	v[3]  = D3DXVECTOR4(-0.203345f * dx, 0.620716f * dy, 0.0f, 0.0f);
+	v[4]  = D3DXVECTOR4(0.96234f * dx, -0.194983f * dy, 0.0f, 0.0f);
+	v[5]  = D3DXVECTOR4(0.473434f * dx, -0.480026f * dy, 0.0f, 0.0f);
+	v[6]  = D3DXVECTOR4(0.519456f * dx, 0.767022f * dy, 0.0f, 0.0f);
+	v[7]  = D3DXVECTOR4(0.185461f * dx, -0.893124f * dy, 0.0f, 0.0f);
+	v[8]  = D3DXVECTOR4(0.507431f * dx, 0.064425f * dy, 0.0f, 0.0f);
+	v[9]  = D3DXVECTOR4(0.89642f * dx, 0.412458f * dy, 0.0f, 0.0f);
+	v[10] = D3DXVECTOR4(-0.32194f * dx, -0.932615f * dy, 0.0f, 0.0f);
+	v[11] = D3DXVECTOR4(-0.791559f * dx, -0.597705f * dy, 0.0f, 0.0f);
+
+	g_pPostEffect->SetVectorArray("filterTaps", v, 12);
+}
+
+// rendering
+void CameraEffects::OnFrameRender( D3DXMATRIXA16& mView, D3DXMATRIXA16& mProj )
+{		
+	// setting the full screen-textures as render targets 0 and 1
+	FrameBufferTexture->StartRender(true, 0);
+	FrameBufferDepthTexture->StartRender(false, 1);
+	// clear screen
+	D3DCOLOR backgroundColor = D3DCOLOR_ARGB(0, 66, 75, 121);
+	V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, backgroundColor, 1.0f, 0) );
+
+	// setting up matrices
+	D3DXMATRIXA16 mWorld;
+	D3DXMatrixTranslation(&mWorld,LightPos->x,LightPos->y,LightPos->z);
+	pd3dDevice->SetTransform( D3DTS_PROJECTION, &mProj );	
+	pd3dDevice->SetTransform( D3DTS_WORLD, &mWorld );	
+	pd3dDevice->SetTransform( D3DTS_VIEW, &mView );	
+	// draw light source
+	lightmesh->Draw();
+	D3DXMATRIX Trans, Rot;
+	D3DXMatrixTranslation(&Trans, 0, 0, -27);
+	D3DXMatrixRotationY(&Rot,  3.1415792);
+	D3DXMatrixMultiply(&mWorld, &Trans, &Rot);
+	SetWorldViewProj(mWorld,mView,mProj);
+
+	// LightPos and CameraPos is needed in Model Space in shader
+	D3DXVECTOR4 mEye, mLight, wEye, wLight;
+	wEye = D3DXVECTOR4(camera->GetEyePt()->x,camera->GetEyePt()->y,camera->GetEyePt()->z, 1.0f);
+	wLight=D3DXVECTOR4(LightPos->x, LightPos->y, LightPos->z, 1.0f);
+	D3DXVec4Transform(&mEye, &wEye, &m_InvWorld);
+	D3DXVec4Transform(&mLight, &wLight, &m_InvWorld);
+
+	// setting shader parameters
+	D3DSURFACE_DESC desc;
+	DisplacementTexture->GetLevelDesc(0,&desc);
+	g_pEffect->SetTexture("BumpMap", DisplacementTexture);
+	g_pEffect->SetTexture("ColorMap", ColorTexture);
+	g_pEffect->SetFloat("focalDist", params->Get(fFocalDistance));
+	g_pEffect->SetFloat("focalRange", 0.1f);
+
+	float lp[] = {mLight.x, mLight.y, mLight.z};
+	g_pEffect->SetFloatArray("mLightPos", lp, 3);
+	float cp[] = {mEye.x, mEye.y, mEye.z};
+	g_pEffect->SetFloatArray("mCameraPos", cp, 3);
+
+	g_pEffect->CommitChanges();
+	g_pEffect->SetTechnique("BumpMapping");
+	UINT p;
+	g_pEffect->Begin(&p, 0 );
+	g_pEffect->BeginPass( 0 );	
+		
+	mesh->Draw();
+	
+	g_pEffect->EndPass();
+	g_pEffect->End();
+
+
+	FrameBufferTexture->EndRender();
+	FrameBufferDepthTexture->EndRender();
+
+	// doing DoF post-processing
+	pd3dDevice->SetStreamSource(0, FullScreenQuad, 0, sizeof(float) * 3);
+	pd3dDevice->SetFVF(D3DFVF_XYZ);
+
+	g_pPostEffect->SetTexture("ColorMap", FrameBufferTexture->m_Tex);
+	g_pPostEffect->SetTexture("DepthMap", FrameBufferDepthTexture->m_Tex);
+	
+	SetupFilterKernel();
+	
+	g_pPostEffect->CommitChanges();
+
+	g_pPostEffect->SetTechnique("DepthOfField");
+
+	g_pPostEffect->Begin(&p, 0 );
+	g_pPostEffect->BeginPass( 0 );	
+	// drawing full-screen quad
+	pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
+
+	g_pPostEffect->EndPass();
+	g_pPostEffect->End();
+}
+
+void CameraEffects::addUiParams(Parameters& p)
+{
+	params=&p;
+	p.Add( fFocalDistance, "Focal Distance", 100, convertToZeroTo30 );
+	//p.Add( fDisplacementScale, "Scale", 100, convertToMinusOne_One );
+
+}
+
+void CameraEffects::SetWorldViewProj(D3DXMATRIXA16& mWorld, D3DXMATRIXA16& mView, D3DXMATRIXA16& mProj )
+{
+	D3DXMatrixInverse(&m_InvWorld,0,&mWorld); // inverse matrix
+	D3DXMATRIXA16 mWorldView = mWorld * mView;
+	D3DXMATRIXA16 mWorldViewProjection = mWorldView * mProj;
+
+	D3DXMATRIXA16 mWorldViewI, mWorldViewIT;
+	D3DXMatrixInverse(&mWorldViewI, NULL, &mWorldView);
+	D3DXMatrixTranspose(&mWorldViewIT, &mWorldViewI);
+
+	V( g_pEffect->SetMatrix( "WorldView", &mWorldView ) );
+	V( g_pEffect->SetMatrix( "WorldViewIT", &mWorldViewIT ) );
+	V( g_pEffect->SetMatrix( "WorldViewProj", &mWorldViewProjection ) );
+	V( g_pEffect->CommitChanges() );
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/depthoffield.txt
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/depthoffield.txt	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/depthoffield.txt	(revision 760)
@@ -0,0 +1,192 @@
+Depth Of Field demo
+-------------------
+
+Controls:
+
+Mouse controlls the camera orientation.
+Focal Distance parameter controlls the focal depth of the simulated camera.
+
+The implemented method:
+-----------------------
+
+
+Depth of Field with Simulation of Circle of Confusion
+
+Multiple rays scattered from a given point on an object will pass through the camera lens, forming the cone of light. If the object is in focus, all rays will converge at a single point on the image plane. However, if a given point on an object in the scene is not near the focal distance, the cone of light rays will intersect the image plane in an area shaped like a conic section. Typically, the conic section is approximated by a circle called the circle of confusion. The circle of confusion diameter b depends on the distance of the plane of focus and lens aperture setting a (also known as f-stop). For a known focus distance and lens parameters, size of the circle of confusion can be calculated as: b = (D * f* (zfocus - z))/(zfocus*(z - f)) where D is a lens diameter D= f / a and f is the focal length of the lens. Any circle of confusion greater than the smallest point a human eye can resolve contributes to the blurriness of the image that we see as a depth of field.
+
+The methods presented in this section are all post-processing methods. It means that they consist of two main phases. In the first phase, the scene is rendered into an off-screen buffer once or more. In the second phase, the final image is computed from the off-screen image buffers and some type of depth controlled blurring. 
+
+Phase 1: 
+First, the whole scene is rendered by outputting depth and blurriness factor, which is used to describe how much each pixel should be blurred, in addition to the resulting scene rendering color. This can be accomplished by rendering the scene to the multiple buffers at one time. DirectX® 9 has a useful feature called Multiple Render Targets (MRT) that allows simultaneous shader output into the multiple renderable buffers. Using this feature gives us the ability to output all of the data channels (scene color, depth and blurriness factor) in our first pass. One of the MRT restrictions on some hardware is the requirement for all render surfaces to have the same bit depth, while allowing use of different surface formats. Guided by this requirement we can pick the D3DFMT_A8R8G8B8 format for the scene color output and the two-channel texture format D3DFMT_G16R16 format for depth and blurriness factor. Both formats are 32-bits per pixel, and provide us with enough space for the necessary information at the desired precision.
+
+Depth of Field with Simulation of Circle of Confusion
+
+Multiple rays scattered from a given point on an object will pass through the camera lens, forming the cone of light. If the object is in focus, all rays will converge at a single point on the image plane. However, if a given point on an object in the scene is not near the focal distance, the cone of light rays will intersect the image plane in an area shaped like a conic section. Typically, the conic section is approximated by a circle called the circle of confusion. The circle of confusion diameter b depends on the distance of the plane of focus and lens aperture setting a (also known as f-stop). For a known focus distance and lens parameters, size of the circle of confusion can be calculated as: b = (D * f* (zfocus - z))/(zfocus*(z - f)) where D is a lens diameter D= f / a and f is the focal length of the lens. Any circle of confusion greater than the smallest point a human eye can resolve contributes to the blurriness of the image that we see as a depth of field.
+
+The methods presented in this section are all post-processing methods. It means that they consist of two main phases. In the first phase, the scene is rendered into an off-screen buffer once or more. In the second phase, the final image is computed from the off-screen image buffers and some type of depth controlled blurring. 
+
+Phase 1: 
+First, the whole scene is rendered by outputting depth and blurriness factor, which is used to describe how much each pixel should be blurred, in addition to the resulting scene rendering color. This can be accomplished by rendering the scene to the multiple buffers at one time. DirectX® 9 has a useful feature called Multiple Render Targets (MRT) that allows simultaneous shader output into the multiple renderable buffers. Using this feature gives us the ability to output all of the data channels (scene color, depth and blurriness factor) in our first pass. One of the MRT restrictions on some hardware is the requirement for all render surfaces to have the same bit depth, while allowing use of different surface formats. Guided by this requirement we can pick the D3DFMT_A8R8G8B8 format for the scene color output and the two-channel texture format D3DFMT_G16R16 format for depth and blurriness factor. Both formats are 32-bits per pixel, and provide us with enough space for the necessary information at the desired precision.
+
+The implementation of the first phase: The pixel shader of the scene rendering pass needs to compute the blurriness factor and output it along with the scene depth and color. To abstract from the different display sizes and resolutions, the blurriness is defined to lie in the 0..1 range. A value of zero means the pixel is perfectly sharp, while a value of one corresponds to the pixel of the maximal circle of confusion size. The reason behind using 0..1 range is twofold. First, the blurriness is not expressed in terms of pixels and can scale with resolution during the post-processing step. Second, the values can be directly used as sample weights when eliminating bleeding artifacts.
+For each pixel of a scene, this shader computes the circle of confusion size based on the formula provided in the preceding discussion of the thin lens model. Later in the process, the size of the circle of confusion is scaled by the factor corresponding to size of the circle in pixels for a given resolution and display size. As a last step, the blurriness value is divided by maximal desired circle of confusion size in pixels (variable maxCoC) and clamped to the 0..1 range. Sometimes it might be necessary to limit the circle of confusion size (through the variable maxCoC) to reasonable values (i.e. 10 pixels) to avoid sampling artifacts caused by an insufficient number of filter taps.
+
+struct VS_INPUT {
+	float4 Position  : POSITION;
+	float3 Normal	 : NORMAL;					
+	float3 Binormal	 : BINORMAL;
+	float3 Tangent	 : TANGENT;
+	float4 TexCoord0 : TEXCOORD0;
+};
+
+struct VS_OUTPUT {
+        float4 hPosition : POSITION;     // point in normalized device space before homogeneous division
+        float2 TexCoord  : TEXCOORD0;    // texture coordinates
+        float3 tView     : TEXCOORD1;    // tangent space view vector
+        float3 tLight    : TEXCOORD2;    // tangent space light vector
+	float  Depth    : TEXCOORD3;
+};
+
+struct PS_OUTPUT {
+	float4 Color : COLOR0;
+	float4 Depth : COLOR1;
+};
+
+VS_OUTPUT BumpVS(VS_INPUT IN)
+{
+        VS_OUTPUT output;
+   
+        // object-space tangent matrix
+	float3x3 Tan = float3x3(normalize(IN.Tangent), normalize(IN.Binormal), IN.Normal);
+        // position in view-space
+        float3 P = mul(IN.Position, WorldView);
+	// model-space view vector        
+	float3 mView = mCameraPos - IN.Position;
+	// model-space light vector
+	float3 mLight = mLightPos - IN.Position;
+	// tangent-space view vector
+	output.tView = mul(Tan, mView);
+	// tangent-space light vector
+	output.tLight =  mul(Tan, mLight);
+        // vertex position before homogenious division
+        output.hPosition = mul(IN.Position, WorldViewProj);
+	// tex coordinates passed to pixel shader
+        output.TexCoord = IN.TexCoord0;
+	output.Depth = output.hPosition.z;
+
+        return output;
+}
+
+
+PS_OUTPUT BumpPS(VS_OUTPUT IN)
+{
+	PS_OUTPUT output;
+	// needs normalization because of linear interpolation
+    	float3 View = normalize( IN.tView );
+    	// needs normalization because of linear interpolation    
+    	float3 Light = normalize( IN.tLight );
+    	// get tangent-space normal from normal map
+    	float3 Normal = tex2D(BumpMapSampler, IN.TexCoord).rgb;
+    	// illumination calculation
+    	output.Color = Illumination(Light, Normal, View, IN.TexCoord, Attenuation(IN.tLight));
+    
+    	float blur = saturate(abs(IN.Depth - focalDist) * focalRange);
+    	output.Depth = float4(IN.Depth, blur, 0, 0);
+
+    	return output;
+}
+
+
+Phase 2:
+During the post-processing phase, the results of the previous rendering are processed and the color image is blurred based on the blurriness factor computed in the first phase. Blurring is performed using a variable-sized filter representing the circle of confusion. To perform image filtering, a simple screen-aligned quadrilateral is drawn, textured with the results of the first phase.
+The filter kernel in the post-processing step has 13 samples - a center sample and 12 outer samples. The number of samples can vary but 12 represents the maximum number of samples that can be processed by a 2.0 pixel shader in a single pass.
+The post-processing pixel-shader computes filter smaple positions based on a 2D offset stored in filterTaps array, initialized by the following function:
+
+void SetupFilterKernel()
+{
+	FLOAT dx = 1.0f / (FLOAT)m_ScreenWidth;
+	FLOAT dy = 1.0f / (FLOAT)m_ScreenHeight;
+
+	D3DXVECTOR4 v[12];
+	v[0]  = D3DXVECTOR4(-0.326212f * dx, -0.405805f * dy, 0.0f, 0.0f);
+	v[1]  = D3DXVECTOR4(-0.840144f * dx, -0.07358f * dy, 0.0f, 0.0f);
+	v[2]  = D3DXVECTOR4(-0.695914f * dx, 0.457137f * dy, 0.0f, 0.0f);
+	v[3]  = D3DXVECTOR4(-0.203345f * dx, 0.620716f * dy, 0.0f, 0.0f);
+	v[4]  = D3DXVECTOR4(0.96234f * dx, -0.194983f * dy, 0.0f, 0.0f);
+	v[5]  = D3DXVECTOR4(0.473434f * dx, -0.480026f * dy, 0.0f, 0.0f);
+	v[6]  = D3DXVECTOR4(0.519456f * dx, 0.767022f * dy, 0.0f, 0.0f);
+	v[7]  = D3DXVECTOR4(0.185461f * dx, -0.893124f * dy, 0.0f, 0.0f);
+	v[8]  = D3DXVECTOR4(0.507431f * dx, 0.064425f * dy, 0.0f, 0.0f);
+	v[9]  = D3DXVECTOR4(0.89642f * dx, 0.412458f * dy, 0.0f, 0.0f);
+	v[10] = D3DXVECTOR4(-0.32194f * dx, -0.932615f * dy, 0.0f, 0.0f);
+	v[11] = D3DXVECTOR4(-0.791559f * dx, -0.597705f * dy, 0.0f, 0.0f);
+
+	g_pPostEffect->SetVectorArray("filterTaps", v, 12);
+}
+
+One of the problems with all post-filtering methods is leaking or "bleeding" of color from sharp objects onto the blurry backgrounds. This results in faint halos around sharp objects. The color leaking happens because the filter for the blurry background will sample color from the sharp object in the vicinity due to the large filter size. To solve this problem, we will discard the outer samples that can contribute to leaking according to the following criteria: if the outer sample is in focus and it is in front of the blurry center sample, it should not contribute to the blurred color. This can introduce a minor popping effect when objects go in or out of focus. To combat sample popping, the outer sample blurriness factor is used as a sample weight to fade out its contribution gradually. 
+
+The vertex shader implementation is feeded with a fullscreen quad without texture coordinates. Those are calculated in the vertex shader and passed to the pixel shader. 
+
+struct VS_INPUT {
+		float3 Position : POSITION;
+};
+
+struct VS_OUTPUT {
+        float4 hPosition : POSITION;     // point in normalized device space before homogeneous division
+        float2 TexCoord  : TEXCOORD0;
+};
+
+VS_OUTPUT DepthVS(VS_INPUT IN)
+{
+	VS_OUTPUT output;
+    
+    output.hPosition = half4(IN.Position, 1);
+    
+    output.TexCoord = IN.Position.xy * 0.5f + 0.5f; 
+    output.TexCoord.y *= -1;
+
+    return output;
+}
+//------------------------------------------------------------------------------------
+//
+// DoF pixel shader
+//
+//------------------------------------------------------------------------------------
+const float maxCoC = 5;
+float4 DepthPS(VS_OUTPUT IN) : COLOR
+{
+	// Get center sample
+	float4 colorSum = tex2D(ColorMapSampler, IN.TexCoord);
+	float2 centerDepthBlur = tex2D(DepthMapSampler, IN.TexCoord);
+
+	// Compute CoC size based on blurriness
+	float sizeCoC = centerDepthBlur.y * maxCoC;
+
+	float totalContribution = 1.0f;
+
+	// Run through all taps
+	for (int i = 0; i < NUM_DOF_TAPS; i++)
+	{
+		// Compute tap coordinates
+		float2 tapCoord = IN.TexCoord + filterTaps[i] * sizeCoC;
+
+		// Fetch tap sample
+		float4 tapColor = tex2D(ColorMapSampler, tapCoord);
+		float2 tapDepthBlur = tex2D(DepthMapSampler, tapCoord);
+
+		// Compute tap contribution
+		float tapContribution = (tapDepthBlur.x > centerDepthBlur.x) ? 1.0f : tapDepthBlur.y;
+
+		// Accumulate color and contribution
+		colorSum += tapColor * tapContribution;
+		totalContribution += tapContribution;
+	}
+
+	// Normalize to get proper luminance
+	float4 finalColor = colorSum / totalContribution;
+
+	return finalColor;
+}
+
+
Index: GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/DXTexture.cpp	(revision 760)
@@ -0,0 +1,81 @@
+#include "dxstdafx.h"
+#include ".\dxtexture.h"
+#include <d3dx9.h>
+#include <dxerr9.h>
+
+
+CDXTexture::CDXTexture()
+{
+	SetStage(0);
+	m_Stencil = NULL;
+	m_Tex = NULL;
+	m_pBackBuffer = NULL;
+	m_OrigDepthStencil = NULL;
+	m_RTindex = 0;
+}
+
+CDXTexture::~CDXTexture(void)
+{
+	SAFE_RELEASE(m_Tex);
+	SAFE_RELEASE(m_Stencil);
+	SAFE_RELEASE(m_pBackBuffer);
+	SAFE_RELEASE(m_OrigDepthStencil);
+}
+
+bool CDXTexture::InitTex(LPDIRECT3DDEVICE9 dev, char* filename, char* tex_name, D3DFORMAT format)
+{
+	CopyToName(tex_name);
+	
+	m_Dev = dev;
+	
+	D3DXIMAGE_INFO info;
+	
+	D3DXCreateTextureFromFileEx(
+		dev,		   // device
+		(LPCWSTR)filename,      // filename
+		D3DX_DEFAULT,  // x size
+		D3DX_DEFAULT,  // y size
+		D3DX_DEFAULT,  // mipmap
+		0,			   // usage
+		format,// a tárolási formát a file határozza meg
+		D3DPOOL_DEFAULT,// a videomemóriába legyen
+		D3DX_DEFAULT,  // filterek
+		D3DX_DEFAULT,  // mipmap filter
+		0,             // nincs colorkey
+		&info,         // file infókat ide adja
+		NULL,
+		&m_Tex);
+	
+	return true;
+}
+
+bool CDXTexture::InitTex(LPDIRECT3DDEVICE9 dev, char* tex_name, int width, int height, D3DFORMAT format, bool mipmapped)
+{
+	CopyToName(tex_name);
+
+	m_Dev = dev;
+	m_Width = width;
+	m_Height = height;
+	// create new texture
+	HRESULT res = D3DXCreateTexture(m_Dev, width, height, mipmapped ? 0 : 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &m_Tex);
+	if (res != D3D_OK)
+	{
+		return false;
+	}
+	res = m_Dev->CreateDepthStencilSurface(width, height, D3DFMT_D24S8, D3DMULTISAMPLE_NONE,0,true,&m_Stencil,NULL);
+	if (res != D3D_OK){
+		return false;
+	}
+	
+	return true;
+}
+
+
+
+void CDXTexture::CopyToName(char* name)
+{
+	if (strlen(name) > 512)
+		name[500] = '\0';
+	
+	strcpy(m_Name, name);
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.cpp	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/Mesh.cpp	(revision 760)
@@ -0,0 +1,175 @@
+
+#include "dxstdafx.h"
+#include "Mesh.h"
+
+extern IDirect3DDevice9* g_pd3dDevice;
+
+// source: DirectX SDK Samples / OptimizedMesh
+
+Mesh::Mesh(float preferredDiameter)
+{
+	originalDiameter = 1;
+	this->preferredDiameter = preferredDiameter;
+	originalSize = D3DXVECTOR3(1,1,1); 
+	position = D3DXVECTOR3(0,0,0); 
+	containerSize = D3DXVECTOR3(1,1,1); 
+	numMaterials = 0;
+	pMesh = NULL;
+	//if (g_pd3dDevice == NULL) exit(-1);
+}
+
+Mesh::Mesh(LPCWSTR fileName, float preferredDiameter, D3DXVECTOR3 offset)
+{
+	originalDiameter = 1;
+	this->preferredDiameter = preferredDiameter;
+	originalSize = D3DXVECTOR3(1,1,1); 
+	position = D3DXVECTOR3(0,0,0); 
+	containerSize = D3DXVECTOR3(1,1,1); 
+	numMaterials = 0;
+	pMesh = NULL;
+
+	Load(fileName);
+	Move(offset);
+}
+
+void Mesh::Move(D3DXVECTOR3 movement) 
+{
+	position += movement;
+
+	// keep some distance from the walls
+	D3DXVECTOR3 maxOffset = containerSize*0.99f - GetMeshSize();
+	D3DXVECTOR3 minOffset = -maxOffset;
+/*
+	if (position.x > maxOffset.x) position.x = maxOffset.x;
+	if (position.y > maxOffset.y) position.y = maxOffset.y;
+	if (position.z > maxOffset.z) position.z = maxOffset.z;
+
+	if (position.x < minOffset.x) position.x = minOffset.x;
+	if (position.y < minOffset.y) position.y = minOffset.y;
+	if (position.z < minOffset.z) position.z = minOffset.z;*/
+}
+
+Mesh::~Mesh()
+{
+    SAFE_RELEASE( pMesh );
+}
+
+HRESULT Mesh::CalculateMeshSize( )
+{
+	// default size
+	originalSize = D3DXVECTOR3(1,1,1); 
+	originalDiameter = 1;
+
+	IDirect3DVertexBuffer9* pMeshVB = NULL;
+	D3DXVECTOR3 minPos, maxPos;
+	BYTE* pVertices;
+
+	// Lock the vertex buffer to generate a simple bounding box
+
+	hr = pMesh->GetVertexBuffer( &pMeshVB );
+	if( SUCCEEDED( hr ) )
+	{
+		hr = pMeshVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_NOSYSLOCK );
+		if( SUCCEEDED(hr) )
+		{
+			V( D3DXComputeBoundingBox( ( D3DXVECTOR3*)pVertices, pMesh->GetNumVertices(),
+									D3DXGetFVFVertexSize( pMesh->GetFVF() ),
+									&minPos, &maxPos ) );
+
+			D3DXVECTOR3 vCenter = ( minPos + maxPos ) / 2.0f;
+
+			// eliminating offset from the mesh
+
+			DWORD numVerts = pMesh->GetNumVertices();					// get the face count
+			DWORD vertSize = D3DXGetFVFVertexSize(pMesh->GetFVF());		// calculate vertex size
+
+			for (DWORD i = 0; i < numVerts; i++)						// loop through the vertices
+			{
+				D3DXVECTOR3 *vPtr=(D3DXVECTOR3*)pVertices;				
+				*vPtr -= vCenter;										// eliminating offset
+				pVertices += vertSize;									// set pointer to next vertex
+			}
+
+			pMeshVB->Unlock();
+			pMeshVB->Release();
+
+			// size of the object
+			originalSize = ( maxPos - minPos ) / 2.0f;
+			// object "diameter" is calculated from the size of the bounding box only
+			originalDiameter = sqrt( originalSize.x * originalSize.x + 
+									 originalSize.y * originalSize.y +
+									 originalSize.z * originalSize.z) / 1.732f;
+		}
+	}
+	
+	return hr;
+}
+
+void Mesh::Load( LPCWSTR fileName )
+{  
+	SAFE_RELEASE( pMesh );
+    pMesh = NULL;
+
+//    HRESULT hr;
+
+    if (FAILED( D3DXLoadMeshFromX(fileName, D3DXMESH_MANAGED, g_pd3dDevice, NULL, NULL, NULL, &numMaterials, &pMesh) ))
+	{
+		MessageBox(NULL, L"Media not found!", fileName, MB_ICONEXCLAMATION);
+		exit(-1);
+	}
+/*	
+	if ( FAILED( CalculateMeshSize() ))
+	{
+		MessageBox(NULL, L"Could not calculate bounding box!\nUsing original mesh size...",
+			fileName, MB_ICONEXCLAMATION);
+	}
+
+    DWORD *rgdwAdjacency = NULL;
+
+    // Make sure there are normals which are required for lighting
+    if( !(pMesh->GetFVF() & D3DFVF_NORMAL) )
+    {
+        ID3DXMesh* pTempMesh;
+        V( pMesh->CloneMeshFVF( pMesh->GetOptions(), 
+                                  pMesh->GetFVF() | D3DFVF_NORMAL, 
+                                  g_pd3dDevice, &pTempMesh ) );
+        V( D3DXComputeNormals( pTempMesh, NULL ) );
+
+        SAFE_RELEASE( pMesh );
+        pMesh = pTempMesh;
+    }
+
+    // Optimize the mesh for this graphics card's vertex cache 
+    rgdwAdjacency = new DWORD[pMesh->GetNumFaces() * 3];
+    if( rgdwAdjacency == NULL ) return ;
+
+    V( pMesh->ConvertPointRepsToAdjacency(NULL, rgdwAdjacency) );
+    V( pMesh->OptimizeInplace(D3DXMESHOPT_VERTEXCACHE, rgdwAdjacency, NULL, NULL, NULL) );
+    delete[] rgdwAdjacency;	*/
+}
+
+void Mesh::computeTangent()
+{
+	//V(D3DXComputeTangentFrame(pMesh,D3DXTANGENT_DONT_NORMALIZE_PARTIALS));
+	D3DXComputeTangentFrameEx(pMesh, D3DDECLUSAGE_TEXCOORD, 0,   
+      D3DDECLUSAGE_TANGENT, 0, D3DDECLUSAGE_BINORMAL, 0, 
+      D3DDECLUSAGE_NORMAL, 0, 
+      D3DXTANGENT_DONT_NORMALIZE_PARTIALS | D3DXTANGENT_GENERATE_IN_PLACE,
+      NULL, 0.01f, 0.25f, 0.01f, NULL, NULL);
+
+
+}
+
+
+
+HRESULT Mesh::Draw()
+{
+	HRESULT hr;
+    // Set and draw each of the materials in the mesh
+    for( DWORD iMaterial = 0; iMaterial < numMaterials; iMaterial++ )
+    {
+        V( pMesh->DrawSubset( iMaterial ) );
+    }
+
+    return S_OK;
+}
Index: GTP/trunk/App/Demos/Illum/DepthOfField/resource.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/resource.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/resource.h	(revision 760)
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by EnvMap.rc
+//
+#define IDI_MAIN_ICON                   101
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        113
+#define _APS_NEXT_COMMAND_VALUE         40029
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
Index: GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.h
===================================================================
--- GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.h	(revision 760)
+++ GTP/trunk/App/Demos/Illum/DepthOfField/CameraEffects.h	(revision 760)
@@ -0,0 +1,52 @@
+#pragma once
+#include "Mesh.h"
+#include "Parameters.h"
+#include "DXTexture.h"
+
+class CameraEffects
+{
+	IDirect3DDevice9*			pd3dDevice; 
+	IDirect3DTexture9*			DisplacementTexture;		// texture for simple rendering 
+	IDirect3DTexture9*			ColorTexture;
+	CDXTexture*					FrameBufferTexture;
+	CDXTexture*					FrameBufferDepthTexture;
+
+	UINT m_ScreenWidth;
+	UINT m_ScreenHeight;
+
+	IDirect3DVertexBuffer9*		FullScreenQuad;
+
+	ID3DXEffect*            g_pEffect;
+	ID3DXEffect*            g_pPostEffect;
+	Mesh* mesh;
+	Mesh* lightmesh;
+
+	HRESULT					hr;				// return codes
+
+	D3DXMATRIX m_InvWorld;					// inverse world matrix
+
+public:
+	CModelViewerCamera* camera;	//!!
+	Parameters* params;
+	int currentmethod;
+	int currentmesh;
+	D3DXVECTOR3* LightPos;
+
+public:
+	CameraEffects(void);
+	~CameraEffects(void);
+	
+	void OnFrameRender( D3DXMATRIXA16& mView, D3DXMATRIXA16& mProj );
+
+	void SetupFilterKernel();
+	void OnCreateDevice( IDirect3DDevice9* pd3dDevice);
+	void OnDestroyDevice();
+	void OnResetDevice(D3DSURFACE_DESC* pBackBufferDesc);
+	void OnLostDevice();
+	void SetWorldViewProj(D3DXMATRIXA16& mWorld, D3DXMATRIXA16& mView, D3DXMATRIXA16& mProj );
+	
+	void addUiParams(Parameters& p);
+	void changeMesh(int meshid);
+
+	void CreateBumpMap(bool createMipMaps);
+};
