Sign in to follow this  

Integrating exported RenderMonkey .fx file into DirectX.

This topic is 3112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have been having the toughest time getting an .fx file exported from the RenderMonkey shadow example into my simple spinning cube program. I know the basics about shaders but not quite near efficient yet. If anyone would be able to help me integrate this shader into my program, this would be a tremendous help, and hopefully help out whoever else stumbles upon my post. Here is the simple spinning cube example I am using
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")

#include <windows.h>
#include <dx9/d3dx9.h>
#include <dx9/d3d9.h>

HDC        hDC = NULL;
HWND       hWnd = NULL;
HINSTANCE  hInstance;			
LPDIRECT3D9   pD3D = NULL;
LPDIRECT3DDEVICE9  pD3DDevice = NULL;

bool	keys[256];	
bool	active=TRUE;
bool	fullscreen=TRUE;

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)

IDirect3DVertexBuffer9 *pVertexBuffer = NULL;  // Our Vertex Buffer

struct tVertex				// Our new vertex struct
{
    float x, y, z;			// 3D position
    DWORD color;			// Hex Color Value
};


tVertex cube[24] =			// Vertex Array
{	
	// Front Blue Color
	{-1.0f, 1.0f,-1.0f,  0xF00FF00F },
	{ 1.0f, 1.0f,-1.0f,  0xF00FF00F },
	{-1.0f,-1.0f,-1.0f,  0xF00FF00F },
	{ 1.0f,-1.0f,-1.0f,  0xF00FF00F },
	// Back Orange Color
	{-1.0f, 1.0f, 1.0f,  0xFFF8800F },
	{-1.0f,-1.0f, 1.0f,  0xFFF8800F },
	{ 1.0f, 1.0f, 1.0f,  0xFFF8800F },
	{ 1.0f,-1.0f, 1.0f,  0xFFF8800F },
	// Top Red Color
	{-1.0f, 1.0f, 1.0f,  0xFFF0000F },
	{ 1.0f, 1.0f, 1.0f,  0xFFF0000F },
	{-1.0f, 1.0f,-1.0f,  0xFFF0000F },
	{ 1.0f, 1.0f,-1.0f,  0xFFF0000F },
	// Bottom Yellow Color
	{-1.0f,-1.0f, 1.0f,  0xFFFFF00F },
	{-1.0f,-1.0f,-1.0f,  0xFFFFF00F },
	{ 1.0f,-1.0f, 1.0f,  0xFFFFF00F },
	{ 1.0f,-1.0f,-1.0f,  0xFFFFF00F },
	// Right Blue Color
	{ 1.0f, 1.0f,-1.0f,  0xF0000FFF },
	{ 1.0f, 1.0f, 1.0f,  0xF0000FFF },
	{ 1.0f,-1.0f,-1.0f,  0xF0000FFF },
	{ 1.0f,-1.0f, 1.0f,  0xF0000FFF },
	// Left Violet Color
	{-1.0f, 1.0f,-1.0f,  0xFFF00FFF },
	{-1.0f,-1.0f,-1.0f,  0xFFF00FFF },
	{-1.0f, 1.0f, 1.0f,  0xFFF00FFF },
	{-1.0f,-1.0f, 1.0f,  0xFFF00FFF }
};

LRESULT	CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

void ReSizeD3DScene(int width, int height)		// Resize And Initialize The DX Window
{
	if (height==0)										// Prevent A Divide By Zero By
	{
		height=1;										// Making Height Equal One
	}

	D3DXMATRIX projection_matrix;

	D3DXMatrixPerspectiveFovLH(&projection_matrix, 45.0f, (float)width/(float)height, 0.1f, 100.0f );

	pD3DDevice->SetTransform( D3DTS_PROJECTION, &(D3DMATRIX)projection_matrix );
	D3DXMatrixIdentity(&projection_matrix);

}

int InitD3D()
{
	pD3DDevice->SetRenderState(D3DRS_ZENABLE,  TRUE ); // Z-Buffer (Depth Buffer)
    pD3DDevice->SetRenderState(D3DRS_CULLMODE, FALSE); // Disable Backface Culling
    pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); // Disable Light


	pD3DDevice->CreateVertexBuffer( 24*sizeof(tVertex),0, D3DFVF_CUSTOMVERTEX,
                                       D3DPOOL_DEFAULT, &pVertexBuffer, NULL );
	unsigned char *pVertices = NULL;

    pVertexBuffer->Lock( 0, sizeof(cube), (void**)&pVertices, 0 );
    memcpy( pVertices, cube, sizeof(cube) );
    pVertexBuffer->Unlock();

	return TRUE;
}

