Fixed cleaning up Deffered.cpp

This commit is contained in:
lanariel 2014-02-07 15:52:07 +01:00
parent 898fc883e9
commit 1de325c5a6
18 changed files with 331 additions and 381 deletions

View File

@ -1,14 +1,12 @@
#include "GFXAPI.h"
#include "../Core/Core.h"
#include "../Render/Resources/Debug.h"
#include "../Render/Resources/Deffered.h"
#include "../Render/Rendering/Render.h"
#include "../Render/Resources.h"
#include "../Render/DefaultRenderer.h"
#include "../FileLoader/ObjReader.h"
//#include "../../Misc/Resource/OysterResource.h"
#include "../../Misc/Resource/ResourceManager.h"
#include "../FileLoader/GeneralLoader.h"
#include "../Model/ModelInfo.h"
#include "../Render/Rendering/GuiRender.h"
#include "../Render/GuiRenderer.h"
#include <vld.h>
namespace Oyster
@ -30,11 +28,11 @@ namespace Oyster
{
return API::Fail;
}
Render::Resources::Deffered::Init();
Render::Resources::Init();
Render::Preparations::Basic::SetViewPort();
Render::Rendering::Basic::cube = API::CreateModel(L"box.dan");
Render::Rendering::Basic::cube2 = API::CreateModel(L"box2.dan");
Render::DefaultRenderer::cube = API::CreateModel(L"box.dan");
Render::DefaultRenderer::cube2 = API::CreateModel(L"box2.dan");
return API::Sucsess;
}
@ -52,27 +50,27 @@ namespace Oyster
{
if(Lights.size())
{
Render::Rendering::Basic::NewFrame(View, Projection, &Lights[0], (int)Lights.size());
Render::DefaultRenderer::NewFrame(View, Projection, &Lights[0], (int)Lights.size());
}
else
{
Render::Rendering::Basic::NewFrame(View, Projection, NULL, 0);
Render::DefaultRenderer::NewFrame(View, Projection, NULL, 0);
}
}
void API::RenderScene(Model::Model models[], int count)
{
Render::Rendering::Basic::RenderScene(models,count, View, Projection);
Render::DefaultRenderer::RenderScene(models,count, View, Projection);
}
void API::RenderModel(Model::Model& m)
{
Render::Rendering::Basic::RenderScene(&m,1, View, Projection);
Render::DefaultRenderer::RenderScene(&m,1, View, Projection);
}
void API::EndFrame()
{
Render::Rendering::Basic::EndFrame();
Render::DefaultRenderer::EndFrame();
}
API::State API::SetOptions(API::Option option)
@ -112,12 +110,12 @@ namespace Oyster
void API::Clean()
{
DeleteModel(Render::Rendering::Basic::cube);
DeleteModel(Render::Rendering::Basic::cube2);
DeleteModel(Render::DefaultRenderer::cube);
DeleteModel(Render::DefaultRenderer::cube2);
SAFE_DELETE(Core::viewPort);
Core::loader.Clean();
Oyster::Graphics::Core::PipelineManager::Clean();
Oyster::Graphics::Render::Resources::Deffered::Clean();
Oyster::Graphics::Render::Resources::Clean();
SAFE_RELEASE(Core::depthStencil);
SAFE_RELEASE(Core::depthStencilUAV);
@ -142,7 +140,7 @@ namespace Oyster
#ifdef _DEBUG
API::State API::ReloadShaders()
{
Render::Resources::Deffered::InitShaders();
Render::Resources::InitShaders();
return State::Sucsess;
}
#endif

View File

@ -181,9 +181,9 @@
<ClCompile Include="FileLoader\ShaderLoader.cpp" />
<ClCompile Include="FileLoader\ModelLoader.cpp" />
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Render\Rendering\GuiRender.cpp" />
<ClCompile Include="Render\Resources\Deffered.cpp" />
<ClCompile Include="Render\DefaultRenderer.cpp" />
<ClCompile Include="Render\GuiRenderer.cpp" />
<ClCompile Include="Render\Resources.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Core\Core.h" />
@ -194,10 +194,10 @@
<ClInclude Include="Model\Model.h" />
<ClInclude Include="Model\ModelInfo.h" />
<ClInclude Include="Render\Preparations\Preparations.h" />
<ClInclude Include="Render\Rendering\GuiRender.h" />
<ClInclude Include="Render\Rendering\Render.h" />
<ClInclude Include="Render\GuiRenderer.h" />
<ClInclude Include="Render\DefaultRenderer.h" />
<ClInclude Include="Definitions\GraphicalDefinition.h" />
<ClInclude Include="Render\Resources\Deffered.h" />
<ClInclude Include="Render\Resources.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Misc\Misc.vcxproj">
@ -242,7 +242,7 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="Shader\Passes\Post\BlurHor.hlsl">
<FxCompile Include="Shader\Passes\Blur\BlurHor.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
@ -252,7 +252,7 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\Passes\Post\BlurVert.hlsl">
<FxCompile Include="Shader\Passes\Blur\BlurVert.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
@ -324,7 +324,7 @@
<None Include="Shader\Passes\Light\PosManipulation.hlsli" />
<None Include="Shader\Passes\Light\SSAO.hlsli" />
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
<None Include="Shader\Passes\Post\BlurSharedData.hlsli" />
<None Include="Shader\Passes\Blur\BlurSharedData.hlsli" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -24,9 +24,6 @@
<ClCompile Include="Core\Init.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Rendering\BasicRender.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -42,16 +39,19 @@
<ClCompile Include="FileLoader\ModelLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Resources\Deffered.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Core\PipelineManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileLoader\DanLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Rendering\GuiRender.cpp">
<ClCompile Include="Render\DefaultRenderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\GuiRenderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -62,9 +62,6 @@
<ClInclude Include="Render\Preparations\Preparations.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Rendering\Render.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Model\ModelInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -86,10 +83,13 @@
<ClInclude Include="FileLoader\GeneralLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Resources\Deffered.h">
<ClInclude Include="Render\DefaultRenderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Rendering\GuiRender.h">
<ClInclude Include="Render\GuiRenderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
@ -105,8 +105,8 @@
<FxCompile Include="Shader\Passes\2D\2DVertex.hlsl" />
<FxCompile Include="Shader\Passes\2D\2DPixel.hlsl" />
<FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" />
<FxCompile Include="Shader\Passes\Post\BlurVert.hlsl" />
<FxCompile Include="Shader\Passes\Post\BlurHor.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurHor.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurVert.hlsl" />
</ItemGroup>
<ItemGroup>
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
@ -116,6 +116,6 @@
<None Include="Shader\Passes\Light\SSAO.hlsli" />
<None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Post\BlurSharedData.hlsli" />
<None Include="Shader\Passes\Blur\BlurSharedData.hlsli" />
</ItemGroup>
</Project>

View File

@ -1,8 +1,8 @@
#include "Render.h"
#include "../Resources/Deffered.h"
#include "../../Definitions/GraphicalDefinition.h"
#include "../../Model/ModelInfo.h"
#include "../../DllInterfaces/GFXAPI.h"
#include "DefaultRenderer.h"
#include "Resources.h"
#include "../Definitions/GraphicalDefinition.h"
#include "../Model/ModelInfo.h"
#include "../DllInterfaces/GFXAPI.h"
#include <map>
#include <vector>
@ -11,18 +11,16 @@ namespace Oyster
namespace Graphics
{
namespace Render
{
namespace Rendering
{
Definitions::Pointlight pl;
Model::Model* Basic::cube = NULL;
Model::Model* Basic::cube2 = NULL;
Model::Model* DefaultRenderer::cube = NULL;
Model::Model* DefaultRenderer::cube2 = NULL;
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
{
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
Preparations::Basic::ClearRTV(Resources::Deffered::GBufferRTV,Resources::Deffered::GBufferSize,Math::Float4(0,0,0,1));
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Deffered::GeometryPass);
Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,1));
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass);
void* data;
@ -34,13 +32,13 @@ namespace Oyster
lc.Proj = Projection;
lc.SSAORadius = 3;
data = Resources::Deffered::LightConstantsData.Map();
data = Resources::Light::LightConstantsData.Map();
memcpy(data, &lc, sizeof(Definitions::LightConstants));
Resources::Deffered::LightConstantsData.Unmap();
Resources::Light::LightConstantsData.Unmap();
data = Resources::Deffered::PointLightsData.Map();
data = Resources::Light::PointLightsData.Map();
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
Resources::Deffered::PointLightsData.Unmap();
Resources::Light::PointLightsData.Unmap();
}
Math::Matrix RecursiveBindPosRotation(int index, Model::ModelInfo* mi)
@ -60,7 +58,7 @@ namespace Oyster
return Math::Vector4(RecursiveBindPosPosition(mi->bones->Parent, mi).xyz + (mi->bones[index].Relative.v[3] * RecursiveBindPosRotation(mi->bones->Parent,mi)).xyz,1);
}
void Basic::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection)
void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection)
{
for(int i = 0; i < count; ++i)
{
@ -141,7 +139,7 @@ namespace Oyster
cube->WorldMatrix = Scale;
cube->WorldMatrix.v[3] = BoneAbsAnimated[b].v[3];
cube->WorldMatrix = models[i].WorldMatrix * cube->WorldMatrix;
Basic::RenderScene(cube,1,View,Projection);
DefaultRenderer::RenderScene(cube,1,View,Projection);
}
//write data to am
@ -151,18 +149,18 @@ namespace Oyster
}
void *data = Resources::Deffered::AnimationData.Map();
void *data = Resources::Gather::AnimationData.Map();
memcpy(data,&am,sizeof(Definitions::AnimationData));
Resources::Deffered::AnimationData.Unmap();
Resources::Gather::AnimationData.Unmap();
pm.Animated = 1;
}
else
pm.Animated = 0;
void* data = Resources::Deffered::ModelData.Map();
void* data = Resources::Gather::ModelData.Map();
memcpy(data,&(pm),sizeof(pm));
Resources::Deffered::ModelData.Unmap();
Resources::Gather::ModelData.Unmap();
if(info->Material.size())
{
@ -185,19 +183,19 @@ namespace Oyster
}
void Basic::EndFrame()
void DefaultRenderer::EndFrame()
{
Core::PipelineManager::SetRenderPass(Resources::Deffered::LightPass);
Core::PipelineManager::SetRenderPass(Resources::Light::Pass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Deffered::BlurHorPass);
Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Deffered::BlurVertPass);
Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
Core::PipelineManager::SetRenderPass(Resources::PostPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
@ -206,4 +204,3 @@ namespace Oyster
}
}
}
}

