2013-12-18 20:28:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
#include "Resources.h"
|
|
|
|
#include "..\Definitions\GraphicalDefinition.h"
|
2013-12-18 20:28:06 +01:00
|
|
|
|
|
|
|
typedef Oyster::Graphics::Core::PipelineManager::ShaderType ShaderType;
|
|
|
|
typedef Oyster::Graphics::Core::PipelineManager::Get GetShader;
|
|
|
|
typedef Oyster::Graphics::Core::PipelineManager Shader;
|
|
|
|
typedef Oyster::Graphics::Core::Buffer Buffer;
|
|
|
|
|
2014-02-07 11:09:59 +01:00
|
|
|
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\Passes\\";
|
2013-12-18 20:28:06 +01:00
|
|
|
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
|
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
const int KernelSize = 10;
|
2014-01-22 16:31:33 +01:00
|
|
|
const int SampleSpread = 16;
|
2014-01-08 07:01:59 +01:00
|
|
|
|
2014-02-11 13:29:19 +01:00
|
|
|
|
|
|
|
const int MAX_LETTER_COUNT=60;
|
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Graphics
|
|
|
|
{
|
|
|
|
namespace Render
|
|
|
|
{
|
2014-02-13 15:24:19 +01:00
|
|
|
#pragma region Declare Static
|
|
|
|
ID3D11RenderTargetView* Resources::GBufferRTV[Resources::GBufferSize] = {0};
|
2014-02-07 15:52:07 +01:00
|
|
|
ID3D11ShaderResourceView* Resources::GBufferSRV[Resources::GBufferSize] = {0};
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
ID3D11UnorderedAccessView* Resources::LBufferUAV[Resources::LBufferSize] = {0};
|
|
|
|
ID3D11ShaderResourceView* Resources::LBufferSRV[Resources::LBufferSize] = {0};
|
2014-02-07 13:46:55 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
ID3D11UnorderedAccessView* Resources::Blur::BufferUAV = {0};
|
|
|
|
ID3D11ShaderResourceView* Resources::Blur::BufferSRV = {0};
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
Shader::RenderPass Resources::Gather::AnimatedPass;
|
|
|
|
Shader::RenderPass Resources::Gather::InstancedPass;
|
2014-02-07 15:52:07 +01:00
|
|
|
Shader::RenderPass Resources::Light::Pass;
|
2014-02-07 16:51:35 +01:00
|
|
|
Shader::RenderPass Resources::Post::Pass;
|
2014-02-07 15:52:07 +01:00
|
|
|
Shader::RenderPass Resources::Gui::Pass;
|
2014-02-11 13:29:19 +01:00
|
|
|
Shader::RenderPass Resources::Gui::Text::Pass;
|
2014-02-07 15:52:07 +01:00
|
|
|
Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur
|
|
|
|
Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Buffer Resources::Gather::ModelData = Buffer();
|
|
|
|
Buffer Resources::Gather::AnimationData = Buffer();
|
2014-02-24 14:44:36 +01:00
|
|
|
Buffer Resources::Gather::InstancedData = Buffer();
|
2014-02-07 15:52:07 +01:00
|
|
|
Buffer Resources::Light::LightConstantsData = Buffer();
|
|
|
|
Buffer Resources::Gui::Data = Buffer();
|
2014-02-12 16:21:46 +01:00
|
|
|
Buffer Resources::Color = Buffer();
|
2014-02-11 13:29:19 +01:00
|
|
|
Buffer Resources::Gui::Text::Vertex = Buffer();
|
2014-02-10 01:03:10 +01:00
|
|
|
Buffer Resources::Post::Data = Buffer();
|
2014-02-13 15:24:19 +01:00
|
|
|
Buffer Resources::Blur::Data = Buffer();
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Buffer Resources::Light::PointLightsData = Buffer();
|
|
|
|
ID3D11ShaderResourceView* Resources::Light::PointLightView = NULL;
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
ID3D11ShaderResourceView* Resources::Light::SSAOKernel = NULL;
|
|
|
|
ID3D11ShaderResourceView* Resources::Light::SSAORandom = NULL;
|
2014-01-08 07:01:59 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
ID3D11RasterizerState* Resources::RenderStates::rs = NULL;
|
|
|
|
ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1];
|
|
|
|
ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL;
|
2014-02-11 13:29:19 +01:00
|
|
|
ID3D11BlendState* Resources::RenderStates::bs = NULL;
|
|
|
|
|
|
|
|
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
2014-02-18 09:32:10 +01:00
|
|
|
ID3D11DepthStencilView* Resources::Gui::depth = NULL;
|
2014-02-21 11:49:24 +01:00
|
|
|
|
|
|
|
std::map<Model::ModelInfo*, Resources::ModelDataWrapper*> Resources::RenderData = std::map<Model::ModelInfo*, Resources::ModelDataWrapper*>();
|
2014-02-13 15:24:19 +01:00
|
|
|
#pragma endregion
|
2014-02-05 16:54:57 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
|
|
|
|
Core::Init::State Resources::InitShaders()
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-02-07 11:09:59 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
std::wstring path = PathToHLSL+L"Gather\\";
|
2013-12-18 20:28:06 +01:00
|
|
|
std::wstring end = L".hlsl";
|
|
|
|
#else
|
|
|
|
std::wstring path = PathToCSO;
|
|
|
|
std::wstring end = L".cso";
|
|
|
|
#endif
|
|
|
|
//Load Shaders
|
2014-02-24 14:44:36 +01:00
|
|
|
Core::PipelineManager::Init(path + L"GatherAnimPixel" + end, ShaderType::Pixel, L"AGather");
|
|
|
|
Core::PipelineManager::Init(path + L"GatherAnimVertex" + end, ShaderType::Vertex, L"AGather");
|
|
|
|
|
|
|
|
|
|
|
|
Core::PipelineManager::Init(path + L"GatherInstPixel" + end, ShaderType::Pixel, L"IGather");
|
|
|
|
Core::PipelineManager::Init(path + L"GatherInstVertex" + end, ShaderType::Vertex, L"IGather");
|
2014-02-07 11:09:59 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
path = PathToHLSL+L"Light\\";
|
|
|
|
#endif
|
2013-12-18 20:28:06 +01:00
|
|
|
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
|
2014-02-07 11:09:59 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
path = PathToHLSL+L"Post\\";
|
|
|
|
#endif
|
|
|
|
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
|
2014-02-07 15:52:07 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
path = PathToHLSL+L"Blur\\";
|
|
|
|
#endif
|
2014-02-07 13:46:55 +01:00
|
|
|
Core::PipelineManager::Init(path + L"BlurHor" + end, ShaderType::Compute, L"BlurHor");
|
|
|
|
Core::PipelineManager::Init(path + L"BlurVert" + end, ShaderType::Compute, L"BlurVert");
|
2014-02-07 11:09:59 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
path = PathToHLSL+L"2D\\";
|
|
|
|
#endif
|
|
|
|
Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D");
|
|
|
|
Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D");
|
|
|
|
Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D");
|
2014-02-11 13:29:19 +01:00
|
|
|
#ifdef _DEBUG
|
|
|
|
path = PathToHLSL+L"2D\\Text\\";
|
|
|
|
#endif
|
|
|
|
Core::PipelineManager::Init(path + L"2DTextVertex" + end,ShaderType::Vertex, L"2DText");
|
|
|
|
Core::PipelineManager::Init(path + L"2DTextGeometry" + end,ShaderType::Geometry, L"2DText");
|
2014-02-07 11:09:59 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
return Core::Init::State::Success;
|
|
|
|
}
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::Init::State Resources::InitBuffers()
|
2014-01-08 07:01:59 +01:00
|
|
|
{
|
2013-12-18 20:28:06 +01:00
|
|
|
//Create Buffers
|
|
|
|
Buffer::BUFFER_INIT_DESC desc;
|
2014-01-08 07:01:59 +01:00
|
|
|
desc.ElementSize = sizeof(Definitions::PerModel);
|
2013-12-18 20:28:06 +01:00
|
|
|
desc.NumElements = 1;
|
|
|
|
desc.InitData = NULL;
|
|
|
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
|
|
|
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Gather::ModelData.Init(desc);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-01-27 14:24:13 +01:00
|
|
|
desc.NumElements = 1;
|
|
|
|
desc.ElementSize = sizeof(Definitions::AnimationData);
|
2014-02-07 15:52:07 +01:00
|
|
|
Gather::AnimationData.Init(desc);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-12 09:24:37 +01:00
|
|
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS;
|
2014-02-20 12:07:53 +01:00
|
|
|
desc.ElementSize = sizeof(Definitions::TintData);
|
2014-02-12 16:21:46 +01:00
|
|
|
Color.Init(desc);
|
2014-02-12 09:24:37 +01:00
|
|
|
|
2014-02-07 11:09:59 +01:00
|
|
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
|
|
|
|
desc.NumElements = 1;
|
|
|
|
desc.ElementSize = sizeof(Definitions::GuiData);
|
2014-02-07 16:51:35 +01:00
|
|
|
Gui::Data.Init(desc);
|
2014-02-07 11:09:59 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_CS;
|
2014-02-10 01:03:10 +01:00
|
|
|
desc.ElementSize = sizeof(Definitions::PostData);
|
|
|
|
Post::Data.Init(desc);
|
|
|
|
|
|
|
|
desc.ElementSize = sizeof(Definitions::LightConstants);
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::LightConstantsData.Init(desc);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-13 15:24:19 +01:00
|
|
|
desc.ElementSize = sizeof(Definitions::BlurrData);
|
|
|
|
Blur::Data.Init(desc);
|
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
desc.ElementSize = sizeof(Definitions::Pointlight);
|
|
|
|
desc.NumElements = MaxLightSize;
|
|
|
|
desc.Type = Buffer::STRUCTURED_BUFFER;
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::PointLightsData.Init(desc);
|
2014-02-11 13:29:19 +01:00
|
|
|
|
|
|
|
desc.Type = Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
|
|
|
desc.ElementSize = sizeof(Definitions::Text2D);
|
|
|
|
desc.NumElements = MAX_LETTER_COUNT;
|
|
|
|
Gui::Text::Vertex.Init(desc);
|
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
return Core::Init::Success;
|
|
|
|
}
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::Init::State Resources::InitRenderStates()
|
|
|
|
{
|
2014-01-08 07:01:59 +01:00
|
|
|
////Create States
|
2013-12-18 20:28:06 +01:00
|
|
|
D3D11_RASTERIZER_DESC rdesc;
|
|
|
|
rdesc.CullMode = D3D11_CULL_BACK;
|
|
|
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
2014-02-18 12:02:48 +01:00
|
|
|
rdesc.FrontCounterClockwise = true;
|
2013-12-18 20:28:06 +01:00
|
|
|
rdesc.DepthBias = 0;
|
|
|
|
rdesc.DepthBiasClamp = 0;
|
|
|
|
rdesc.DepthClipEnable = true;
|
|
|
|
rdesc.SlopeScaledDepthBias = 0;
|
|
|
|
rdesc.ScissorEnable = false;
|
|
|
|
rdesc.MultisampleEnable = false;
|
|
|
|
rdesc.AntialiasedLineEnable = false;
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
|
|
|
|
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&RenderStates::rs);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
|
|
|
D3D11_SAMPLER_DESC sdesc;
|
|
|
|
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
2014-02-12 08:24:24 +01:00
|
|
|
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
|
|
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
2014-02-20 12:07:53 +01:00
|
|
|
sdesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
2013-12-18 20:28:06 +01:00
|
|
|
sdesc.MipLODBias = 0;
|
|
|
|
sdesc.MaxAnisotropy =4;
|
|
|
|
sdesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
|
|
|
*sdesc.BorderColor = *Oyster::Math::Float4(1,1,1,1).element;
|
|
|
|
sdesc.MinLOD = 0;
|
|
|
|
sdesc.MaxLOD = D3D11_FLOAT32_MAX;
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
|
|
|
|
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,RenderStates::ss);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
|
|
|
D3D11_DEPTH_STENCIL_DESC ddesc;
|
|
|
|
ddesc.DepthEnable = true;
|
|
|
|
ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
|
|
|
ddesc.DepthFunc = D3D11_COMPARISON_LESS;
|
|
|
|
|
|
|
|
ddesc.StencilEnable = true;
|
|
|
|
ddesc.StencilReadMask = 0xFF;
|
|
|
|
ddesc.StencilWriteMask = 0xFF;
|
|
|
|
|
|
|
|
ddesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
ddesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
|
|
|
|
ddesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
ddesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
|
|
|
|
|
|
ddesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
ddesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
|
|
|
|
ddesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
|
|
ddesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
|
|
|
|
Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState);
|
2014-02-11 13:29:19 +01:00
|
|
|
|
|
|
|
D3D11_BLEND_DESC bdesc;
|
|
|
|
bdesc.AlphaToCoverageEnable = true;
|
|
|
|
bdesc.IndependentBlendEnable = false;
|
|
|
|
bdesc.RenderTarget[0].BlendEnable = true;
|
|
|
|
|
|
|
|
bdesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
|
|
|
bdesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
|
|
|
bdesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
|
|
|
|
|
|
|
bdesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
|
|
|
bdesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
|
|
|
|
bdesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX;
|
|
|
|
|
|
|
|
bdesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
|
|
|
|
|
|
|
Core::device->CreateBlendState(&bdesc,&RenderStates::bs);
|
2014-02-07 15:52:07 +01:00
|
|
|
return Core::Init::Success;
|
|
|
|
}
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::Init::State Resources::InitViews()
|
|
|
|
{
|
2013-12-18 20:28:06 +01:00
|
|
|
//Create Views
|
2014-02-07 15:52:07 +01:00
|
|
|
for(int i = 0; i< GBufferSize; ++i)
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
|
|
|
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
|
|
|
|
}
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
for(int i = 0; i < LBufferSize; ++i)
|
2014-01-08 07:01:59 +01:00
|
|
|
{
|
|
|
|
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
|
|
|
|
}
|
|
|
|
|
2014-02-13 15:24:19 +01:00
|
|
|
//Blur
|
|
|
|
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&Blur::BufferSRV,&Blur::BufferUAV);
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Buffer* b = &Light::PointLightsData;
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&Light::PointLightView,NULL);
|
2014-01-16 09:30:01 +01:00
|
|
|
srand((unsigned int)time(0));
|
2014-01-22 16:31:33 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
//SSAO
|
|
|
|
Math::Vector3 kernel[KernelSize];
|
|
|
|
Math::Vector3 random[SampleSpread];
|
|
|
|
for(int i = 0;i < KernelSize; ++i)
|
|
|
|
{
|
|
|
|
kernel[i] = Oyster::Math::Vector3::null;
|
|
|
|
while( kernel[i] == Oyster::Math::Vector3::null )
|
|
|
|
{
|
|
|
|
kernel[i] = Oyster::Math::Vector3(
|
|
|
|
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
|
|
|
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
|
|
|
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
|
|
|
|
}
|
|
|
|
kernel[i].Normalize();
|
|
|
|
|
|
|
|
float scale = float(i) / float(KernelSize);
|
|
|
|
|
|
|
|
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
|
|
|
|
kernel[i] *= scale;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < SampleSpread; ++i)
|
|
|
|
{
|
|
|
|
random[i] = Oyster::Math::Vector3::null;
|
|
|
|
while( random[i] == Oyster::Math::Vector3::null )
|
|
|
|
{
|
|
|
|
random[i] = Oyster::Math::Vector3(
|
|
|
|
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
|
2014-01-22 16:31:33 +01:00
|
|
|
/*(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,*/
|
|
|
|
1.0f,
|
2014-01-08 07:01:59 +01:00
|
|
|
0.0f);
|
|
|
|
}
|
|
|
|
random[i].Normalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
D3D11_TEXTURE1D_DESC T1desc;
|
|
|
|
T1desc.Width = KernelSize;
|
|
|
|
T1desc.MipLevels = T1desc.ArraySize = 1;
|
|
|
|
T1desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
T1desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
T1desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
|
|
|
T1desc.CPUAccessFlags = 0;
|
|
|
|
T1desc.MiscFlags = 0;
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
D3D11_SUBRESOURCE_DATA sphere;
|
|
|
|
sphere.pSysMem = kernel;
|
|
|
|
|
|
|
|
D3D11_SUBRESOURCE_DATA rnd;
|
|
|
|
rnd.pSysMem = random;
|
2014-02-07 08:34:01 +01:00
|
|
|
rnd.SysMemPitch = (UINT)(sqrt(SampleSpread) * sizeof(Oyster::Math::Vector3));
|
2014-01-22 16:31:33 +01:00
|
|
|
|
|
|
|
ID3D11Texture1D *pTexture1;
|
|
|
|
|
|
|
|
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
|
2014-02-18 09:32:10 +01:00
|
|
|
Core::UsedMem += T1desc.Width * 16;
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
|
2014-01-22 16:31:33 +01:00
|
|
|
pTexture1->Release();
|
|
|
|
|
|
|
|
D3D11_TEXTURE2D_DESC T2desc;
|
|
|
|
T2desc.Width = KernelSize;
|
|
|
|
T2desc.MipLevels = T2desc.ArraySize = 1;
|
|
|
|
T2desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
T2desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
T2desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
|
|
|
T2desc.CPUAccessFlags = 0;
|
|
|
|
T2desc.MiscFlags = 0;
|
2014-02-07 08:34:01 +01:00
|
|
|
T2desc.Height = (UINT)sqrt(SampleSpread);
|
|
|
|
T2desc.Width = (UINT)(SampleSpread/sqrt(SampleSpread));
|
2014-01-22 16:31:33 +01:00
|
|
|
T2desc.SampleDesc.Quality = 0;
|
|
|
|
T2desc.SampleDesc.Count = 1;
|
|
|
|
|
|
|
|
ID3D11Texture2D *pTexture2;
|
|
|
|
|
|
|
|
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
|
2014-02-18 09:32:10 +01:00
|
|
|
Core::UsedMem += T2desc.Height * T2desc.Width * 16;
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
|
2014-01-22 16:31:33 +01:00
|
|
|
pTexture2->Release();
|
2014-02-18 09:32:10 +01:00
|
|
|
|
|
|
|
//create Depth Buffer
|
|
|
|
D3D11_TEXTURE2D_DESC dTDesc;
|
|
|
|
dTDesc.MipLevels=1;
|
|
|
|
dTDesc.ArraySize=1;
|
|
|
|
dTDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
|
|
|
dTDesc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
|
|
|
dTDesc.CPUAccessFlags=0;
|
|
|
|
dTDesc.MiscFlags=0;
|
2014-02-18 13:43:32 +01:00
|
|
|
dTDesc.Height = (UINT)Core::resolution.y;
|
|
|
|
dTDesc.Width = (UINT)Core::resolution.x;
|
2014-02-18 09:32:10 +01:00
|
|
|
dTDesc.SampleDesc.Count=1;
|
|
|
|
dTDesc.SampleDesc.Quality=0;
|
|
|
|
|
|
|
|
ID3D11Texture2D* depthstencil;
|
|
|
|
Core::device->CreateTexture2D(&dTDesc,0,&depthstencil);
|
|
|
|
Core::UsedMem += dTDesc.Height * dTDesc.Width * 4;
|
|
|
|
Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth);
|
|
|
|
depthstencil->Release();
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
return Core::Init::Success;
|
|
|
|
}
|
2014-01-08 07:01:59 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Core::Init::State Resources::InitPasses()
|
|
|
|
{
|
2014-01-08 07:01:59 +01:00
|
|
|
|
|
|
|
////---------------- Geometry Pass Setup ----------------------------
|
2014-02-24 14:44:36 +01:00
|
|
|
#pragma region Animated Pass
|
2014-02-25 09:45:02 +01:00
|
|
|
Gather::AnimatedPass.Shaders.Pixel = GetShader::Pixel(L"AGather");
|
|
|
|
Gather::AnimatedPass.Shaders.Vertex = GetShader::Vertex(L"AGather");
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
D3D11_INPUT_ELEMENT_DESC AnimInDesc[] =
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
|
|
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
|
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
2014-01-17 08:51:12 +01:00
|
|
|
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
2014-02-14 15:11:12 +01:00
|
|
|
{ "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
|
|
{ "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 48, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
2013-12-18 20:28:06 +01:00
|
|
|
};
|
|
|
|
|
2014-02-25 09:45:02 +01:00
|
|
|
Shader::CreateInputLayout(AnimInDesc,5,GetShader::Vertex(L"AGather"),Gather::AnimatedPass.IAStage.Layout);
|
2014-02-24 14:44:36 +01:00
|
|
|
Gather::AnimatedPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
|
|
|
Gather::AnimatedPass.CBuffers.Vertex.push_back(Gather::AnimationData);
|
|
|
|
Gather::AnimatedPass.CBuffers.Vertex.push_back(Gather::ModelData);
|
|
|
|
Gather::AnimatedPass.CBuffers.Pixel.push_back(Color);
|
|
|
|
Gather::AnimatedPass.RenderStates.Rasterizer = RenderStates::rs;
|
|
|
|
Gather::AnimatedPass.RenderStates.SampleCount = 1;
|
|
|
|
Gather::AnimatedPass.RenderStates.SampleState = RenderStates::ss;
|
|
|
|
Gather::AnimatedPass.RenderStates.DepthStencil = RenderStates::dsState;
|
2014-02-07 11:09:59 +01:00
|
|
|
for(int i = 0; i<GBufferSize;++i)
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-02-24 14:44:36 +01:00
|
|
|
Gather::AnimatedPass.RTV.push_back(GBufferRTV[i]);
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
2014-02-24 14:44:36 +01:00
|
|
|
Gather::AnimatedPass.depth = Core::depthStencil;
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Instanced Pass
|
|
|
|
Gather::InstancedPass.Shaders.Pixel = GetShader::Pixel(L"IGather");
|
|
|
|
Gather::InstancedPass.Shaders.Vertex = GetShader::Vertex(L"IGather");
|
|
|
|
|
|
|
|
D3D11_INPUT_ELEMENT_DESC InstInDesc[15];
|
|
|
|
|
|
|
|
InstInDesc[0].AlignedByteOffset = 0;
|
|
|
|
InstInDesc[0].SemanticName = "POSITION";
|
|
|
|
InstInDesc[0].SemanticIndex = 0;
|
|
|
|
InstInDesc[0].InputSlot = 0;
|
|
|
|
InstInDesc[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
|
|
|
InstInDesc[0].InstanceDataStepRate = 0;
|
|
|
|
InstInDesc[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[1].AlignedByteOffset = 12;
|
|
|
|
InstInDesc[1].SemanticName = "TEXCOORD";
|
|
|
|
InstInDesc[1].SemanticIndex = 0;
|
|
|
|
InstInDesc[1].InputSlot = 0;
|
|
|
|
InstInDesc[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
|
|
|
InstInDesc[1].InstanceDataStepRate = 0;
|
|
|
|
InstInDesc[1].Format = DXGI_FORMAT_R32G32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[2].AlignedByteOffset = 20;
|
|
|
|
InstInDesc[2].SemanticName = "NORMAL";
|
|
|
|
InstInDesc[2].SemanticIndex = 0;
|
|
|
|
InstInDesc[2].InputSlot = 0;
|
|
|
|
InstInDesc[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
|
|
|
InstInDesc[2].InstanceDataStepRate = 0;
|
|
|
|
InstInDesc[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[3].AlignedByteOffset = 36;
|
|
|
|
InstInDesc[3].SemanticName = "BONEINDEX";
|
|
|
|
InstInDesc[3].SemanticIndex = 0;
|
|
|
|
InstInDesc[3].InputSlot = 0;
|
|
|
|
InstInDesc[3].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
|
|
|
InstInDesc[3].InstanceDataStepRate = 0;
|
|
|
|
InstInDesc[3].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[4].AlignedByteOffset = 48;
|
|
|
|
InstInDesc[4].SemanticName = "BONEWEIGHT";
|
|
|
|
InstInDesc[4].SemanticIndex = 0;
|
|
|
|
InstInDesc[4].InputSlot = 0;
|
|
|
|
InstInDesc[4].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
|
|
|
InstInDesc[4].InstanceDataStepRate = 0;
|
|
|
|
InstInDesc[4].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
/// Set WV
|
|
|
|
InstInDesc[5].AlignedByteOffset = 0;
|
|
|
|
InstInDesc[5].SemanticName = "WV";
|
|
|
|
InstInDesc[5].SemanticIndex = 0;
|
|
|
|
InstInDesc[5].InputSlot = 1;
|
|
|
|
InstInDesc[5].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[5].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[5].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[6].AlignedByteOffset = 16;
|
|
|
|
InstInDesc[6].SemanticName = "WV";
|
|
|
|
InstInDesc[6].SemanticIndex = 1;
|
|
|
|
InstInDesc[6].InputSlot = 1;
|
|
|
|
InstInDesc[6].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[6].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[6].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[7].AlignedByteOffset = 32;
|
|
|
|
InstInDesc[7].SemanticName = "WV";
|
|
|
|
InstInDesc[7].SemanticIndex = 2;
|
|
|
|
InstInDesc[7].InputSlot = 1;
|
|
|
|
InstInDesc[7].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[7].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[7].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[8].AlignedByteOffset = 48;
|
|
|
|
InstInDesc[8].SemanticName = "WV";
|
|
|
|
InstInDesc[8].SemanticIndex = 3;
|
|
|
|
InstInDesc[8].InputSlot = 1;
|
|
|
|
InstInDesc[8].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[8].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[8].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
//WVP
|
|
|
|
|
|
|
|
InstInDesc[9].AlignedByteOffset = 64;
|
|
|
|
InstInDesc[9].SemanticName = "WVP";
|
|
|
|
InstInDesc[9].SemanticIndex = 0;
|
|
|
|
InstInDesc[9].InputSlot = 1;
|
|
|
|
InstInDesc[9].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[9].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[9].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[10].AlignedByteOffset = 80;
|
|
|
|
InstInDesc[10].SemanticName = "WVP";
|
|
|
|
InstInDesc[10].SemanticIndex = 1;
|
|
|
|
InstInDesc[10].InputSlot = 1;
|
|
|
|
InstInDesc[10].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[10].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[10].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[11].AlignedByteOffset = 96;
|
|
|
|
InstInDesc[11].SemanticName = "WVP";
|
|
|
|
InstInDesc[11].SemanticIndex = 2;
|
|
|
|
InstInDesc[11].InputSlot = 1;
|
|
|
|
InstInDesc[11].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[11].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[11].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[12].AlignedByteOffset = 112;
|
|
|
|
InstInDesc[12].SemanticName = "WVP";
|
|
|
|
InstInDesc[12].SemanticIndex = 3;
|
|
|
|
InstInDesc[12].InputSlot = 1;
|
|
|
|
InstInDesc[12].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[12].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[12].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[13].AlignedByteOffset = 128;
|
|
|
|
InstInDesc[13].SemanticName = "TINT";
|
|
|
|
InstInDesc[13].SemanticIndex = 0;
|
|
|
|
InstInDesc[13].InputSlot = 1;
|
|
|
|
InstInDesc[13].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[13].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[13].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
|
|
|
|
InstInDesc[14].AlignedByteOffset = 140;
|
|
|
|
InstInDesc[14].SemanticName = "GTINT";
|
|
|
|
InstInDesc[14].SemanticIndex = 0;
|
|
|
|
InstInDesc[14].InputSlot = 1;
|
|
|
|
InstInDesc[14].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
|
|
|
InstInDesc[14].InstanceDataStepRate = 1;
|
|
|
|
InstInDesc[14].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
|
|
|
|
|
|
|
Shader::CreateInputLayout(InstInDesc,15,GetShader::Vertex(L"IGather"),Gather::InstancedPass.IAStage.Layout);
|
|
|
|
Gather::InstancedPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
|
|
|
Gather::InstancedPass.RenderStates.Rasterizer = RenderStates::rs;
|
|
|
|
Gather::InstancedPass.RenderStates.SampleCount = 1;
|
|
|
|
Gather::InstancedPass.RenderStates.SampleState = RenderStates::ss;
|
|
|
|
Gather::InstancedPass.RenderStates.DepthStencil = RenderStates::dsState;
|
|
|
|
for(int i = 0; i<GBufferSize;++i)
|
|
|
|
{
|
|
|
|
Gather::InstancedPass.RTV.push_back(GBufferRTV[i]);
|
|
|
|
}
|
|
|
|
Gather::InstancedPass.depth = Core::depthStencil;
|
|
|
|
#pragma endregion
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
////---------------- Light Pass Setup ----------------------------
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::Pass.Shaders.Compute = GetShader::Compute(L"LightPass");
|
|
|
|
for(int i = 0; i<LBufferSize;++i)
|
2014-01-08 07:01:59 +01:00
|
|
|
{
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::Pass.UAV.Compute.push_back(LBufferUAV[i]);
|
2014-01-08 07:01:59 +01:00
|
|
|
}
|
2014-02-07 15:52:07 +01:00
|
|
|
for(int i = 0; i<GBufferSize;++i)
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::Pass.SRV.Compute.push_back(GBufferSRV[i]);
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::Pass.SRV.Compute.push_back(Core::depthStencilUAV);
|
|
|
|
Light::Pass.CBuffers.Compute.push_back(Light::LightConstantsData);
|
|
|
|
Light::Pass.SRV.Compute.push_back(Light::PointLightView);
|
|
|
|
Light::Pass.SRV.Compute.push_back(Light::SSAOKernel);
|
|
|
|
Light::Pass.SRV.Compute.push_back(Light::SSAORandom);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
////---------------- Post Pass Setup ----------------------------
|
2014-02-07 16:51:35 +01:00
|
|
|
Post::Pass.Shaders.Compute = GetShader::Compute(L"PostPass");
|
2014-02-07 15:52:07 +01:00
|
|
|
for(int i = 0; i<LBufferSize;++i)
|
2014-01-08 07:01:59 +01:00
|
|
|
{
|
2014-02-07 16:51:35 +01:00
|
|
|
Post::Pass.SRV.Compute.push_back(LBufferSRV[i]);
|
2014-01-08 07:01:59 +01:00
|
|
|
}
|
2014-02-07 16:51:35 +01:00
|
|
|
Post::Pass.UAV.Compute.push_back(Core::backBufferUAV);
|
2014-02-10 01:03:10 +01:00
|
|
|
Post::Pass.CBuffers.Compute.push_back(Post::Data);
|
2014-02-13 15:24:19 +01:00
|
|
|
Post::Pass.RenderStates.SampleCount = 1;
|
|
|
|
Post::Pass.RenderStates.SampleState = RenderStates::ss;
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-07 11:09:59 +01:00
|
|
|
////---------------- GUI Pass Setup ----------------------------
|
2014-02-07 15:52:07 +01:00
|
|
|
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
|
|
|
|
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
|
|
|
|
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
2014-02-18 09:32:10 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
2014-02-07 16:51:35 +01:00
|
|
|
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
2014-02-12 16:21:46 +01:00
|
|
|
Gui::Pass.CBuffers.Pixel.push_back(Color);
|
2014-02-07 11:09:59 +01:00
|
|
|
|
2014-02-18 09:32:10 +01:00
|
|
|
Gui::Pass.depth = Gui::depth;
|
|
|
|
|
2014-02-07 11:09:59 +01:00
|
|
|
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
|
|
|
{
|
|
|
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
|
|
};
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Shader::CreateInputLayout(indesc2D,1,GetShader::Vertex(L"2D"),Gui::Pass.IAStage.Layout);
|
|
|
|
Gui::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
|
2014-02-07 11:09:59 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
Gui::Pass.RenderStates.SampleCount = 1;
|
|
|
|
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
|
2014-02-12 08:35:21 +01:00
|
|
|
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
|
2014-02-18 09:32:10 +01:00
|
|
|
Gui::Pass.RenderStates.DepthStencil = RenderStates::dsState;
|
2014-02-07 11:09:59 +01:00
|
|
|
|
2014-02-07 13:46:55 +01:00
|
|
|
////---------------- Blur Pass Setup ----------------------------
|
2014-02-07 15:52:07 +01:00
|
|
|
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
|
|
|
|
Blur::VertPass.Shaders.Compute = GetShader::Compute(L"BlurVert");
|
2014-02-07 13:46:55 +01:00
|
|
|
|
|
|
|
//Taking the Ambient SRV from LBufferSRV and setting it as input texture
|
2014-02-07 15:52:07 +01:00
|
|
|
Blur::HorPass.SRV.Compute.push_back(LBufferSRV[2]);
|
2014-02-07 13:46:55 +01:00
|
|
|
//Output texture is the Blur UAV buffer
|
2014-02-07 15:52:07 +01:00
|
|
|
Blur::HorPass.UAV.Compute.push_back(Blur::BufferUAV);
|
2014-02-07 13:46:55 +01:00
|
|
|
|
|
|
|
//Taking the Blur SRV and setting it as input texture now
|
2014-02-07 15:52:07 +01:00
|
|
|
Blur::VertPass.SRV.Compute.push_back(Blur::BufferSRV);
|
2014-02-07 13:46:55 +01:00
|
|
|
//And the Ambient UAV is now the output texture
|
2014-02-07 15:52:07 +01:00
|
|
|
Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]);
|
|
|
|
|
2014-02-13 15:24:19 +01:00
|
|
|
Blur::HorPass.CBuffers.Compute.push_back(Blur::Data);
|
|
|
|
Blur::VertPass.CBuffers.Compute.push_back(Blur::Data);
|
|
|
|
|
2014-02-11 13:29:19 +01:00
|
|
|
////---------------- 2DText Pass Setup ----------------------------
|
|
|
|
Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText");
|
|
|
|
Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText");
|
|
|
|
Gui::Text::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
|
|
|
|
|
|
|
|
Gui::Text::Pass.IAStage.Topology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
|
|
|
|
|
|
|
|
D3D11_INPUT_ELEMENT_DESC Text2Ddesc[] =
|
|
|
|
{
|
|
|
|
{"Position",0, DXGI_FORMAT_R32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"Offset",0, DXGI_FORMAT_R32_SINT, 0, 4, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"CharOffset",0, DXGI_FORMAT_R32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout);
|
|
|
|
Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
2014-02-12 16:21:46 +01:00
|
|
|
Gui::Text::Pass.CBuffers.Pixel.push_back(Color);
|
2014-02-11 13:29:19 +01:00
|
|
|
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
|
|
|
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
2014-02-18 09:32:10 +01:00
|
|
|
|
|
|
|
Gui::Text::Pass.depth = Gui::depth;
|
|
|
|
|
2014-02-11 13:29:19 +01:00
|
|
|
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
|
|
|
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
|
|
|
|
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
|
2014-02-18 09:32:10 +01:00
|
|
|
Gui::Text::Pass.RenderStates.DepthStencil = RenderStates::dsState;
|
2014-02-11 13:29:19 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
return Core::Init::Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
Core::Init::State Resources::Init()
|
|
|
|
{
|
|
|
|
InitShaders();
|
|
|
|
InitBuffers();
|
|
|
|
InitRenderStates();
|
|
|
|
InitViews();
|
|
|
|
InitPasses();
|
2014-02-07 13:46:55 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
return Core::Init::State::Success;
|
|
|
|
}
|
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
void Resources::Clean()
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-02-07 15:52:07 +01:00
|
|
|
Gather::ModelData.~Buffer();
|
|
|
|
Gather::AnimationData.~Buffer();
|
2014-02-24 14:44:36 +01:00
|
|
|
Gather::InstancedData.~Buffer();
|
2014-02-07 15:52:07 +01:00
|
|
|
Light::LightConstantsData.~Buffer();
|
|
|
|
Light::PointLightsData.~Buffer();
|
|
|
|
Gui::Data.~Buffer();
|
2014-02-12 16:21:46 +01:00
|
|
|
Color.~Buffer();
|
2014-02-11 13:29:19 +01:00
|
|
|
Gui::Text::Vertex.~Buffer();
|
2014-02-10 01:03:10 +01:00
|
|
|
Post::Data.~Buffer();
|
2014-02-13 15:24:19 +01:00
|
|
|
Blur::Data.~Buffer();
|
2014-02-07 15:52:07 +01:00
|
|
|
SAFE_RELEASE(Light::PointLightView);
|
|
|
|
SAFE_RELEASE(Light::SSAOKernel);
|
|
|
|
SAFE_RELEASE(Light::SSAORandom);
|
|
|
|
|
|
|
|
SAFE_RELEASE(Blur::BufferSRV);
|
|
|
|
SAFE_RELEASE(Blur::BufferUAV);
|
2014-02-07 13:46:55 +01:00
|
|
|
|
2013-12-18 20:28:06 +01:00
|
|
|
for(int i = 0; i< GBufferSize; ++i)
|
|
|
|
{
|
|
|
|
SAFE_RELEASE(GBufferRTV[i]);
|
|
|
|
SAFE_RELEASE(GBufferSRV[i]);
|
|
|
|
}
|
|
|
|
|
2014-01-08 07:01:59 +01:00
|
|
|
for(int i = 0; i< LBufferSize; ++i)
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-01-08 07:01:59 +01:00
|
|
|
SAFE_RELEASE(LBufferUAV[i]);
|
|
|
|
SAFE_RELEASE(LBufferSRV[i]);
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_RELEASE(Gather::AnimatedPass.IAStage.Layout);
|
|
|
|
SAFE_RELEASE(Gather::InstancedPass.IAStage.Layout);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_RELEASE(Gather::AnimatedPass.RenderStates.BlendState);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_RELEASE(Gather::AnimatedPass.RenderStates.DepthStencil);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_RELEASE(Gather::AnimatedPass.RenderStates.Rasterizer);
|
2013-12-18 20:28:06 +01:00
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
for(int i = 0; i < Gather::AnimatedPass.RenderStates.SampleCount; ++i)
|
2013-12-18 20:28:06 +01:00
|
|
|
{
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_RELEASE(Gather::AnimatedPass.RenderStates.SampleState[i]);
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
|
|
|
|
2014-02-24 14:44:36 +01:00
|
|
|
SAFE_DELETE_ARRAY(Gather::AnimatedPass.RenderStates.SampleState);
|
2014-02-07 11:52:51 +01:00
|
|
|
|
2014-02-07 15:52:07 +01:00
|
|
|
SAFE_RELEASE(Gui::Pass.IAStage.Layout);
|
2014-02-11 13:29:19 +01:00
|
|
|
|
|
|
|
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
|
|
|
|
|
|
|
|
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
|
2014-02-18 09:32:10 +01:00
|
|
|
|
|
|
|
SAFE_RELEASE(Gui::depth);
|
2013-12-18 20:28:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|