Fix Pixel Data to Post Pass
This commit is contained in:
lanariel 2014-02-07 16:51:35 +01:00
parent 1de325c5a6
commit 1121bbdebf
8 changed files with 27 additions and 10 deletions

View File

@ -195,7 +195,7 @@ namespace Oyster
Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass); Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); 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); Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);

View File

@ -12,6 +12,7 @@ namespace Oyster
{ {
void Gui::BeginRender() void Gui::BeginRender()
{ {
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
} }
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size)
@ -32,7 +33,7 @@ namespace Oyster
void* data = Render::Resources::Gui::Data.Map(); void* data = Render::Resources::Gui::Data.Map();
memcpy(data,&gd,sizeof(gd)); memcpy(data,&gd,sizeof(Definitions::GuiData));
Render::Resources::Gui::Data.Unmap(); Render::Resources::Gui::Data.Unmap();
Core::deviceContext->Draw(1,0); Core::deviceContext->Draw(1,0);

View File

@ -32,7 +32,7 @@ namespace Oyster
Shader::RenderPass Resources::Gather::Pass; Shader::RenderPass Resources::Gather::Pass;
Shader::RenderPass Resources::Light::Pass; Shader::RenderPass Resources::Light::Pass;
Shader::RenderPass Resources::PostPass; Shader::RenderPass Resources::Post::Pass;
Shader::RenderPass Resources::Gui::Pass; Shader::RenderPass Resources::Gui::Pass;
Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur 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 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.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS;
desc.NumElements = 1; desc.NumElements = 1;
desc.ElementSize = sizeof(Definitions::GuiData); desc.ElementSize = sizeof(Definitions::GuiData);
Gui::Data.Init(desc);
desc.ElementSize = sizeof(Definitions::LightConstants); desc.ElementSize = sizeof(Definitions::LightConstants);
desc.NumElements = 1; desc.NumElements = 1;
@ -325,18 +326,19 @@ namespace Oyster
Light::Pass.SRV.Compute.push_back(Light::SSAORandom); Light::Pass.SRV.Compute.push_back(Light::SSAORandom);
////---------------- Post Pass Setup ---------------------------- ////---------------- Post Pass Setup ----------------------------
PostPass.Shaders.Compute = GetShader::Compute(L"PostPass"); Post::Pass.Shaders.Compute = GetShader::Compute(L"PostPass");
for(int i = 0; i<LBufferSize;++i) for(int i = 0; i<LBufferSize;++i)
{ {
PostPass.SRV.Compute.push_back(LBufferSRV[i]); Post::Pass.SRV.Compute.push_back(LBufferSRV[i]);
} }
PostPass.UAV.Compute.push_back(Core::backBufferUAV); Post::Pass.UAV.Compute.push_back(Core::backBufferUAV);
////---------------- GUI Pass Setup ---------------------------- ////---------------- GUI Pass Setup ----------------------------
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D"); Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D"); Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D"); Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
Gui::Pass.RTV.push_back(GBufferRTV[2]); Gui::Pass.RTV.push_back(GBufferRTV[2]);
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
D3D11_INPUT_ELEMENT_DESC indesc2D[] = D3D11_INPUT_ELEMENT_DESC indesc2D[] =
{ {

View File

@ -60,6 +60,7 @@ namespace Oyster
{ {
static Core::PipelineManager::RenderPass Pass; static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Data; static Core::Buffer Data;
static Core::Buffer Vertex;
}; };
struct Blur struct Blur
@ -73,8 +74,11 @@ namespace Oyster
static ID3D11ShaderResourceView* BufferSRV; static ID3D11ShaderResourceView* BufferSRV;
}; };
struct Post
static Core::PipelineManager::RenderPass PostPass; {
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Data;
};

View File

@ -2,5 +2,5 @@
float4 main(Pixel2DIn input) : SV_Target0 float4 main(Pixel2DIn input) : SV_Target0
{ {
return Material.Sample(LinearSampler,input.Uv); return float4(Material.Sample(LinearSampler,input.Uv).xyz,0.5);
} }

View File

@ -35,6 +35,7 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
{ {
float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2); float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2);
Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue); Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue);
Ambient[DTid.xy + Pixels/2] = GUI[DTid.xy];
} }
} }

View File

@ -4,6 +4,11 @@ Texture2D Ambient : register(t2);
RWTexture2D<float4> Output; RWTexture2D<float4> Output;
cbuffer Size : register(b0)
{
int2 Pixels;
}
#define AmbFactor 0.3f; #define AmbFactor 0.3f;
[numthreads(16, 16, 1)] [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] = 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].w;
Output[DTid.xy] = Ambient[DTid.xy/2 + Pixels/2];
} }

View File

@ -20,6 +20,7 @@ HWND g_hWnd = NULL;
Oyster::Graphics::Model::Model* m = NULL; Oyster::Graphics::Model::Model* m = NULL;
Oyster::Graphics::Model::Model* m2 = NULL; Oyster::Graphics::Model::Model* m2 = NULL;
Oyster::Graphics::Model::Model* m3 = NULL; Oyster::Graphics::Model::Model* m3 = NULL;
Oyster::Graphics::API::Texture t = NULL;
Oyster::Math::Float4x4 V; Oyster::Math::Float4x4 V;
Oyster::Math::Float4x4 P; Oyster::Math::Float4x4 P;
@ -173,6 +174,7 @@ HRESULT InitDirect3D()
//m3 = Oyster::Graphics::API::CreateModel(L"box_2.dan"); //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); //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); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000);
Oyster::Graphics::API::SetProjection(P); Oyster::Graphics::API::SetProjection(P);
@ -216,7 +218,8 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::RenderModel(*m); Oyster::Graphics::API::RenderModel(*m);
Oyster::Graphics::API::RenderModel(*m2); Oyster::Graphics::API::RenderModel(*m2);
//Oyster::Graphics::API::RenderModel(*m3); //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(); Oyster::Graphics::API::EndFrame();
return S_OK; return S_OK;