From 1de325c5a6ccd27ee58271f157d26e3794357ea5 Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 7 Feb 2014 15:52:07 +0100 Subject: [PATCH] Fixed cleaning up Deffered.cpp --- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 32 ++- Code/OysterGraphics/OysterGraphics.vcxproj | 18 +- .../OysterGraphics.vcxproj.filters | 30 +-- .../BasicRender.cpp => DefaultRenderer.cpp} | 53 ++-- Code/OysterGraphics/Render/DefaultRenderer.h | 25 ++ .../GuiRender.cpp => GuiRenderer.cpp} | 10 +- .../{Rendering/GuiRender.h => GuiRenderer.h} | 2 +- Code/OysterGraphics/Render/Rendering/Render.h | 29 --- .../{Resources/Deffered.cpp => Resources.cpp} | 232 ++++++++++-------- Code/OysterGraphics/Render/Resources.h | 91 +++++++ .../OysterGraphics/Render/Resources/Debug.cpp | 53 ---- Code/OysterGraphics/Render/Resources/Debug.h | 39 --- .../Render/Resources/Deffered.h | 69 ------ .../Shader/Passes/{Post => Blur}/BlurHor.hlsl | 0 .../{Post => Blur}/BlurSharedData.hlsli | 0 .../Passes/{Post => Blur}/BlurVert.hlsl | 0 .../Shader/Passes/Post/PostPass.hlsl | 4 +- Code/Tester/MainTest.cpp | 25 +- 18 files changed, 331 insertions(+), 381 deletions(-) rename Code/OysterGraphics/Render/{Rendering/BasicRender.cpp => DefaultRenderer.cpp} (78%) create mode 100644 Code/OysterGraphics/Render/DefaultRenderer.h rename Code/OysterGraphics/Render/{Rendering/GuiRender.cpp => GuiRenderer.cpp} (74%) rename Code/OysterGraphics/Render/{Rendering/GuiRender.h => GuiRenderer.h} (90%) delete mode 100644 Code/OysterGraphics/Render/Rendering/Render.h rename Code/OysterGraphics/Render/{Resources/Deffered.cpp => Resources.cpp} (61%) create mode 100644 Code/OysterGraphics/Render/Resources.h delete mode 100644 Code/OysterGraphics/Render/Resources/Debug.cpp delete mode 100644 Code/OysterGraphics/Render/Resources/Debug.h delete mode 100644 Code/OysterGraphics/Render/Resources/Deffered.h rename Code/OysterGraphics/Shader/Passes/{Post => Blur}/BlurHor.hlsl (100%) rename Code/OysterGraphics/Shader/Passes/{Post => Blur}/BlurSharedData.hlsli (100%) rename Code/OysterGraphics/Shader/Passes/{Post => Blur}/BlurVert.hlsl (100%) diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 36b8653f..06579b48 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -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 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 diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index 4ade9218..ca2e776b 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -181,9 +181,9 @@ - - - + + + @@ -194,10 +194,10 @@ - - + + - + @@ -242,7 +242,7 @@ Pixel Pixel - + Compute 5.0 Compute @@ -252,7 +252,7 @@ Compute 4.0 - + Compute 5.0 Compute @@ -324,7 +324,7 @@ - + diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters index 643249c4..4fcaee03 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters @@ -24,9 +24,6 @@ Source Files - - Source Files - Source Files @@ -42,16 +39,19 @@ Source Files - - Source Files - Source Files Source Files - + + Source Files + + + Source Files + + Source Files @@ -62,9 +62,6 @@ Header Files - - Header Files - Header Files @@ -86,10 +83,13 @@ Header Files - + Header Files - + + Header Files + + Header Files @@ -105,8 +105,8 @@ - - + + @@ -116,6 +116,6 @@ - + \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp similarity index 78% rename from Code/OysterGraphics/Render/Rendering/BasicRender.cpp rename to Code/OysterGraphics/Render/DefaultRenderer.cpp index 5e18419b..36e5475d 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -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 #include @@ -12,17 +12,15 @@ namespace Oyster { 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,25 +183,24 @@ 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); Core::swapChain->Present(0,0); } - } } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h new file mode 100644 index 00000000..5402f310 --- /dev/null +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -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; + }; + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/GuiRender.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp similarity index 74% rename from Code/OysterGraphics/Render/Rendering/GuiRender.cpp rename to Code/OysterGraphics/Render/GuiRenderer.cpp index f347daf2..dabb2a7b 100644 --- a/Code/OysterGraphics/Render/Rendering/GuiRender.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -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); } diff --git a/Code/OysterGraphics/Render/Rendering/GuiRender.h b/Code/OysterGraphics/Render/GuiRenderer.h similarity index 90% rename from Code/OysterGraphics/Render/Rendering/GuiRender.h rename to Code/OysterGraphics/Render/GuiRenderer.h index d7e25dd7..c722ae24 100644 --- a/Code/OysterGraphics/Render/Rendering/GuiRender.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -1,6 +1,6 @@ #pragma once -#include "../../Core/Core.h" +#include "../Core/Core.h" namespace Oyster { diff --git a/Code/OysterGraphics/Render/Rendering/Render.h b/Code/OysterGraphics/Render/Rendering/Render.h deleted file mode 100644 index f8ac7aed..00000000 --- a/Code/OysterGraphics/Render/Rendering/Render.h +++ /dev/null @@ -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; - }; - } - } - } -} \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources/Deffered.cpp b/Code/OysterGraphics/Render/Resources.cpp similarity index 61% rename from Code/OysterGraphics/Render/Resources/Deffered.cpp rename to Code/OysterGraphics/Render/Resources.cpp index adc80eca..b59b5844 100644 --- a/Code/OysterGraphics/Render/Resources/Deffered.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -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; @@ -20,38 +20,40 @@ namespace Oyster { 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 -// /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 \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources/Debug.h b/Code/OysterGraphics/Render/Resources/Debug.h deleted file mode 100644 index 3dc2fae2..00000000 --- a/Code/OysterGraphics/Render/Resources/Debug.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources/Deffered.h b/Code/OysterGraphics/Render/Resources/Deffered.h deleted file mode 100644 index 72fa039f..00000000 --- a/Code/OysterGraphics/Render/Resources/Deffered.h +++ /dev/null @@ -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(); - }; - } - } - } -} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurHor.hlsl b/Code/OysterGraphics/Shader/Passes/Blur/BlurHor.hlsl similarity index 100% rename from Code/OysterGraphics/Shader/Passes/Post/BlurHor.hlsl rename to Code/OysterGraphics/Shader/Passes/Blur/BlurHor.hlsl diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurSharedData.hlsli b/Code/OysterGraphics/Shader/Passes/Blur/BlurSharedData.hlsli similarity index 100% rename from Code/OysterGraphics/Shader/Passes/Post/BlurSharedData.hlsli rename to Code/OysterGraphics/Shader/Passes/Blur/BlurSharedData.hlsli diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurVert.hlsl b/Code/OysterGraphics/Shader/Passes/Blur/BlurVert.hlsl similarity index 100% rename from Code/OysterGraphics/Shader/Passes/Post/BlurVert.hlsl rename to Code/OysterGraphics/Shader/Passes/Blur/BlurVert.hlsl diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index 3956d9b6..b3abc0df 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -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; } \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index 0c4262dc..bdb9fe7f 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -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();