int DrawD3DScene()
{
	
    pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
								D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,0.0f), 1.0f, 0 );

	static float rotqube = 0.0f;
	rotqube  += 0.9f;


    D3DXMATRIX matWorld;			// Create The World Matrix
    D3DXMATRIX matTranslation;		// Create a Translation Matrix
	D3DXMATRIX matRotX;				// Create X Axis Rotation Matrix
	D3DXMATRIX matRotY;				// Create Y Axis Rotation Matrix
	D3DXMATRIX matRotZ;				// Create Z Axis Rotation Matrix
	D3DXMATRIX matRotXYZ;			// Create XYZ Rotation Matrix


    D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f ); // Translate The Cube 5 Units Into The Screen

	D3DXMatrixRotationY(&matRotY, D3DXToRadian(rotqube));		// Rotate In Y Direction
	D3DXMatrixRotationX(&matRotX, D3DXToRadian(rotqube));		// Rotate In X Direction
	D3DXMatrixRotationY(&matRotY, D3DXToRadian(rotqube));		// Rotate In Z Direction
	D3DXMatrixRotationZ(&matRotZ, D3DXToRadian(rotqube));

	D3DXMatrixRotationYawPitchRoll( &matRotXYZ, D3DXToRadian(rotqube), D3DXToRadian(rotqube), D3DXToRadian(rotqube) );

    matWorld = (matRotY * matRotX  * matRotZ) * matTranslation;



    pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );	// Set The Transformation

    pD3DDevice->BeginScene();							// Begin Direct3D Scene

    pD3DDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof(tVertex) );
    pD3DDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  0, 2 ); // Draw Front
	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  4, 2 ); // Draw Back
	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP,  8, 2 ); // Draw Top
	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 12, 2 ); // Draw Bottom
	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 16, 2 ); // Draw Right
	pD3DDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 20, 2 ); // Draw Left

	pD3DDevice->EndScene();								// End Direct3D Scene
	
	pD3DDevice->Present( NULL, NULL, NULL, NULL );// Display The Result
	
	return TRUE;
}

void KillD3DScene() 
{
    if( pVertexBuffer != NULL )	
	{ 
		pVertexBuffer->Release();						// Release The Vertex Buffer
		pVertexBuffer = NULL;
	}
}

void KillD3DWindow()									// Properly Kill The Window
{

	KillD3DScene();										// Release D3D Scene

    if (pD3DDevice != NULL)	pD3DDevice->Release();		// Release D3D Device
	
	if (pD3D != NULL) pD3D->Release();					// Release D3D Interface

	if (fullscreen)										// Are We In Fullscreen Mode?
	{
		ChangeDisplaySettings(NULL,0);					// If So Switch Back To The Desktop
		ShowCursor(TRUE);								// Show Mouse Pointer
	}

	if (hDC && !ReleaseDC(hWnd,hDC))					// Are We Able To Release The DC
	{
		MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hDC=NULL;										// Set DC To NULL
	}

	if (hWnd && !DestroyWindow(hWnd))					// Are We Able To Destroy The Window?
	{
		MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hWnd=NULL;										// Set hWnd To NULL
	}

	if (!UnregisterClass("Direct3D",hInstance))			// Are We Able To Unregister Class
	{
		MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
		hInstance=NULL;									// Set hInstance To NULL
	}
}