View File

@ -0,0 +1,25 @@
#pragma once
#include "..\Definitions\GraphicalDefinition.h"
#include "..\Core\Core.h"
#include "Preparations\Preparations.h"
#include "..\Model\Model.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
class DefaultRenderer
{
public:
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection);
static void EndFrame();
static Model::Model* cube;
static Model::Model* cube2;
};
}
}
}

View File

@ -1,6 +1,6 @@
#include "GuiRender.h"
#include "../Resources/Deffered.h"
#include "../../Definitions/GraphicalDefinition.h"
#include "GuiRenderer.h"
#include "Resources.h"
#include "../Definitions/GraphicalDefinition.h"
namespace Oyster
{
@ -31,9 +31,9 @@ namespace Oyster
gd.Translation.m22 = size.y;
void* data = Render::Resources::Deffered::GuiData.Map();
void* data = Render::Resources::Gui::Data.Map();
memcpy(data,&gd,sizeof(gd));
Render::Resources::Deffered::GuiData.Unmap();
Render::Resources::Gui::Data.Unmap();
Core::deviceContext->Draw(1,0);
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "../../Core/Core.h"
#include "../Core/Core.h"
namespace Oyster
{

View File

@ -1,29 +0,0 @@
#pragma once
#include "..\..\Definitions\GraphicalDefinition.h"
#include "..\..\Core\Core.h"
#include "..\Preparations\Preparations.h"
#include "..\..\Model\Model.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
namespace Rendering
{
class Basic
{
public:
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection);
static void EndFrame();
static Model::Model* cube;
static Model::Model* cube2;
};
}
}
}
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "Deffered.h"
#include "..\..\Definitions\GraphicalDefinition.h"
#include "Resources.h"
#include "..\Definitions\GraphicalDefinition.h"
typedef Oyster::Graphics::Core::PipelineManager::ShaderType ShaderType;
typedef Oyster::Graphics::Core::PipelineManager::Get GetShader;
@ -19,39 +19,41 @@ namespace Oyster
namespace Graphics
{
namespace Render
{
namespace Resources
{
ID3D11RenderTargetView* Deffered::GBufferRTV[Deffered::GBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::GBufferSRV[Deffered::GBufferSize] = {0};
ID3D11RenderTargetView* Resources::GBufferRTV[Resources::GBufferSize] = {0};
ID3D11ShaderResourceView* Resources::GBufferSRV[Resources::GBufferSize] = {0};
ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0};
ID3D11UnorderedAccessView* Resources::LBufferUAV[Resources::LBufferSize] = {0};
ID3D11ShaderResourceView* Resources::LBufferSRV[Resources::LBufferSize] = {0};
ID3D11UnorderedAccessView* Deffered::BlurBufferUAV = {0};
ID3D11ShaderResourceView* Deffered::BlurBufferSRV = {0};
ID3D11UnorderedAccessView* Resources::Blur::BufferUAV = {0};
ID3D11ShaderResourceView* Resources::Blur::BufferSRV = {0};
Shader::RenderPass Deffered::GeometryPass;
Shader::RenderPass Deffered::LightPass;
Shader::RenderPass Deffered::PostPass;
Shader::RenderPass Deffered::GuiPass;
Shader::RenderPass Deffered::BlurVertPass; //Set this pass second when doing a "fullscreen" blur
Shader::RenderPass Deffered::BlurHorPass; //Set this pass first when doing a "fullscreen" blur
Shader::RenderPass Resources::Gather::Pass;
Shader::RenderPass Resources::Light::Pass;
Shader::RenderPass Resources::PostPass;
Shader::RenderPass Resources::Gui::Pass;
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
Buffer Deffered::ModelData = Buffer();
Buffer Deffered::AnimationData = Buffer();
Buffer Deffered::LightConstantsData = Buffer();
Buffer Deffered::GuiData = Buffer();
Buffer Resources::Gather::ModelData = Buffer();
Buffer Resources::Gather::AnimationData = Buffer();
Buffer Resources::Light::LightConstantsData = Buffer();
Buffer Resources::Gui::Data = Buffer();
Buffer Deffered::PointLightsData = Buffer();
ID3D11ShaderResourceView* Deffered::PointLightView = NULL;
Buffer Resources::Light::PointLightsData = Buffer();
ID3D11ShaderResourceView* Resources::Light::PointLightView = NULL;
ID3D11ShaderResourceView* Deffered::SSAOKernel = NULL;
ID3D11ShaderResourceView* Deffered::SSAORandom = NULL;
ID3D11ShaderResourceView* Resources::Light::SSAOKernel = NULL;
ID3D11ShaderResourceView* Resources::Light::SSAORandom = NULL;
ID3D11RasterizerState* Resources::RenderStates::rs = NULL;
ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1];
ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL;
Core::Init::State Deffered::InitShaders()
Core::Init::State Resources::InitShaders()
{
#ifdef _DEBUG
std::wstring path = PathToHLSL+L"Gather\\";
@ -71,6 +73,9 @@ namespace Oyster
path = PathToHLSL+L"Post\\";
#endif
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
#ifdef _DEBUG
path = PathToHLSL+L"Blur\\";
#endif
Core::PipelineManager::Init(path + L"BlurHor" + end, ShaderType::Compute, L"BlurHor");
Core::PipelineManager::Init(path + L"BlurVert" + end, ShaderType::Compute, L"BlurVert");
#ifdef _DEBUG
@ -83,10 +88,8 @@ namespace Oyster
return Core::Init::State::Success;
}
Core::Init::State Deffered::Init()
Core::Init::State Resources::InitBuffers()
{
InitShaders();
//Create Buffers
Buffer::BUFFER_INIT_DESC desc;
desc.ElementSize = sizeof(Definitions::PerModel);
@ -95,11 +98,11 @@ namespace Oyster
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
desc.Usage = Buffer::BUFFER_USAGE::BUFFER_CPU_WRITE_DISCARD;
ModelData.Init(desc);
Gather::ModelData.Init(desc);
desc.NumElements = 1;
desc.ElementSize = sizeof(Definitions::AnimationData);
AnimationData.Init(desc);
Gather::AnimationData.Init(desc);
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
desc.NumElements = 1;
@ -109,13 +112,17 @@ namespace Oyster
desc.NumElements = 1;
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_CS;
LightConstantsData.Init(desc);
Light::LightConstantsData.Init(desc);
desc.ElementSize = sizeof(Definitions::Pointlight);
desc.NumElements = MaxLightSize;
desc.Type = Buffer::STRUCTURED_BUFFER;
PointLightsData.Init(desc);
Light::PointLightsData.Init(desc);
return Core::Init::Success;
}
Core::Init::State Resources::InitRenderStates()
{
////Create States
D3D11_RASTERIZER_DESC rdesc;
rdesc.CullMode = D3D11_CULL_BACK;
@ -129,8 +136,8 @@ namespace Oyster
rdesc.MultisampleEnable = false;
rdesc.AntialiasedLineEnable = false;
ID3D11RasterizerState* rs = NULL;
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&rs);
Oyster::Graphics::Core::device->CreateRasterizerState(&rdesc,&RenderStates::rs);
D3D11_SAMPLER_DESC sdesc;
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
@ -144,8 +151,8 @@ namespace Oyster
sdesc.MinLOD = 0;
sdesc.MaxLOD = D3D11_FLOAT32_MAX;
ID3D11SamplerState** ss = new ID3D11SamplerState*[1];
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,ss);
Oyster::Graphics::Core::device->CreateSamplerState(&sdesc,RenderStates::ss);
D3D11_DEPTH_STENCIL_DESC ddesc;
ddesc.DepthEnable = true;
@ -166,23 +173,27 @@ namespace Oyster
ddesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
ddesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
ID3D11DepthStencilState* dsState;
Core::device->CreateDepthStencilState(&ddesc,&dsState);
Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState);
return Core::Init::Success;
}
Core::Init::State Resources::InitViews()
{
//Create Views
for(int i = 0; i< Resources::Deffered::GBufferSize; ++i)
for(int i = 0; i< GBufferSize; ++i)
{
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
}
for(int i = 0; i < Resources::Deffered::LBufferSize; ++i)
for(int i = 0; i < LBufferSize; ++i)
{
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
}
Buffer* b = &PointLightsData;
Buffer* b = &Light::PointLightsData;
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&Light::PointLightView,NULL);
srand((unsigned int)time(0));
//SSAO
@ -241,7 +252,7 @@ namespace Oyster
ID3D11Texture1D *pTexture1;
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
Core::device->CreateShaderResourceView( pTexture1, 0, &SSAOKernel );
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
pTexture1->Release();
D3D11_TEXTURE2D_DESC T2desc;
@ -260,14 +271,17 @@ namespace Oyster
ID3D11Texture2D *pTexture2;
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
Core::device->CreateShaderResourceView( (pTexture2), 0, &SSAORandom );
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
pTexture2->Release();
return Core::Init::Success;
}
////Create ShaderEffects
Core::Init::State Resources::InitPasses()
{
////---------------- Geometry Pass Setup ----------------------------
GeometryPass.Shaders.Pixel = GetShader::Pixel(L"Gather");
GeometryPass.Shaders.Vertex = GetShader::Vertex(L"Gather");
Gather::Pass.Shaders.Pixel = GetShader::Pixel(L"Gather");
Gather::Pass.Shaders.Vertex = GetShader::Vertex(L"Gather");
D3D11_INPUT_ELEMENT_DESC indesc[] =
{
@ -280,91 +294,104 @@ namespace Oyster
{ "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Gather"),GeometryPass.IAStage.Layout);
GeometryPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
GeometryPass.CBuffers.Vertex.push_back(AnimationData);
GeometryPass.CBuffers.Vertex.push_back(ModelData);
GeometryPass.RenderStates.Rasterizer = rs;
GeometryPass.RenderStates.SampleCount = 1;
GeometryPass.RenderStates.SampleState = ss;
GeometryPass.RenderStates.DepthStencil = dsState;
Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout);
Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData);
Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData);
Gather::Pass.RenderStates.Rasterizer = RenderStates::rs;
Gather::Pass.RenderStates.SampleCount = 1;
Gather::Pass.RenderStates.SampleState = RenderStates::ss;
Gather::Pass.RenderStates.DepthStencil = RenderStates::dsState;
for(int i = 0; i<GBufferSize;++i)
{
GeometryPass.RTV.push_back(GBufferRTV[i]);
Gather::Pass.RTV.push_back(GBufferRTV[i]);
}
GeometryPass.depth = Core::depthStencil;
Gather::Pass.depth = Core::depthStencil;
////---------------- Light Pass Setup ----------------------------
LightPass.Shaders.Compute = GetShader::Compute(L"LightPass");
for(int i = 0; i<Deffered::LBufferSize;++i)
Light::Pass.Shaders.Compute = GetShader::Compute(L"LightPass");
for(int i = 0; i<LBufferSize;++i)
{
LightPass.UAV.Compute.push_back(LBufferUAV[i]);
Light::Pass.UAV.Compute.push_back(LBufferUAV[i]);
}
for(int i = 0; i<Deffered::GBufferSize;++i)
for(int i = 0; i<GBufferSize;++i)
{
LightPass.SRV.Compute.push_back(GBufferSRV[i]);
Light::Pass.SRV.Compute.push_back(GBufferSRV[i]);
}
LightPass.SRV.Compute.push_back(Core::depthStencilUAV);
LightPass.CBuffers.Compute.push_back(LightConstantsData);
LightPass.SRV.Compute.push_back(PointLightView);
LightPass.SRV.Compute.push_back(SSAOKernel);
LightPass.SRV.Compute.push_back(SSAORandom);
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);
////---------------- Post Pass Setup ----------------------------
PostPass.Shaders.Compute = GetShader::Compute(L"PostPass");
for(int i = 0; i<Deffered::LBufferSize;++i)
for(int i = 0; i<LBufferSize;++i)
{
PostPass.SRV.Compute.push_back(LBufferSRV[i]);
}
PostPass.UAV.Compute.push_back(Core::backBufferUAV);
////---------------- GUI Pass Setup ----------------------------
GuiPass.Shaders.Vertex = GetShader::Vertex(L"2D");
GuiPass.Shaders.Pixel = GetShader::Pixel(L"2D");
GuiPass.Shaders.Geometry = GetShader::Geometry(L"2D");
GuiPass.RTV.push_back(GBufferRTV[2]);
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
Gui::Pass.RTV.push_back(GBufferRTV[2]);
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
Shader::CreateInputLayout(indesc2D,1,GetShader::Vertex(L"2D"),GuiPass.IAStage.Layout);
GuiPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
Shader::CreateInputLayout(indesc2D,1,GetShader::Vertex(L"2D"),Gui::Pass.IAStage.Layout);
Gui::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
GuiPass.RenderStates.SampleCount = 1;
GuiPass.RenderStates.SampleState = ss;
Gui::Pass.RenderStates.SampleCount = 1;
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
////---------------- Blur Pass Setup ----------------------------
BlurHorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
BlurVertPass.Shaders.Compute = GetShader::Compute(L"BlurVert");
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
Blur::VertPass.Shaders.Compute = GetShader::Compute(L"BlurVert");
//Taking the Ambient SRV from LBufferSRV and setting it as input texture
BlurHorPass.SRV.Compute.push_back(LBufferSRV[2]);
Blur::HorPass.SRV.Compute.push_back(LBufferSRV[2]);
//Output texture is the Blur UAV buffer
BlurHorPass.UAV.Compute.push_back(BlurBufferUAV);
Blur::HorPass.UAV.Compute.push_back(Blur::BufferUAV);
//Taking the Blur SRV and setting it as input texture now
BlurVertPass.SRV.Compute.push_back(BlurBufferSRV);
Blur::VertPass.SRV.Compute.push_back(Blur::BufferSRV);
//And the Ambient UAV is now the output texture
BlurVertPass.UAV.Compute.push_back(LBufferUAV[2]);
Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]);
return Core::Init::Success;
}
Core::Init::State Resources::Init()
{
InitShaders();
InitBuffers();
InitRenderStates();
InitViews();
InitPasses();
return Core::Init::State::Success;
}
void Deffered::Clean()
{
Resources::Deffered::ModelData.~Buffer();
Resources::Deffered::AnimationData.~Buffer();
Resources::Deffered::LightConstantsData.~Buffer();
Resources::Deffered::PointLightsData.~Buffer();
GuiData.~Buffer();
SAFE_RELEASE(Resources::Deffered::PointLightView);
SAFE_RELEASE(Deffered::SSAOKernel);
SAFE_RELEASE(Deffered::SSAORandom);
SAFE_RELEASE(BlurBufferSRV);
SAFE_RELEASE(BlurBufferUAV);
void Resources::Clean()
{
Gather::ModelData.~Buffer();
Gather::AnimationData.~Buffer();
Light::LightConstantsData.~Buffer();
Light::PointLightsData.~Buffer();
Gui::Data.~Buffer();
SAFE_RELEASE(Light::PointLightView);
SAFE_RELEASE(Light::SSAOKernel);
SAFE_RELEASE(Light::SSAORandom);
SAFE_RELEASE(Blur::BufferSRV);
SAFE_RELEASE(Blur::BufferUAV);
for(int i = 0; i< GBufferSize; ++i)
{
@ -378,23 +405,22 @@ namespace Oyster
SAFE_RELEASE(LBufferSRV[i]);
}
SAFE_RELEASE(GeometryPass.IAStage.Layout);
SAFE_RELEASE(Gather::Pass.IAStage.Layout);
SAFE_RELEASE(GeometryPass.RenderStates.BlendState);
SAFE_RELEASE(Gather::Pass.RenderStates.BlendState);
SAFE_RELEASE(GeometryPass.RenderStates.DepthStencil);
SAFE_RELEASE(Gather::Pass.RenderStates.DepthStencil);
SAFE_RELEASE(GeometryPass.RenderStates.Rasterizer);
SAFE_RELEASE(Gather::Pass.RenderStates.Rasterizer);
for(int i = 0; i < GeometryPass.RenderStates.SampleCount; ++i)
for(int i = 0; i < Gather::Pass.RenderStates.SampleCount; ++i)
{
SAFE_RELEASE(GeometryPass.RenderStates.SampleState[i]);
SAFE_RELEASE(Gather::Pass.RenderStates.SampleState[i]);
}
SAFE_DELETE_ARRAY(GeometryPass.RenderStates.SampleState);
SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState);
SAFE_RELEASE(GuiPass.IAStage.Layout);
}
SAFE_RELEASE(Gui::Pass.IAStage.Layout);
}
}
}

