• 大小: 2.95MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-21
  • 语言: 其他
  • 标签: DirShadowMap  

资源简介

DirectionalShadowMap

资源截图

代码片段和文件信息

#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“MyShader/ColorShader.fx“ L“MyShader/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“

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6228  2016-11-01 11:39  ModelClass.cpp

     文件       1802  2016-11-01 11:39  ModelClass.h

     文件       2381  2016-11-05 18:16  PointLightClass.cpp

     文件       1471  2016-11-05 19:18  PointLightClass.h

     文件       3896  2016-11-01 14:55  RenderModelToTexure.cpp

     文件        920  2016-11-01 14:38  RenderModelToTexure.h

     文件       5840  2016-09-30 23:41  SystemClass.cpp

     文件       1196  2016-09-27 11:56  SystemClass.h

     文件        496  2016-10-01 17:12  TexClass.cpp

     文件        446  2016-10-01 17:11  TexClass.h

     文件        466  2016-09-27 11:37  源.cpp

     文件       1957  2016-11-06 02:17  MyShader\ColorShader.fx

     文件        530  2016-10-31 20:13  MyShader\DepthShader.fx

     文件       3767  2016-11-05 19:00  MyShader\DrawShadowShader.fx

     文件    1048704  2012-03-25 12:22  Texture\ice.dds

     文件    4194432  2012-03-23 09:02  Texture\metal001.dds

     文件    1048704  2012-03-25 12:23  Texture\wall01.dds

     文件       1427  2016-10-10 01:05  Txt\cube.txt

     文件     105552  2016-11-01 01:01  Txt\plane01.txt

     文件    1093129  2016-11-01 00:55  Txt\sphere.txt

     文件       1999  2016-10-01 00:35  CameraClass.h

     文件       8742  2016-11-01 15:12  ColorShaderClass.cpp

     文件       2045  2016-11-01 15:12  ColorShaderClass.h

     文件      10987  2016-11-01 12:03  D3DClass.cpp

     文件       2128  2016-11-01 12:03  D3DClass.h

     文件       5917  2016-10-31 20:12  DepthShaderClass.cpp

     文件       1308  2016-10-31 20:07  DepthShaderClass.h

     文件       9954  2016-11-05 18:21  DrawShadowShaderClass.cpp

     文件       2295  2016-11-05 18:20  DrawShadowShaderClass.h

     文件      13954  2016-11-06 03:14  GraphicsClass.cpp

............此处省略10个文件信息

评论

共有 条评论

相关资源