From 1121bbdebf51fe8a20c2b04b9647acd11743a76b Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 7 Feb 2014 16:51:35 +0100 Subject: [PATCH] TODO:: Fix Pixel Data to Post Pass --- Code/OysterGraphics/Render/DefaultRenderer.cpp | 2 +- Code/OysterGraphics/Render/GuiRenderer.cpp | 3 ++- Code/OysterGraphics/Render/Resources.cpp | 10 ++++++---- Code/OysterGraphics/Render/Resources.h | 8 ++++++-- Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl | 2 +- Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl | 1 + Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl | 6 ++++++ Code/Tester/MainTest.cpp | 5 ++++- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 36e5475d..48cbdd74 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -195,7 +195,7 @@ namespace Oyster 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::PostPass); + Core::PipelineManager::SetRenderPass(Resources::Post::Pass); Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index dabb2a7b..62b724cd 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -12,6 +12,7 @@ namespace Oyster { void Gui::BeginRender() { + Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); } void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) @@ -32,7 +33,7 @@ namespace Oyster void* data = Render::Resources::Gui::Data.Map(); - memcpy(data,&gd,sizeof(gd)); + memcpy(data,&gd,sizeof(Definitions::GuiData)); Render::Resources::Gui::Data.Unmap(); Core::deviceContext->Draw(1,0); diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index b59b5844..90bd1d53 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -32,7 +32,7 @@ namespace Oyster Shader::RenderPass Resources::Gather::Pass; Shader::RenderPass Resources::Light::Pass; - Shader::RenderPass Resources::PostPass; + Shader::RenderPass Resources::Post::Pass; 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 @@ -107,6 +107,7 @@ namespace Oyster desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS; desc.NumElements = 1; desc.ElementSize = sizeof(Definitions::GuiData); + Gui::Data.Init(desc); desc.ElementSize = sizeof(Definitions::LightConstants); desc.NumElements = 1; @@ -325,18 +326,19 @@ namespace Oyster Light::Pass.SRV.Compute.push_back(Light::SSAORandom); ////---------------- Post Pass Setup ---------------------------- - PostPass.Shaders.Compute = GetShader::Compute(L"PostPass"); + Post::Pass.Shaders.Compute = GetShader::Compute(L"PostPass"); for(int i = 0; i Output; +cbuffer Size : register(b0) +{ + int2 Pixels; +} + #define AmbFactor 0.3f; [numthreads(16, 16, 1)] @@ -15,4 +20,5 @@ void main( uint3 DTid : SV_DispatchThreadID ) //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] = Ambient[DTid.xy/2 + Pixels/2]; } \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index bdb9fe7f..a692688f 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -20,6 +20,7 @@ HWND g_hWnd = NULL; Oyster::Graphics::Model::Model* m = NULL; Oyster::Graphics::Model::Model* m2 = NULL; Oyster::Graphics::Model::Model* m3 = NULL; +Oyster::Graphics::API::Texture t = NULL; Oyster::Math::Float4x4 V; Oyster::Math::Float4x4 P; @@ -173,6 +174,7 @@ HRESULT InitDirect3D() //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); + t = Oyster::Graphics::API::CreateTexture(L"white.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -216,7 +218,8 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(*m); Oyster::Graphics::API::RenderModel(*m2); //Oyster::Graphics::API::RenderModel(*m3); - + Oyster::Graphics::API::StartGuiRender(); + Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.2f,0.2f)); Oyster::Graphics::API::EndFrame(); return S_OK;