View File

@ -0,0 +1,91 @@
#pragma once
#include "../Core/Core.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
class Resources
{
public:
static const int GBufferSize = 3;
static const int LBufferSize = 3;
static const int MaxLightSize = 100;
//! GBuffers
//! 0 = Diffuse + Glow
//! 1 = Normal + Spec
//! 2 = GUI
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
//! LBuffer
//! 0 = Diffuse
//! 1 = Specular
//! 2 = SSAO
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
struct RenderStates
{
static ID3D11RasterizerState* rs;
static ID3D11SamplerState** ss;
static ID3D11DepthStencilState* dsState;
};
struct Gather
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer ModelData;
static Core::Buffer AnimationData;
};
struct Light
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer LightConstantsData;
static Core::Buffer PointLightsData;
static ID3D11ShaderResourceView* PointLightView;
static ID3D11ShaderResourceView* SSAOKernel;
static ID3D11ShaderResourceView* SSAORandom;
};
struct Gui
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Data;
};
struct Blur
{
static Core::PipelineManager::RenderPass HorPass;
static Core::PipelineManager::RenderPass VertPass;
//Blur UAV and SRV
static ID3D11UnorderedAccessView* BufferUAV;
static ID3D11ShaderResourceView* BufferSRV;
};
static Core::PipelineManager::RenderPass PostPass;
static Core::Init::State Init();
static Core::Init::State InitShaders();
static Core::Init::State InitRenderStates();
static Core::Init::State InitBuffers();
static Core::Init::State InitViews();
static Core::Init::State InitPasses();
static void Clean();
};
}
}
}

