From e6e56ba21bfb69b3aaf73673f2cb69f2806740b2 Mon Sep 17 00:00:00 2001 From: lanariel Date: Mon, 10 Feb 2014 01:03:10 +0100 Subject: [PATCH] Done with 2D --- .../OysterGraphics/Definitions/GraphicalDefinition.h | 5 +++++ Code/OysterGraphics/Render/DefaultRenderer.cpp | 10 +++++++++- Code/OysterGraphics/Render/Resources.cpp | 12 +++++++----- .../Shader/Passes/Light/LightPass.hlsl | 3 ++- Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl | 10 ++++++++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 41420cce..7c0d76d7 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -61,6 +61,11 @@ namespace Oyster Math::Matrix Translation; }; + struct PostData + { + int x; + int y; + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 48cbdd74..45bd0630 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -19,7 +19,7 @@ namespace Oyster 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::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,1)); + Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0)); Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass); void* data; @@ -39,6 +39,14 @@ namespace Oyster data = Resources::Light::PointLightsData.Map(); memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights); Resources::Light::PointLightsData.Unmap(); + + Definitions::PostData pd; + pd.x = lc.Pixels.x; + pd.y = lc.Pixels.y; + + data = Resources::Post::Data.Map(); + memcpy(data, &pd, sizeof(Definitions::PostData)); + Resources::Post::Data.Unmap(); } Math::Matrix RecursiveBindPosRotation(int index, Model::ModelInfo* mi) diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 90bd1d53..f7b1144d 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -41,6 +41,7 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); + Buffer Resources::Post::Data = Buffer(); Buffer Resources::Light::PointLightsData = Buffer(); ID3D11ShaderResourceView* Resources::Light::PointLightView = NULL; @@ -109,10 +110,11 @@ namespace Oyster desc.ElementSize = sizeof(Definitions::GuiData); Gui::Data.Init(desc); - desc.ElementSize = sizeof(Definitions::LightConstants); - desc.NumElements = 1; desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_CS; - + desc.ElementSize = sizeof(Definitions::PostData); + Post::Data.Init(desc); + + desc.ElementSize = sizeof(Definitions::LightConstants); Light::LightConstantsData.Init(desc); desc.ElementSize = sizeof(Definitions::Pointlight); @@ -332,6 +334,7 @@ namespace Oyster Post::Pass.SRV.Compute.push_back(LBufferSRV[i]); } Post::Pass.UAV.Compute.push_back(Core::backBufferUAV); + Post::Pass.CBuffers.Compute.push_back(Post::Data); ////---------------- GUI Pass Setup ---------------------------- Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D"); @@ -379,8 +382,6 @@ namespace Oyster return Core::Init::State::Success; } - - void Resources::Clean() { Gather::ModelData.~Buffer(); @@ -388,6 +389,7 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); + Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); SAFE_RELEASE(Light::SSAOKernel); SAFE_RELEASE(Light::SSAORandom); diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 75a927c3..8c988f1f 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -35,7 +35,8 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) { float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2); Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue); - Ambient[DTid.xy + Pixels/2] = GUI[DTid.xy]; + Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; + //Ambient[DTid.xy] = GUI[DTid.xy]; } } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index 3f6ff9d5..78d6ebd1 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -18,7 +18,13 @@ 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] = Light + Amb * AmbFactor; //Output[DTid.xy] = Ambient[DTid.xy/2].w; - Output[DTid.xy] = Ambient[DTid.xy/2 + Pixels/2]; + float4 GUI; + uint2 index = DTid.xy/2 + int2(Pixels.x/2,0); + float3 PostLight = Light.xyz + Amb.xyz * AmbFactor; + GUI = float4(Ambient[index]); + PostLight = PostLight * (1-GUI.w); + //Output[DTid.xy] = float4((GUI.xyz * GUI.w) + ((Light + Amb * AmbFactor) * (1 - GUI.w)),0); + Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); } \ No newline at end of file