BOOL CreateD3DWindow(char* title, int width, int height, bool fullscreenflag)
{
	WNDCLASS	wc;
	DWORD		dwExStyle;				// Window Extended Style
	DWORD		dwStyle;				// Window Style
	RECT		WindowRect;				// Grabs Rectangle Upper Left / Lower Right Values
	WindowRect.left=(long)0;			// Set Left Value To 0
	WindowRect.right=(long)width;		// Set Right Value To Requested Width
	WindowRect.top=(long)0;				// Set Top Value To 0
	WindowRect.bottom=(long)height;		// Set Bottom Value To Requested Height

	fullscreen=fullscreenflag;			// Set The Global Fullscreen Flag

	hInstance			= GetModuleHandle(NULL);				// Grab An Instance For Our Window
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;	// Redraw On Size, And Own DC For Window.
	wc.lpfnWndProc		= (WNDPROC) WndProc;					// WndProc Handles Messages
	wc.cbClsExtra		= 0;									// No Extra Window Data
	wc.cbWndExtra		= 0;									// No Extra Window Data
	wc.hInstance		= hInstance;							// Set The Instance
	wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);			// Load The Default Icon
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Load The Arrow Pointer
	wc.hbrBackground	= NULL;									// No Background Required For D3D
	wc.lpszMenuName		= NULL;									// We Don't Want A Menu
	wc.lpszClassName	= "Direct3D";							// Set The Class Name


	if (!RegisterClass(&wc))									// Attempt To Register The Window Class
	{
		MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;											// Return FALSE
	}

	if (fullscreen)												// Fullscreen Mode?
	{
		dwExStyle=WS_EX_APPWINDOW;								// Window Extended Style
		dwStyle=WS_POPUP;										// Windows Style
		ShowCursor(FALSE);										// Hide Mouse Pointer
	}
	else
	{
		dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;			// Window Extended Style
		dwStyle=WS_OVERLAPPEDWINDOW;							// Windows Style
	}


	AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);	// Adjust Window To True Requested Size


	// Create The Window
	if (!(hWnd=CreateWindowEx(	dwExStyle,							// Extended Style For The Window
								"Direct3D",							// Class Name
								title,								// Window Title
								dwStyle |							// Defined Window Style
								WS_CLIPSIBLINGS |					// Required Window Style
								WS_CLIPCHILDREN,					// Required Window Style
								0, 0,								// Window Position
								WindowRect.right-WindowRect.left,	// Calculate Window Width
								WindowRect.bottom-WindowRect.top,	// Calculate Window Height
								NULL,								// No Parent Window
								NULL,								// No Menu
								hInstance,							// Instance
								NULL)))								// Dont Pass Anything To WM_CREATE
	{
		KillD3DWindow();							// Reset The Display
		MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;								// Return FALSE
	}


	if (!(hDC=GetDC(hWnd)))							// Did We Get A Device Context?
	{
		KillD3DWindow();								// Reset The Display
		MessageBox(NULL,"Can't Create A Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;								// Return FALSE
	}


	pD3D = Direct3DCreate9( D3D_SDK_VERSION );		// Check for correct DirectX 3D version
	if ( pD3D == NULL )
	{
		KillD3DWindow();							// Reset The Display
		MessageBox(NULL,"Can't find D3D SDK Version 9.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;								// Return FALSE
	}


	D3DPRESENT_PARAMETERS d3dpp=					// d3dpp Tells Windows How We Want Things To Be
	{
		width,										// Back Buffer Width
		height,										// Back Buffer Height
		D3DFMT_R5G6B5,								// Back Buffer Format (Color Depth)
		1,											// Back Buffer Count (Double Buffer)
		D3DMULTISAMPLE_NONE,						// Multi Sample Type
		0,											// Multi Sample Quality
		D3DSWAPEFFECT_DISCARD,						// Swap Effect (Fast)
		hWnd,										// The Window Handle
		!fullscreen,								// Windowed or Fullscreen
		TRUE,										// Enable Auto Depth Stencil  
		D3DFMT_D16,									// 16Bit Z-Buffer (Depth Buffer)
		0,											// No Flags
		D3DPRESENT_RATE_DEFAULT,					// Default Refresh Rate
		D3DPRESENT_INTERVAL_DEFAULT					// Default Presentation Interval (vertical sync)
	};


	// Check The Wanted Surface Format.
	if ( FAILED( pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
									      d3dpp.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
									      D3DRTYPE_SURFACE, d3dpp.AutoDepthStencilFormat ) ) )
	{
		KillD3DWindow();							// Reset The Display
		MessageBox(NULL,"Can't Find Surface Format.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;								// Return FALSE
	}


	// Create The DirectX 3D Device 
	if(FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
					 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pD3DDevice ) ) )
	{
		KillD3DWindow();								// Reset The Display
		MessageBox(NULL,"Can't Create DirectX 3D Device.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;
	}


	ShowWindow(hWnd,SW_SHOW);						// Show The Window
	SetForegroundWindow(hWnd);						// Slightly Higher Priority
	SetFocus(hWnd);									// Sets Keyboard Focus To The Window
	ReSizeD3DScene(width, height);					// Set Up Our Perspective D3D Screen


	if (!InitD3D())									// Initialize Our Newly Created D3D Window
	{
		KillD3DWindow();								// Reset The Display
		MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return FALSE;								// Return FALSE
	}

	return TRUE;
}

LRESULT CALLBACK WndProc(	HWND	hWnd, 
							UINT	uMsg, 
							WPARAM	wParam, 
							LPARAM	lParam )
{
    switch( uMsg )
	{
		case WM_ACTIVATE:							// Watch For Window Activate Message
		{
			if (!HIWORD(wParam))					// Check Minimization State
			{
				active=TRUE;						// Program Is Active
			}
			else
			{
				active=FALSE;						// Program Is No Longer Active
			}

			return 0;								// Return To The Message Loop
		}

		case WM_SYSCOMMAND:							// Intercept System Commands
		{
			switch (wParam)							// Check System Calls
			{
				case SC_SCREENSAVE:					// Screensaver Trying To Start?
				case SC_MONITORPOWER:				// Monitor Trying To Enter Powersave?
				return 0;							// Prevent From Happening
			}
			break;									// Exit
		}

		case WM_CLOSE:								// Did We Receive A Close Message?
		{
			PostQuitMessage(0);						// Send A Quit Message
			return 0;								// Jump Back
		}

		case WM_KEYDOWN:							// Is A Key Being Held Down?
		{
			keys[wParam] = TRUE;					// If So, Mark It As TRUE
			return 0;								// Jump Back
		}

		case WM_KEYUP:								// Has A Key Been Released?
		{
			keys[wParam] = FALSE;					// If So, Mark It As FALSE
			return 0;								// Jump Back
		}

		case WM_SIZE:								// Resize The Direct3D Window
		{
			if(!fullscreen)
				ReSizeD3DScene(LOWORD(lParam), HIWORD(lParam));  // LoWord=Width, HiWord=Height
			return 0;								// Jump Back
		}
	}

	// Pass All Unhandled Messages To DefWindowProc
	return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

int WINAPI WinMain( HINSTANCE	hInstance,
                    HINSTANCE	hPrevInstance,
                    LPSTR		lpCmdLine,
                    int			nCmdShow )
{

	MSG     msg;
	BOOL	done=FALSE;								// Bool Variable To Exit Loop

	// Ask The User Which Screen Mode They Prefer
	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;							// Windowed Mode
	}

	// Create Our DirectX 3D Window
	if (!CreateD3DWindow("APRON TUTORIALS",640,480,fullscreen))
	{
		return 0;									// Quit If Window Was Not Created
	}
  

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=TRUE;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		{
			// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawD3DScene()
			if ((active && !DrawD3DScene()) || keys[VK_ESCAPE])	// Active?  Was There A Quit Received?
			{
				done=TRUE;							// ESC or DrawD3DScene Signalled A Quit
			}

			if (keys[VK_F1])						// Is F1 Being Pressed?
			{
				keys[VK_F1]=FALSE;					// If So Make Key FALSE
				KillD3DWindow();					// Kill Our Current Window
				fullscreen=!fullscreen;				// Toggle Fullscreen / Windowed Mode
				// Recreate Our DirectX 3D Window
				if (!CreateD3DWindow("APRON TUTORIALS",640,480,fullscreen))
				{
					return 0;						// Quit If Window Was Not Created
				}
			}
		}
	}

	// Shutdown
	KillD3DWindow();
	return (msg.wParam);							// Exit The Program
}

