diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj
index 5d92df15..4ade9218 100644
--- a/Code/OysterGraphics/OysterGraphics.vcxproj
+++ b/Code/OysterGraphics/OysterGraphics.vcxproj
@@ -242,6 +242,26 @@
Pixel
Pixel
+
+ Compute
+ 5.0
+ Compute
+ 4.0
+ Compute
+ 4.0
+ Compute
+ 4.0
+
+
+ Compute
+ 5.0
+ Compute
+ 4.0
+ Compute
+ 4.0
+ Compute
+ 4.0
+
Compute
5.0
@@ -304,6 +324,7 @@
+
diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters
index 67e2ce46..643249c4 100644
--- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters
+++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters
@@ -105,6 +105,8 @@
+
+
@@ -114,5 +116,6 @@
+
\ No newline at end of file
diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
index 24059331..3058a25d 100644
--- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
+++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp
@@ -209,6 +209,12 @@ namespace Oyster
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
+ Core::PipelineManager::SetRenderPass(Resources::Deffered::BlurHorPass);
+ Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
+
+ Core::PipelineManager::SetRenderPass(Resources::Deffered::BlurVertPass);
+ Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
+
Core::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
diff --git a/Code/OysterGraphics/Render/Resources/Deffered.cpp b/Code/OysterGraphics/Render/Resources/Deffered.cpp
index e897e0fa..adc80eca 100644
--- a/Code/OysterGraphics/Render/Resources/Deffered.cpp
+++ b/Code/OysterGraphics/Render/Resources/Deffered.cpp
@@ -28,11 +28,16 @@ namespace Oyster
ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0};
+
+ ID3D11UnorderedAccessView* Deffered::BlurBufferUAV = {0};
+ ID3D11ShaderResourceView* Deffered::BlurBufferSRV = {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
Buffer Deffered::ModelData = Buffer();
Buffer Deffered::AnimationData = Buffer();
@@ -66,6 +71,8 @@ namespace Oyster
path = PathToHLSL+L"Post\\";
#endif
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
+ Core::PipelineManager::Init(path + L"BlurHor" + end, ShaderType::Compute, L"BlurHor");
+ Core::PipelineManager::Init(path + L"BlurVert" + end, ShaderType::Compute, L"BlurVert");
#ifdef _DEBUG
path = PathToHLSL+L"2D\\";
#endif
@@ -328,6 +335,20 @@ namespace Oyster
GuiPass.RenderStates.SampleCount = 1;
GuiPass.RenderStates.SampleState = ss;
+ ////---------------- Blur Pass Setup ----------------------------
+ BlurHorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
+ BlurVertPass.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]);
+ //Output texture is the Blur UAV buffer
+ BlurHorPass.UAV.Compute.push_back(BlurBufferUAV);
+
+ //Taking the Blur SRV and setting it as input texture now
+ BlurVertPass.SRV.Compute.push_back(BlurBufferSRV);
+ //And the Ambient UAV is now the output texture
+ BlurVertPass.UAV.Compute.push_back(LBufferUAV[2]);
+
return Core::Init::State::Success;
}
@@ -342,6 +363,9 @@ namespace Oyster
SAFE_RELEASE(Deffered::SSAOKernel);
SAFE_RELEASE(Deffered::SSAORandom);
+ SAFE_RELEASE(BlurBufferSRV);
+ SAFE_RELEASE(BlurBufferUAV);
+
for(int i = 0; i< GBufferSize; ++i)
{
SAFE_RELEASE(GBufferRTV[i]);
diff --git a/Code/OysterGraphics/Render/Resources/Deffered.h b/Code/OysterGraphics/Render/Resources/Deffered.h
index a1ae6c4f..72fa039f 100644
--- a/Code/OysterGraphics/Render/Resources/Deffered.h
+++ b/Code/OysterGraphics/Render/Resources/Deffered.h
@@ -32,9 +32,15 @@ namespace Oyster
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;
diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurHor.hlsl b/Code/OysterGraphics/Shader/Passes/Post/BlurHor.hlsl
new file mode 100644
index 00000000..7489cd41
--- /dev/null
+++ b/Code/OysterGraphics/Shader/Passes/Post/BlurHor.hlsl
@@ -0,0 +1,33 @@
+#include "BlurSharedData.hlsli"
+
+[numthreads(N,1,1)]
+void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID)
+{
+
+ if(gThreadID.x < blurRadius)
+ {
+ int x = max(ThreadID.x-blurRadius,0);
+ gCache[gThreadID.x] = inTex[int2(x,ThreadID.y)];
+ }
+ if(gThreadID.x >= N-blurRadius)
+ {
+ int x = min(ThreadID.x+blurRadius,inTex.Length.x-1);
+ gCache[gThreadID.x+2*blurRadius] = inTex[int2(x,ThreadID.y)];
+ }
+ gCache[gThreadID.x+blurRadius] = inTex[min(ThreadID.xy,inTex.Length.xy-1)];
+
+ GroupMemoryBarrierWithGroupSync();
+
+ float4 blurCol = float4(0,0,0,0);
+
+ [unroll]
+ for(int i = -blurRadius; i <= blurRadius;++i)
+ {
+ int k = gThreadID.x + blurRadius + i;
+ blurCol +=Weights[i + blurRadius] * gCache[k];
+ }
+
+ outTex[ThreadID.xy] = blurCol;
+ //Output[ThreadID.xy] = Diffuse[((ThreadID.xy))];
+}
+
diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurSharedData.hlsli b/Code/OysterGraphics/Shader/Passes/Post/BlurSharedData.hlsli
new file mode 100644
index 00000000..8a7b5fd1
--- /dev/null
+++ b/Code/OysterGraphics/Shader/Passes/Post/BlurSharedData.hlsli
@@ -0,0 +1,35 @@
+#ifndef BLURSHAREDDATA
+#define BLURSHAREDDATA
+
+
+
+static const float Weights[9] =
+{
+ 0.05f, 0.05f, 0.1f, 0.15f, 0.3f, 0.15f, 0.1f, 0.05f, 0.05f
+};
+
+static const int blurRadius = 4;
+
+#define N 128
+#define gSize (N+2*blurRadius)
+groupshared float4 gCache[gSize];
+
+Texture2D inTex : register(t0);
+RWTexture2D outTex : register(u0);
+
+//cbuffer BlurrData : register(c0)
+//{
+// static const int blurRadius = 5;
+// static const float Weights[11] =
+// {
+// 0.05f,0.05f,0.1f,0.1f,0.1f,0.2f,0.1f,0.1f,0.1f,0.05f,0.05f
+// };
+//};
+
+//[numthreads(16,16,1)]
+//void TryCompute(uint3 ThreadID : SV_DispatchThreadID)
+//{
+// Output[ThreadID.xy] = Diffuse[ThreadID.xy]*0.5f+Glow[ThreadID.xy]*Glow[ThreadID.xy].w;
+//}
+
+#endif
\ No newline at end of file
diff --git a/Code/OysterGraphics/Shader/Passes/Post/BlurVert.hlsl b/Code/OysterGraphics/Shader/Passes/Post/BlurVert.hlsl
new file mode 100644
index 00000000..aa5e4a27
--- /dev/null
+++ b/Code/OysterGraphics/Shader/Passes/Post/BlurVert.hlsl
@@ -0,0 +1,32 @@
+#include "BlurSharedData.hlsli"
+
+[numthreads(1,N,1)]
+void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID)
+{
+
+ if(gThreadID.y < blurRadius)
+ {
+ int y = max(ThreadID.y-blurRadius,0);
+ gCache[gThreadID.y] = inTex[int2(ThreadID.x,y)];
+ }
+ if(gThreadID.y >= N-blurRadius)
+ {
+ int y = min(ThreadID.y+blurRadius,inTex.Length.y-1);
+ gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y)];
+ }
+ gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy,inTex.Length.xy-1)];
+
+ GroupMemoryBarrierWithGroupSync();
+
+ float4 blurCol = float4(0,0,0,0);
+
+ [unroll]
+ for(int i = -blurRadius; i <= blurRadius;++i)
+ {
+ int k = gThreadID.y + blurRadius + i;
+ blurCol +=Weights[i + blurRadius] * gCache[k];
+ }
+
+ outTex[ThreadID.xy] = blurCol;
+ //Output[ThreadID.xy] = inTex[((ThreadID.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 b3abc0df..3956d9b6 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 99ba7b76..0c4262dc 100644
--- a/Code/Tester/MainTest.cpp
+++ b/Code/Tester/MainTest.cpp
@@ -161,11 +161,11 @@ HRESULT InitDirect3D()
return E_FAIL;
}
- m = Oyster::Graphics::API::CreateModel(L"untitled.dan");
- m2 = Oyster::Graphics::API::CreateModel(L"T_reskinned.dan");
+ m = Oyster::Graphics::API::CreateModel(L"crate_colonists.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);
@@ -194,13 +194,13 @@ 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) * 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;
}
@@ -210,8 +210,8 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::SetView(V);
Oyster::Graphics::API::NewFrame();
- //Oyster::Graphics::API::RenderModel(*m);
- Oyster::Graphics::API::RenderModel(*m2);
+ Oyster::Graphics::API::RenderModel(*m);
+ //Oyster::Graphics::API::RenderModel(*m2);
//Oyster::Graphics::API::RenderModel(*m3);
Oyster::Graphics::API::EndFrame();