View File

@ -1,53 +0,0 @@
#include "Debug.h"
#include "..\OysterGraphics\Definitions\GraphicalDefinition.h"
#ifdef _DEBUG
// /Bin/Executable/Tester ->
// /Code/OysterGraphics/Shader/HLSL
const std::wstring PathFromExeToCso = L"..\\Content\\Shaders\\";
const std::wstring PathFromExeToHlsl = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\";
const std::wstring VertexTransformDebug = L"TransformDebugVertex";
const std::wstring VertexDebug = L"DebugVertex";
const std::wstring PixelRed = L"DebugPixel";
const std::wstring PixelTexture = L"Texture";
const std::wstring ComputeDebug = L"Debug";
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;
namespace Oyster
{
namespace Graphics
{
namespace Render
{
//Shader::RenderPass Resources::Debug::obj;
Shader::RenderPass Resources::Debug::debugCompute;// = Shader::ShaderEffect();;
//Buffer Resources::Debug::ModelData = Buffer();
//Buffer Resources::Debug::VPData = Buffer();
//ID3D11ShaderResourceView* Resources::Debug::srv = NULL;
//ID3D11RenderTargetView* Resources::Debug::rtv = NULL;
Core::Init::State Resources::Debug::Init()
{
#pragma region LoadShaders
/** Load Compute Shaders for d3dcompile */
Core::PipelineManager::Init(PathFromExeToHlsl + L"ComputeDebug\\" + L"DebugCompute.hlsl", ShaderType::Compute, ComputeDebug);
#pragma endregion
return Core::Init::Success;
}
void Resources::Debug::Clean()
{
}
}
}
}
#endif