Here is the shader I am using which was exported from the RenderMonkey Shadow example
//**************************************************************//
//  Effect File exported by RenderMonkey 1.6
//
//  - Although many improvements were made to RenderMonkey FX  
//    file export, there are still situations that may cause   
//    compilation problems once the file is exported, such as  
//    occasional naming conflicts for methods, since FX format 
//    does not support any notions of name spaces. You need to 
//    try to create workspaces in such a way as to minimize    
//    potential naming conflicts on export.                    
//    
//  - Note that to minimize resulting name collisions in the FX 
//    file, RenderMonkey will mangle names for passes, shaders  
//    and function names as necessary to reduce name conflicts. 
//**************************************************************//

//--------------------------------------------------------------//
// Shadow Effects
//--------------------------------------------------------------//
//--------------------------------------------------------------//
// SoftShadows
//--------------------------------------------------------------//
//--------------------------------------------------------------//
// Object
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Object_Sphere : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\Sphere.3ds";

float4x4 view_proj_matrix : ViewProjection;
float4 lightPos
<
   string UIName = "lightPos";
   string UIWidget = "Direction";
   bool UIVisible =  true;
   float4 UIMin = float4( -400.00, -400.00, -400.00, -400.00 );
   float4 UIMax = float4( 400.00, 400.00, 400.00, 400.00 );
   bool Normalize =  false;
> = float4( -62.00, 104.00, 60.00, 0.00 );
float4 view_position : ViewPosition;
struct VS_OUTPUT {
   float4 Pos:      POSITION;
   float3 normal:   TEXCOORD0;
   float3 lightVec: TEXCOORD1;
   float3 viewVec:  TEXCOORD2;
};

VS_OUTPUT Shadow_Effects_SoftShadows_Object_Vertex_Shader_main(float4 Pos: POSITION, float3 normal: NORMAL){
   VS_OUTPUT Out;

   Out.Pos = mul(view_proj_matrix, Pos);
   // World-space lighting
   Out.normal = normal;
   Out.lightVec = lightPos - Pos.xyz;
   Out.viewVec = view_position - Pos.xyz;

   return Out;
}





float4 modelColor
<
   string UIName = "modelColor";
   string UIWidget = "Color";
   bool UIVisible =  true;
> = float4( 0.36, 0.45, 1.00, 1.00 );
float4 Shadow_Effects_SoftShadows_Object_Pixel_Shader_main(float3 normal: TEXCOORD0, float3 lightVec: TEXCOORD1, float3 viewVec: TEXCOORD2) : COLOR {
   normal = normalize(normal);
   lightVec = normalize(lightVec);
   viewVec = normalize(viewVec);

   // Simple standard lighting
   float diffuse = 0.5 + 0.5 * dot(lightVec, normal);
   float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16);

   return diffuse * modelColor + 0.5 * specular;
}




//--------------------------------------------------------------//
// Light
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Light_Sphere : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\Sphere.3ds";

float4x4 Shadow_Effects_SoftShadows_Light_Vertex_Shader_view_proj_matrix : ViewProjection;
float4 Shadow_Effects_SoftShadows_Light_Vertex_Shader_lightPos
<
   string UIName = "Shadow_Effects_SoftShadows_Light_Vertex_Shader_lightPos";
   string UIWidget = "Direction";
   bool UIVisible =  true;
   float4 UIMin = float4( -400.00, -400.00, -400.00, -400.00 );
   float4 UIMax = float4( 400.00, 400.00, 400.00, 400.00 );
   bool Normalize =  false;
> = float4( -62.00, 104.00, 60.00, 0.00 );
struct Shadow_Effects_SoftShadows_Light_Vertex_Shader_VS_OUTPUT {
   float4 Pos: POSITION;
};

