資源簡介
ShadowMap_PCF

代碼片段和文件信息
#include“ColorShaderClass.h“
ColorShaderClass::ColorShaderClass()
{
?md3dVertexShader=NULL;
?md3dPixelShader=NULL;
?md3dInputLayout=NULL;
?mCBMatrixBuffer=NULL;
?mCBLightBuffer?=?NULL;
}
ColorShaderClass::ColorShaderClass(const?ColorShaderClass&)
{
}
ColorShaderClass::~ColorShaderClass()
{
}
bool?ColorShaderClass::Initialize(ID3D11Device*?d3dDevice?HWND?hwnd)
{
bool?result;
result?=?InitializeShader(d3dDevice?hwnd?L“Shader/ColorShader.fx“?L“Shader/ColorShader.fx“);
if?(!result)
return?false;
return?true;
}
void?ColorShaderClass::Shutdown()
{
ShutdownShader();
}
bool?ColorShaderClass::Render(ID3D11DeviceContext*?d3dDeviceContext?int?indexCount?CXMMATRIX?worldMatrix?CXMMATRIX?viewMatrix?CXMMATRIX?ProjMatrix??ID3D11ShaderResourceView*baseTexture?FXMVECTOR?DiffuseColor?FXMVECTOR?AmbientColor?FXMVECTOR?PointLightPos)
{
bool?result;
//設置Shader常量緩存和紋理資源
result?=?SetShaderParameter(d3dDeviceContext?worldMatrix?viewMatrix?ProjMatrix?baseTexture?DiffuseColorAmbientColorPointLightPos);
if?(!result)
return?false;
//設置VertexShader?PixelShader?InputLayout?SamplerState
RenderShader(d3dDeviceContext?indexCount);
return?true;
}
bool?ColorShaderClass::InitializeShader(ID3D11Device*?d3dDevice?HWND?hwnd?WCHAR*?VSFileName?WCHAR*?PSFileName)
{
HRESULT?result;
ID3D10Blob*?errorMessage;
ID3D10Blob*?VertexShaderBuffer;??
ID3D10Blob*?PixelShaderBuffer;
//第一初始化參數
errorMessage?=?NULL;
????VertexShaderBuffer=NULL;
PixelShaderBuffer=NULL;
//第二編譯VertexShader代碼并創建VertexShader
result?=?D3DX11CompileFromFile(VSFileName?NULL?NULL?“VS“?“vs_5_0“?D3DCOMPILE_ENABLE_STRICTNESS?0?NULL?&VertexShaderBuffer?&errorMessage?NULL);
if?(FAILED(result))
{
//存在錯誤信息
if?(errorMessage)
{
OutputShaderErrorMessage(errorMessage?hwnd?VSFileName);
}
//不存在錯誤信息也就是沒有找到Shader文件
else
{
MessageBox(hwnd?L“can?not?find?VS?file“?L“error“?MB_OK);
}
}
HR(d3dDevice->CreateVertexShader(VertexShaderBuffer->GetBufferPointer()VertexShaderBuffer->GetBufferSize()NULL&md3dVertexShader));
//第三編譯PixelShader并創建PixelShader
result?=?D3DX11CompileFromFile(PSFileName?NULL?NULL?“PS“?“ps_5_0“?D3DCOMPILE_ENABLE_STRICTNESS?0?NULL?&PixelShaderBuffer?&errorMessage?NULL);
if?(FAILED(result))
{
//存在錯誤信息
if?(errorMessage)
{
OutputShaderErrorMessage(errorMessage?hwnd?PSFileName);
}
//不存在錯誤信息也就是沒有找到Shader文件
else
{
MessageBox(hwnd?L“can?not?find?PS?file“?L“error“?MB_OK);
}
}
HR(d3dDevice->CreatePixelShader(PixelShaderBuffer->GetBufferPointer()?PixelShaderBuffer->GetBufferSize()?NULL?&md3dPixelShader));
//第四填充輸入布局形容結構體創建輸入布局
D3D11_INPUT_ELEMENT_DESC?VertexInputLayout[]?=
{
{?“POSITION“0DXGI_FORMAT_R32G32B32_FLOAT00D3D11_INPUT_PER_VERTEX_DATA0?}?//?96位即12個字節
{?“TEXCOORD“0DXGI_FORMAT_R32G32_FLOAT012D3D11_INPUT_PER_VERTEX_DATA0?}
{?“NORMAL“0DX
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????8738??2017-06-05?22:19??D3D11_ShadowMap_PCF\ColorShaderClass.cpp
?????文件???????2045??2016-11-01?15:12??D3D11_ShadowMap_PCF\ColorShaderClass.h
?????文件???????1269??2016-10-07?19:15??D3D11_ShadowMap_PCF\CPUClass.cpp
?????文件????????518??2016-10-07?19:46??D3D11_ShadowMap_PCF\CPUClass.h
?????文件??????14159??2017-06-04?21:01??D3D11_ShadowMap_PCF\D3DClass.cpp
?????文件???????2494??2017-06-04?21:01??D3D11_ShadowMap_PCF\D3DClass.h
?????文件???????5913??2017-06-04?20:22??D3D11_ShadowMap_PCF\DepthShaderClass.cpp
?????文件???????1308??2016-10-31?20:07??D3D11_ShadowMap_PCF\DepthShaderClass.h
?????文件??????11434??2017-06-05?22:28??D3D11_ShadowMap_PCF\DrawShadowShaderClass.cpp
?????文件???????2439??2017-06-05?22:28??D3D11_ShadowMap_PCF\DrawShadowShaderClass.h
?????文件???????5678??2016-12-20?23:59??D3D11_ShadowMap_PCF\FirstCameraClass.cpp
?????文件???????1620??2016-12-21?19:44??D3D11_ShadowMap_PCF\FirstCameraClass.h
?????文件???????1134??2016-10-05?21:26??D3D11_ShadowMap_PCF\FontClass.h
?????文件???????3652??2016-12-13?23:43??D3D11_ShadowMap_PCF\FontlClass.cpp
?????文件???????8692??2016-12-13?23:20??D3D11_ShadowMap_PCF\FontShaderClass.cpp
?????文件???????1556??2016-10-06?01:28??D3D11_ShadowMap_PCF\FontShaderClass.h
?????文件????????460??2016-10-07?17:08??D3D11_ShadowMap_PCF\FPSClass.cpp
?????文件????????390??2016-10-07?16:59??D3D11_ShadowMap_PCF\FPSClass.h
?????文件??????17762??2017-06-07?21:56??D3D11_ShadowMap_PCF\GraphicsClass.cpp
?????文件???????1662??2017-06-05?00:27??D3D11_ShadowMap_PCF\GraphicsClass.h
?????文件???????5028??2016-12-20?23:26??D3D11_ShadowMap_PCF\InputClass.cpp
?????文件???????1402??2016-12-20?23:26??D3D11_ShadowMap_PCF\InputClass.h
?????文件????????583??2016-10-03?02:10??D3D11_ShadowMap_PCF\LightClass.cpp
?????文件????????508??2016-10-03?02:09??D3D11_ShadowMap_PCF\LightClass.h
?????文件????????298??2016-12-14?00:15??D3D11_ShadowMap_PCF\Macro.h
?????文件???????1427??2016-10-10?01:05??D3D11_ShadowMap_PCF\MeshData\cube.txt
?????文件????????258??2016-10-31?00:50??D3D11_ShadowMap_PCF\MeshData\floor.txt
?????文件???????2946??2016-10-06?01:55??D3D11_ShadowMap_PCF\MeshData\font.txt
?????文件?????105552??2016-11-01?01:01??D3D11_ShadowMap_PCF\MeshData\plane01.txt
?????文件????1093129??2016-11-01?00:55??D3D11_ShadowMap_PCF\MeshData\sphere.txt
............此處省略34個文件信息
- 上一篇:D3D11_ShadowMap1
- 下一篇:有源濾波器精確設計手冊
評論
共有 條評論