Wednesday, March 31, 2010
XNA-ShaderEffect-Shadow(Step.2)
Disable Diffuse light
DepthStencilFormat :DepthFormat.Depth24Stencil8;(According to Computer Hardware)
----------------------------------------------------------------------------------------------
GraphicsDevice.Clear(ClearOptions.Stencil, Color.Black, 0, 0);
GraphicsDevice.RenderState.StencilEnable = true;
GraphicsDevice.RenderState.ReferenceStencil = 0;
GraphicsDevice.RenderState.StencilFunction = CompareFunction.Equal;
GraphicsDevice.RenderState.StencilPass = StencilOperation.Increment;
GraphicsDevice.RenderState.AlphaBlendEnable = true;
GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
----------------------------------------------------------------------------------------------
Control ShadowEffect
Tuesday, March 30, 2010
XNA-ShaderNote
GlobleVaule
struct VertexShaderINPUT
{
float4 Postition : POSITION0; //Require
}
struct VertexShaderOUTPUT
{
float4 Postition : POSITION0; //Require
}
VertexShaderOUT VSBasic(VertexShaderINPUT input)
{
float4 WorldPostition= mul();
float4 ViewPosirion= mul();
return output;
}
float4 PixelShader() : COLOR0
{
return float4;
}
technique NAME
{
pass NAME2
{
compile Version;
}
}
----------------------------------------------------------------------------------------------
Shadow
FX:
1.Create PixelShader for technique
2.Define technique
C#:
1.Define Matrix for shadow
Matrix.CreateShdow(Light,Plane)
Draw Funtion()
1. Define Matrix[] for shadowBones And get Bones.Length
2. Bones[i]*shadow
3.Draw Model
4.Check RenderState
GraphicsDevice.Clear(ClearOptions.Stencil, Color.Black, 0, 0);
GraphicsDevice.RenderState.StencilEnable = true;
GraphicsDevice.RenderState.ReferenceStencil = 0;
GraphicsDevice.RenderState.StencilFunction = CompareFunction.Equal;
GraphicsDevice.RenderState.StencilPass = StencilOperation.Increment;
GraphicsDevice.RenderState.AlphaBlendEnable = true;
GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
struct VertexShaderINPUT
{
float4 Postition : POSITION0; //Require
}
struct VertexShaderOUTPUT
{
float4 Postition : POSITION0; //Require
}
VertexShaderOUT VSBasic(VertexShaderINPUT input)
{
float4 WorldPostition= mul();
float4 ViewPosirion= mul();
return output;
}
float4 PixelShader() : COLOR0
{
return float4;
}
technique NAME
{
pass NAME2
{
compile Version;
}
}
----------------------------------------------------------------------------------------------
Shadow
FX:
1.Create PixelShader for technique
2.Define technique
C#:
1.Define Matrix for shadow
Matrix.CreateShdow(Light,Plane)
Draw Funtion()
1. Define Matrix[] for shadowBones And get Bones.Length
2. Bones[i]*shadow
3.Draw Model
4.Check RenderState
GraphicsDevice.Clear(ClearOptions.Stencil, Color.Black, 0, 0);
GraphicsDevice.RenderState.StencilEnable = true;
GraphicsDevice.RenderState.ReferenceStencil = 0;
GraphicsDevice.RenderState.StencilFunction = CompareFunction.Equal;
GraphicsDevice.RenderState.StencilPass = StencilOperation.Increment;
GraphicsDevice.RenderState.AlphaBlendEnable = true;
GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
Monday, March 29, 2010
XNA-ShaderEffect-Shadow(Step.1)
Shadow
Matrix[] Shadow;
Matrix[] shadowBones = new Matrix[Bones.Length];
for()
{
shadowBones[i] = Bones[i] *shadow;
}
foreach()
{
draw View,Bone,Projection
}
------------------------------------------------------------------------
//GraphicsDevice.RenderState.FillMode = FillModel.Point;
//GraphicsDevice.RenderState.FillMode = FillModel.Solid;
Sunday, March 28, 2010
XNA-ShaderEffect(Step.2)
Normal Map with Diffuse Light
BlackLine: The Diffuse Light Direction (1,1,1) And (-1,-1,-1,-1)
float3 Data1: TEXCOORD1
Remove :
saturate(dot(input.Date1,normalize(lightDir1)));
Tuesday, March 23, 2010
Monday, March 22, 2010
Sunday, March 14, 2010
Thursday, March 11, 2010
DirectX-Note
Include Setting
Go to your project's properties | Configuration Properties | VC++ Directories.
Setting Include Directories :
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Include
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
Your project will know d3dx10.h and d3dx11.h
And Library
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
宣告
1.RegisterClass
2.Create Window
3.Show Window
WNDCLASSEX wc :This is a struct that contains the information for the window class.
ZeroMemory(&wc, sizeof(WNDCLASSEX)) : ZeroMemory is a function that initializes an entire block of memory to NULL.
wc.cbSize = sizeof(WNDCLASSEX): size up this structure and tell it what it's measurements are.
wc.style = CS_HREDRAW | CS_VREDRAW:There are plenty of values we can insert, but we will almost never use any of them in game programming.
wc.lpfnWndProc = WindowProc:This value tells the window class what function to use when it gets a message from Windows.
wc.hInstance = hInstance:Just put the value Windows handed to us in WinMain().
wc.hCursor = LoadCursor(NULL, IDC_ARROW):This member stores the default mouse image for the window class.
---------------------------------------------------------------------------------------------------
Window Size Versue Client Size
BOOL AdjustWindowRect(LPRECT lpRect,DWORD dwStyle,BOOL bMenu);
RECT wr = {0,0,windowWidth,windowHeight};
LPRECT lpRect: Send &wr.
WORD dwStyle: your windowstyle.
BOOL bMenu: not necessary always FALSE.
part of Code
It is adjust your image at right position while you change your window size.
Go to your project's properties | Configuration Properties | VC++ Directories.
Setting Include Directories :
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Include
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
Your project will know d3dx10.h and d3dx11.h
And Library
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
宣告
LRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
//----------RegisterClass
HWND hWnd;
WNDCLASSEX wc;
ZeroMemory(&wc,sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = "WindowClass1";
RegisterClassEx(&wc);
//-----------Create Window Application
hWnd = CreateWindowEx(NULL,"WindowClass1","WindowClass1",WS_OVERLAPPEDWINDOW,300,300,1280,720,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nShowCmd);
//---------- The Main Loop
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY :
{
PostQuitMessage(0);
return 0;
}break;
}
return DefWindowProc(hWnd,message,wParam,lParam);
}
1.RegisterClass
2.Create Window
3.Show Window
WNDCLASSEX wc :This is a struct that contains the information for the window class.
ZeroMemory(&wc, sizeof(WNDCLASSEX)) : ZeroMemory is a function that initializes an entire block of memory to NULL.
wc.cbSize = sizeof(WNDCLASSEX): size up this structure and tell it what it's measurements are.
wc.style = CS_HREDRAW | CS_VREDRAW:There are plenty of values we can insert, but we will almost never use any of them in game programming.
wc.lpfnWndProc = WindowProc:This value tells the window class what function to use when it gets a message from Windows.
wc.hInstance = hInstance:Just put the value Windows handed to us in WinMain().
wc.hCursor = LoadCursor(NULL, IDC_ARROW):This member stores the default mouse image for the window class.
---------------------------------------------------------------------------------------------------
Window Size Versue Client Size
BOOL AdjustWindowRect(LPRECT lpRect,DWORD dwStyle,BOOL bMenu);
RECT wr = {0,0,windowWidth,windowHeight};
LPRECT lpRect: Send &wr.
WORD dwStyle: your windowstyle.
BOOL bMenu: not necessary always FALSE.
part of Code
RECT wr = {0,0,500,400};
AdjustWindowRect(&wr,WS_OVERLAPPEDWINDOW,FALSE);
hWnd = CreateWindowEx(NULL,"WindowClass1","WindowClass1",WS_OVERLAPPEDWINDOW,300,300,wr.right-wr.left,wr.bottom-wr.top,NULL,NULL,hInstance,NULL);
It is adjust your image at right position while you change your window size.
Monday, March 8, 2010
Saturday, March 6, 2010
Friday, March 5, 2010
Monday, March 1, 2010
Subscribe to:
Posts (Atom)