Shadow_Effects_SoftShadows_Light_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Light_Vertex_Shader_main(float4 Pos: POSITION){
   Shadow_Effects_SoftShadows_Light_Vertex_Shader_VS_OUTPUT Out;

   // Compensate for model not being a
   // perfect sphere around origin
   Pos.xyz = 10 * normalize(Pos.xyz);
   // Get the light in place
   Pos.xyz += Shadow_Effects_SoftShadows_Light_Vertex_Shader_lightPos;

   Out.Pos = mul(Shadow_Effects_SoftShadows_Light_Vertex_Shader_view_proj_matrix, Pos);

   return Out;
}






float4 Shadow_Effects_SoftShadows_Light_Pixel_Shader_main() : COLOR {
   return 1;
}


//--------------------------------------------------------------//
// Depth
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Depth_Sphere : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\Sphere.3ds";

texture Depth_Tex : RenderColorTarget
<
   float2 RenderTargetDimensions = {512,512};
   string Format="D3DFMT_A8R8G8B8";
   float  ClearDepth=1.000000;
   int    ClearColor=0;
>;
float4x4 Shadow_Effects_SoftShadows_Depth_Vertex_Shader_view_proj_matrix;
float planeZ
<
   string UIName = "planeZ";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = -100.00;
   float UIMax = 0.00;
> = float( -59.00 );
float4 Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos
<
   string UIName = "Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos";
   string UIWidget = "Direction";
   bool UIVisible =  true;
   float4 UIMin = float4( -400.00, -400.00, -400.00, -400.00 );
   float4 UIMax = float4( 400.00, 400.00, 400.00, 400.00 );
   bool Normalize =  false;
> = float4( -62.00, 104.00, 60.00, 0.00 );
float planeSize
<
   string UIName = "planeSize";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 1000.00;
> = float( 500.00 );
struct Shadow_Effects_SoftShadows_Depth_Vertex_Shader_VS_OUTPUT {
   float4 Pos:  POSITION;
   float3 lVec: TEXCOORD0;
   float3 sVec: TEXCOORD1;
};

Shadow_Effects_SoftShadows_Depth_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Depth_Vertex_Shader_main(float4 Pos: POSITION, float3 normal: NORMAL){
   Shadow_Effects_SoftShadows_Depth_Vertex_Shader_VS_OUTPUT Out;

   // The z + planeZ = 0 plane
   float4 plane = float4(0, 0, 1, -planeZ);

   // We create a matrix that projects the model down into
   // the plane. This is a task that's better done on the
   // CPU and just passed to the vertex shader since it's
   // constant for the whole model. However,in RenderMonkey
   // we don't have that choice and will have to create it
   // in the vertex shader instead.
   float4x4 shadowMatrix;

   shadowMatrix[0] = -Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos.x * plane;
   shadowMatrix[1] = -Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos.y * plane;
   shadowMatrix[2] = -Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos.z * plane;
   shadowMatrix[3] = -plane;

   float dist = dot(Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos, plane.xyz) - planeZ;

   shadowMatrix[0].x += dist;
   shadowMatrix[1].y += dist;
   shadowMatrix[2].z += dist;
   shadowMatrix[3].w += dist;

   // Project the vertex down in the plane
   float4 sPos = mul(shadowMatrix, Pos);
   // Map the plane onto the rendertarget. The rendertarget
   // will cover exactly the quad we put shadows on.
   Out.Pos = float4(planeZ * sPos.xy / (planeSize * sPos.z), 0, 1);
   // How blurry the shadows are supposed to be is determined
   // by how far the vertex and the shadow is from the light.
   Out.lVec = Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos - Pos.xyz;
   // sPos.w will in general not be 1, so we'll have
   // to do the perspective division
   Out.sVec = Shadow_Effects_SoftShadows_Depth_Vertex_Shader_lightPos - sPos.xyz / sPos.w;

   return Out;
}


float4 Shadow_Effects_SoftShadows_Depth_Pixel_Shader_main(float3 lVec: TEXCOORD0, float3 sVec: TEXCOORD1) : COLOR {
   float lLen = length(lVec);
   float sLen = length(sVec);

   // Blurriness factor
   return 1 - lLen / sLen;
}






//--------------------------------------------------------------//
// Dilate
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Dilate_Sphere : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\Sphere.3ds";

texture Dilate_Tex : RenderColorTarget
<
   float2 RenderTargetDimensions = {512,512};
   string Format="D3DFMT_A8R8G8B8";
   float  ClearDepth=1.000000;
   int    ClearColor=0;
>;
float4x4 Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_view_proj_matrix;
struct Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_VS_OUTPUT {
   float4 Pos: POSITION;
   float2 texCoord: TEXCOORD;
};

Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_main(float4 Pos: POSITION){
   Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_VS_OUTPUT Out;
   
   // Clean up inaccuracies
   Pos.xy = sign(Pos.xy);

   Out.Pos = float4(Pos.xy, 0, 1);
   // Image-space
   Out.texCoord.x = 0.5 * (1 + Pos.x);
   Out.texCoord.y = 0.5 * (1 - Pos.y);

   return Out;
}



float dilateSize
<
   string UIName = "dilateSize";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 0.10;