View File

@ -1,39 +0,0 @@
#pragma once
#ifndef Reources_h
#define Reources_h
#ifdef _DEBUG
#include "../OysterGraphics/Core/Core.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
namespace Resources
{
class Debug
{
public:
//static Core::PipelineManager::RenderPass obj;
static Core::PipelineManager::RenderPass debugCompute;
//static Core::Buffer ModelData;
//static Core::Buffer VPData;
//static ID3D11ShaderResourceView* srv;
//static ID3D11RenderTargetView* rtv;
static Core::Init::State Init();
static void Clean();
};
}
}
}
}
#endif
#endif

View File

@ -1,69 +0,0 @@
#pragma once
#include "../../Core/Core.h"
namespace Oyster
{
namespace Graphics
{
namespace Render
{
namespace Resources
{
class Deffered
{
public:
static const int GBufferSize = 3;
static const int LBufferSize = 3;
static const int MaxLightSize = 100;
//! GBuffers
//! 0 = Diffuse + Glow
//! 1 = Normal + Spec
//! 2 = GUI
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
//! LBuffer
//! 0 = Diffuse
//! 1 = Specular
//! 2 = SSAO
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
//Blur UAV and SRV
static ID3D11UnorderedAccessView* BlurBufferUAV;
static ID3D11ShaderResourceView* BlurBufferSRV;
static Core::PipelineManager::RenderPass GeometryPass;
static Core::PipelineManager::RenderPass GuiPass;
static Core::PipelineManager::RenderPass LightPass;
static Core::PipelineManager::RenderPass BlurHorPass;
static Core::PipelineManager::RenderPass BlurVertPass;
static Core::PipelineManager::RenderPass PostPass;
static Core::Buffer ModelData;
static Core::Buffer AnimationData;
static Core::Buffer LightConstantsData;
static Core::Buffer PointLightsData;
static Core::Buffer GuiData;
static ID3D11ShaderResourceView* PointLightView;
static ID3D11ShaderResourceView* SSAOKernel;
static ID3D11ShaderResourceView* SSAORandom;
static Core::Init::State Init();
static Core::Init::State InitShaders();
static void Clean();
};
}
}
}
}

View File

@ -13,6 +13,6 @@ void main( uint3 DTid : SV_DispatchThreadID )
float4 Amb = float4(Ambient[DTid.xy/2].xyz,1);// * Ambient[DTid.xy/2].w,1);
//Output[DTid.xy] = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w */, 1);
//Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy];
//Output[DTid.xy] = Light + Amb * AmbFactor;
Output[DTid.xy] = Ambient[DTid.xy/2].w;
Output[DTid.xy] = Light + Amb * AmbFactor;
//Output[DTid.xy] = Ambient[DTid.xy/2].w;
}

View File

@ -160,18 +160,21 @@ HRESULT InitDirect3D()
{
return E_FAIL;
}
Oyster::Graphics::API::Option o = Oyster::Graphics::API::GetOption();
o.modelPath = L"..\\Content\\Models\\";
o.texturePath = L"..\\Content\\Textures\\";
Oyster::Graphics::API::SetOptions(o);
m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan");
/*m2 = Oyster::Graphics::API::CreateModel(L"T_reskinned.dan");
m2 = Oyster::Graphics::API::CreateModel(L"T_reskinned.dan");
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
m2->AnimationPlaying = 0;
m2->AnimationTime = 0.0f;*/
m2->AnimationTime = 0.0f;
//m3 = Oyster::Graphics::API::CreateModel(L"box_2.dan");
//m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000);
//P = Oyster::Math3D::ProjectionMatrix_Orthographic(10,10,.1f,10000);
Oyster::Graphics::API::SetProjection(P);
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f));
@ -179,7 +182,7 @@ HRESULT InitDirect3D()
Oyster::Graphics::Definitions::Pointlight pl;
pl.Color = Oyster::Math::Float3(1,1,1);
pl.Color = Oyster::Math::Float3(1,0,1);
pl.Bright = 1;
pl.Pos = Oyster::Math::Float3(0,-20.0f,0.4f);
pl.Radius = 90;
@ -192,15 +195,15 @@ HRESULT InitDirect3D()
float angle = 0;
HRESULT Update(float deltaTime)
{
angle += Oyster::Math::pi/16 * deltaTime;
m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle) * Oyster::Math3D::RotationMatrix_AxisX(-Oyster::Math::pi/2);
/*m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-Oyster::Math::pi/2,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;*/
//m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle);
//m->WorldMatrix = m->WorldMatrix * Oyster::Math3D::RotationMatrix_AxisX(-Oyster::Math::pi/2);
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-Oyster::Math::pi/2,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;
//ma *= 50;
//ma.m44 = 1;
//m2->WorldMatrix = m2->WorldMatrix * ma;
//m2->AnimationTime += deltaTime;// * 0.5f;
m2->AnimationTime += deltaTime;// * 0.5f;
//m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null);
return S_OK;
}
@ -211,7 +214,7 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::NewFrame();
Oyster::Graphics::API::RenderModel(*m);
//Oyster::Graphics::API::RenderModel(*m2);
Oyster::Graphics::API::RenderModel(*m2);
//Oyster::Graphics::API::RenderModel(*m3);
Oyster::Graphics::API::EndFrame();