> = float( 0.02 );
sampler Depth = sampler_state
{
   Texture = (Depth_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
// Simple dilate filter. We need to dilate the blurriness
// render target since the blur needs to spread outside the
// source image. If we didn't dilate, the shadow would get
// end with a sharp edge after a partial blur.

const float2 samples[12] = {
   -0.326212, -0.405805,
   -0.840144, -0.073580,
   -0.695914,  0.457137,
   -0.203345,  0.620716,
    0.962340, -0.194983,
    0.473434, -0.480026,
    0.519456,  0.767022,
    0.185461, -0.893124,
    0.507431,  0.064425,
    0.896420,  0.412458,
   -0.321940, -0.932615,
   -0.791559, -0.597705,
};

float4 Shadow_Effects_SoftShadows_Dilate_Pixel_Shader_main(float2 texCoord: TEXCOORD) : COLOR {
   float4 dilate = tex2D(Depth, texCoord);

   for (int i = 0; i < 12; i++){
      dilate = max(dilate, tex2D(Depth, texCoord + dilateSize * samples[i]));
   }
   return dilate;
}




//--------------------------------------------------------------//
// Shadow
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Shadow_Sphere : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\Sphere.3ds";

texture Shadow_Tex : RenderColorTarget
<
   float2 RenderTargetDimensions = {1024,1024};
   string Format="D3DFMT_A8R8G8B8";
   float  ClearDepth=1.000000;
   int    ClearColor=0;
>;
float4x4 Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_view_proj_matrix;
float Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ
<
   string UIName = "Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = -100.00;
   float UIMax = 0.00;
> = float( -59.00 );
float4 Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos
<
   string UIName = "Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos";
   string UIWidget = "Direction";
   bool UIVisible =  true;
   float4 UIMin = float4( -400.00, -400.00, -400.00, -400.00 );
   float4 UIMax = float4( 400.00, 400.00, 400.00, 400.00 );
   bool Normalize =  false;
> = float4( -62.00, 104.00, 60.00, 0.00 );
float Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeSize
<
   string UIName = "Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeSize";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 1000.00;
> = float( 500.00 );
struct Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_VS_OUTPUT {
   float4 Pos: POSITION;
};

Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_main(float4 Pos: POSITION){
   Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_VS_OUTPUT Out;

   // The z + Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ = 0 plane
   float4 plane = float4(0, 0, 1, -Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ);

   // We create a matrix that projects the model down into
   // the plane. This is a task that's better done on the
   // CPU and just passed to the vertex shader since it's
   // constant for the whole model. However,in RenderMonkey
   // we don't have that choice and will have to create it
   // in the vertex shader instead.
   float4x4 shadowMatrix;

   shadowMatrix[0] = -Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos.x * plane;
   shadowMatrix[1] = -Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos.y * plane;
   shadowMatrix[2] = -Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos.z * plane;
   shadowMatrix[3] = -plane;

   float dist = dot(Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_lightPos, plane.xyz) - Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ;

   shadowMatrix[0].x += dist;
   shadowMatrix[1].y += dist;
   shadowMatrix[2].z += dist;
   shadowMatrix[3].w += dist;

   // Project the vertex down in the plane
   float4 sPos = mul(shadowMatrix, Pos);
   // Map the plane onto the rendertarget. The rendertarget
   // will cover exactly the quad we put shadows on.
   Out.Pos = float4(Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeZ * sPos.xy / (Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_planeSize * sPos.z), 0, 1);

   return Out;
}




float4 Shadow_Effects_SoftShadows_Shadow_Pixel_Shader_main() : COLOR {
   return 1;
}


//--------------------------------------------------------------//
// Blur0
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Blur0_ScreenAlignedQuad : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\ScreenAlignedQuad.3ds";

texture Blur0_Tex : RenderColorTarget
<
   float2 RenderTargetDimensions = {512,512};
   string Format="D3DFMT_A8R8G8B8";
   float  ClearDepth=1.000000;
   int    ClearColor=0;
>;
float4x4 Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_view_proj_matrix;
struct Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_VS_OUTPUT {
   float4 Pos: POSITION;
   float2 texCoord: TEXCOORD;
};

Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_main(float4 Pos: POSITION){
   Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_VS_OUTPUT Out;
   
   // Clean up inaccuracies
   Pos.xy = sign(Pos.xy);
   Out.Pos = float4(Pos.xy, 0, 1);
   // Image-space
   Out.texCoord.x = 0.5 * (1 + Pos.x);
   Out.texCoord.y = 0.5 * (1 - Pos.y);

   return Out;
}



float sampleDist0
<
   string UIName = "sampleDist0";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 0.20;
> = float( 0.42 );
float depthBlur
<
   string UIName = "depthBlur";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 15.00;
> = float( 6.45 );
sampler Dilate = sampler_state
{
   Texture = (Dilate_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
sampler Shadow = sampler_state
{
   Texture = (Shadow_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
const float2 Shadow_Effects_SoftShadows_Blur0_Pixel_Shader_samples[12] = {
   -0.326212, -0.405805,
   -0.840144, -0.073580,
   -0.695914,  0.457137,
   -0.203345,  0.620716,
    0.962340, -0.194983,
    0.473434, -0.480026,
    0.519456,  0.767022,
    0.185461, -0.893124,
    0.507431,  0.064425,
    0.896420,  0.412458,
   -0.321940, -0.932615,
   -0.791559, -0.597705,
};

float4 Shadow_Effects_SoftShadows_Blur0_Pixel_Shader_main(float2 texCoord: TEXCOORD) : COLOR {
   float4 sum = tex2D(Shadow, texCoord);
   // Blur filter kernel size
   float x = tex2D(Dilate, texCoord).r;
   float size = sampleDist0 * pow(x, depthBlur);

   for (int i = 0; i < 12; i++){
      sum += tex2D(Shadow, texCoord + size * Shadow_Effects_SoftShadows_Blur0_Pixel_Shader_samples[i]);
   }
   return sum / 13;
}


//--------------------------------------------------------------//
// Blur1
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Blur1_ScreenAlignedQuad : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\ScreenAlignedQuad.3ds";

texture Blur1_Tex : RenderColorTarget
<
   float2 RenderTargetDimensions = {512,512};
   string Format="D3DFMT_A8R8G8B8";
   float  ClearDepth=1.000000;
   int    ClearColor=0;
>;
float4x4 Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_view_proj_matrix;
struct Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_VS_OUTPUT {
   float4 Pos: POSITION;
   float2 texCoord: TEXCOORD;
};

Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_main(float4 Pos: POSITION){
   Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_VS_OUTPUT Out;
   
   // Clean up inaccuracies
   Pos.xy = sign(Pos.xy);
   Out.Pos = float4(Pos.xy, 0, 1);
   // Image-space
   Out.texCoord.x = 0.5 * (1 + Pos.x);
   Out.texCoord.y = 0.5 * (1 - Pos.y);

   return Out;
}



float sampleDist1
<
   string UIName = "sampleDist1";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 0.20;
> = float( 0.16 );
float Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_depthBlur
<
   string UIName = "Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_depthBlur";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 15.00;
> = float( 6.45 );
sampler Blur0 = sampler_state
{
   Texture = (Blur0_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
sampler Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_Dilate = sampler_state
{
   Texture = (Dilate_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
const float2 Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_samples[12] = {
   -0.326212, -0.405805,
   -0.840144, -0.073580,
   -0.695914,  0.457137,
   -0.203345,  0.620716,
    0.962340, -0.194983,
    0.473434, -0.480026,
    0.519456,  0.767022,
    0.185461, -0.893124,
    0.507431,  0.064425,
    0.896420,  0.412458,
   -0.321940, -0.932615,
   -0.791559, -0.597705,
};

float4 Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_main(float2 texCoord: TEXCOORD) : COLOR {
   float4 sum = tex2D(Blur0, texCoord);
   // Blur filter kernel size
   float x = tex2D(Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_Dilate, texCoord).r;
   float size = sampleDist1 * pow(x, Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_depthBlur);

   for (int i = 0; i < 12; i++){
      sum += tex2D(Blur0, texCoord + size * Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_samples[i]);
   }
   return sum / 13;
}


//--------------------------------------------------------------//
// Plane
//--------------------------------------------------------------//
string Shadow_Effects_SoftShadows_Plane_ScreenAlignedQuad : ModelData = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Models\\ScreenAlignedQuad.3ds";

float4x4 Shadow_Effects_SoftShadows_Plane_Vertex_Shader_view_proj_matrix : ViewProjection;
float Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeZ
<
   string UIName = "Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeZ";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = -100.00;
   float UIMax = 0.00;
> = float( -59.00 );
float4 Shadow_Effects_SoftShadows_Plane_Vertex_Shader_lightPos
<
   string UIName = "Shadow_Effects_SoftShadows_Plane_Vertex_Shader_lightPos";
   string UIWidget = "Direction";
   bool UIVisible =  true;
   float4 UIMin = float4( -400.00, -400.00, -400.00, -400.00 );
   float4 UIMax = float4( 400.00, 400.00, 400.00, 400.00 );
   bool Normalize =  false;
> = float4( -62.00, 104.00, 60.00, 0.00 );
float4 Shadow_Effects_SoftShadows_Plane_Vertex_Shader_view_position : ViewPosition;
float Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeSize
<
   string UIName = "Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeSize";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 1000.00;
> = float( 500.00 );
struct Shadow_Effects_SoftShadows_Plane_Vertex_Shader_VS_OUTPUT {
   float4 Pos:      POSITION;
   float2 texCoord: TEXCOORD0;
   float3 normal:   TEXCOORD1;
   float3 lightVec: TEXCOORD2;
   float3 viewVec:  TEXCOORD3;
};

Shadow_Effects_SoftShadows_Plane_Vertex_Shader_VS_OUTPUT Shadow_Effects_SoftShadows_Plane_Vertex_Shader_main(float4 Pos: POSITION, float3 normal: NORMAL){
   Shadow_Effects_SoftShadows_Plane_Vertex_Shader_VS_OUTPUT Out;

   // Image-space
   Out.texCoord.x = 0.5 * (1 + Pos.x);
   Out.texCoord.y = 0.5 * (1 - Pos.y);

   // Put the plane into place
   Pos.xy *= Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeSize;
   Pos.z = Shadow_Effects_SoftShadows_Plane_Vertex_Shader_planeZ;

   Out.Pos = mul(Shadow_Effects_SoftShadows_Plane_Vertex_Shader_view_proj_matrix, Pos);
   // World-space lighting
   Out.normal = normal;
   Out.lightVec = Shadow_Effects_SoftShadows_Plane_Vertex_Shader_lightPos - Pos.xyz;
   Out.viewVec  = Shadow_Effects_SoftShadows_Plane_Vertex_Shader_view_position - Pos.xyz;

   return Out;
}
















float ambient
<
   string UIName = "ambient";
   string UIWidget = "Numeric";
   bool UIVisible =  true;
   float UIMin = 0.00;
   float UIMax = 1.00;
> = float( 0.30 );
sampler Blur1 = sampler_state
{
   Texture = (Blur1_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
texture Floor_Tex
<
   string ResourceName = "..\\..\\..\\..\\..\\..\\..\\Program Files\\AMD\\RenderMonkey 1.81\\Examples\\Media\\Textures\\Wood.dds";
>;
sampler Floor = sampler_state
{
   Texture = (Floor_Tex);
   ADDRESSU = CLAMP;
   ADDRESSV = CLAMP;
   MAGFILTER = LINEAR;
   MINFILTER = LINEAR;
   MIPFILTER = LINEAR;
};
float4 Shadow_Effects_SoftShadows_Plane_Pixel_Shader_main(float2 texCoord: TEXCOORD0, float3 normal: TEXCOORD1, float3 lightVec: TEXCOORD2, float3 viewVec: TEXCOORD3) : COLOR {
   normal   = normalize(normal);
   lightVec = normalize(lightVec);
   viewVec  = normalize(viewVec);

   float4 base = tex2D(Floor, texCoord);

   // The last blur gives us the shadow factor
   float shadow = 1 - tex2D(Blur1, texCoord).r;

   // Basic lighting
   float diffuse = 0.5 + 0.5 * dot(lightVec, normal);
   float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16);

   return (shadow * diffuse + ambient) * base + 0.4 * shadow * specular;
}























































//--------------------------------------------------------------//
// Technique Section for Shadow Effects
//--------------------------------------------------------------//
technique SoftShadows
{
   pass Object
   {
      ZWRITEENABLE = TRUE;
      CULLMODE = CCW;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Object_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Object_Pixel_Shader_main();
   }

   pass Light
   {
      CULLMODE = CCW;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Light_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Light_Pixel_Shader_main();
   }

   pass Depth
   <
      string Script = "RenderColorTarget0 = Depth_Tex;"
                      "ClearColor = (0, 0, 0, 0);"
                      "ClearDepth = 1.000000;";
   >
   {
      ZWRITEENABLE = FALSE;
      SRCBLEND = ONE;
      DESTBLEND = ONE;
      CULLMODE = NONE;
      ALPHABLENDENABLE = TRUE;
      BLENDOP = MAX;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Depth_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Depth_Pixel_Shader_main();
   }

   pass Dilate
   <
      string Script = "RenderColorTarget0 = Dilate_Tex;"
                      "ClearColor = (0, 0, 0, 0);"
                      "ClearDepth = 1.000000;";
   >
   {
      ZWRITEENABLE = FALSE;
      CULLMODE = NONE;
      ALPHABLENDENABLE = FALSE;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Dilate_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Dilate_Pixel_Shader_main();
   }

   pass Shadow
   <
      string Script = "RenderColorTarget0 = Shadow_Tex;"
                      "ClearColor = (0, 0, 0, 0);"
                      "ClearDepth = 1.000000;";
   >
   {
      ZWRITEENABLE = FALSE;
      CULLMODE = NONE;
      ALPHABLENDENABLE = FALSE;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Shadow_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Shadow_Pixel_Shader_main();
   }

   pass Blur0
   <
      string Script = "RenderColorTarget0 = Blur0_Tex;"
                      "ClearColor = (0, 0, 0, 0);"
                      "ClearDepth = 1.000000;";
   >
   {
      CULLMODE = NONE;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Blur0_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Blur0_Pixel_Shader_main();
   }

   pass Blur1
   <
      string Script = "RenderColorTarget0 = Blur1_Tex;"
                      "ClearColor = (0, 0, 0, 0);"
                      "ClearDepth = 1.000000;";
   >
   {
      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Blur1_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Blur1_Pixel_Shader_main();
   }

   pass Plane
   {
      ZWRITEENABLE = TRUE;
      CULLMODE = NONE;
      ALPHABLENDENABLE = FALSE;

      VertexShader = compile vs_1_1 Shadow_Effects_SoftShadows_Plane_Vertex_Shader_main();
      PixelShader = compile ps_2_0 Shadow_Effects_SoftShadows_Plane_Pixel_Shader_main();
   }

}

Share this post


Link to post
Share on other sites

This topic is 3112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this