First commit save jebuz

This commit is contained in:
Tobias Grundel 2014-02-07 13:46:55 +01:00
parent 5119b287d6
commit 016bf37459
10 changed files with 171 additions and 11 deletions

View File

@ -242,6 +242,26 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile> </FxCompile>
<FxCompile Include="Shader\Passes\Post\BlurHor.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\Passes\Post\BlurVert.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\Passes\Post\PostPass.hlsl"> <FxCompile Include="Shader\Passes\Post\PostPass.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel> <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
@ -304,6 +324,7 @@
<None Include="Shader\Passes\Light\PosManipulation.hlsli" /> <None Include="Shader\Passes\Light\PosManipulation.hlsli" />
<None Include="Shader\Passes\Light\SSAO.hlsli" /> <None Include="Shader\Passes\Light\SSAO.hlsli" />
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" /> <None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
<None Include="Shader\Passes\Post\BlurSharedData.hlsli" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -105,6 +105,8 @@
<FxCompile Include="Shader\Passes\2D\2DVertex.hlsl" /> <FxCompile Include="Shader\Passes\2D\2DVertex.hlsl" />
<FxCompile Include="Shader\Passes\2D\2DPixel.hlsl" /> <FxCompile Include="Shader\Passes\2D\2DPixel.hlsl" />
<FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" /> <FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" />
<FxCompile Include="Shader\Passes\Post\BlurVert.hlsl" />
<FxCompile Include="Shader\Passes\Post\BlurHor.hlsl" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" /> <None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
@ -114,5 +116,6 @@
<None Include="Shader\Passes\Light\SSAO.hlsli" /> <None Include="Shader\Passes\Light\SSAO.hlsli" />
<None Include="Shader\Passes\2D\Header.hlsli" /> <None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" /> <None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Post\BlurSharedData.hlsli" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -209,6 +209,12 @@ namespace Oyster
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::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::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
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

@ -28,11 +28,16 @@ namespace Oyster
ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0}; ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0};
ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0}; ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0};
ID3D11UnorderedAccessView* Deffered::BlurBufferUAV = {0};
ID3D11ShaderResourceView* Deffered::BlurBufferSRV = {0};
Shader::RenderPass Deffered::GeometryPass; Shader::RenderPass Deffered::GeometryPass;
Shader::RenderPass Deffered::LightPass; Shader::RenderPass Deffered::LightPass;
Shader::RenderPass Deffered::PostPass; Shader::RenderPass Deffered::PostPass;
Shader::RenderPass Deffered::GuiPass; 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::ModelData = Buffer();
Buffer Deffered::AnimationData = Buffer(); Buffer Deffered::AnimationData = Buffer();
@ -66,6 +71,8 @@ namespace Oyster
path = PathToHLSL+L"Post\\"; path = PathToHLSL+L"Post\\";
#endif #endif
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass"); 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 #ifdef _DEBUG
path = PathToHLSL+L"2D\\"; path = PathToHLSL+L"2D\\";
#endif #endif
@ -328,6 +335,20 @@ namespace Oyster
GuiPass.RenderStates.SampleCount = 1; GuiPass.RenderStates.SampleCount = 1;
GuiPass.RenderStates.SampleState = ss; 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; return Core::Init::State::Success;
} }
@ -342,6 +363,9 @@ namespace Oyster
SAFE_RELEASE(Deffered::SSAOKernel); SAFE_RELEASE(Deffered::SSAOKernel);
SAFE_RELEASE(Deffered::SSAORandom); SAFE_RELEASE(Deffered::SSAORandom);
SAFE_RELEASE(BlurBufferSRV);
SAFE_RELEASE(BlurBufferUAV);
for(int i = 0; i< GBufferSize; ++i) for(int i = 0; i< GBufferSize; ++i)
{ {
SAFE_RELEASE(GBufferRTV[i]); SAFE_RELEASE(GBufferRTV[i]);

View File

@ -32,9 +32,15 @@ namespace Oyster
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize]; static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize]; static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
//Blur UAV and SRV
static ID3D11UnorderedAccessView* BlurBufferUAV;
static ID3D11ShaderResourceView* BlurBufferSRV;
static Core::PipelineManager::RenderPass GeometryPass; static Core::PipelineManager::RenderPass GeometryPass;
static Core::PipelineManager::RenderPass GuiPass; static Core::PipelineManager::RenderPass GuiPass;
static Core::PipelineManager::RenderPass LightPass; static Core::PipelineManager::RenderPass LightPass;
static Core::PipelineManager::RenderPass BlurHorPass;
static Core::PipelineManager::RenderPass BlurVertPass;
static Core::PipelineManager::RenderPass PostPass; static Core::PipelineManager::RenderPass PostPass;

View File

@ -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))];
}

View File

@ -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<float4> 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

View File

@ -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))];
}

View File

@ -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); 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] = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w */, 1);
//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;
} }

View File

@ -161,11 +161,11 @@ HRESULT InitDirect3D()
return E_FAIL; return E_FAIL;
} }
m = Oyster::Graphics::API::CreateModel(L"untitled.dan"); 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->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
m2->AnimationPlaying = 0; m2->AnimationPlaying = 0;
m2->AnimationTime = 0.0f; m2->AnimationTime = 0.0f;*/
//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);
@ -194,13 +194,13 @@ HRESULT Update(float deltaTime)
{ {
angle += Oyster::Math::pi/16 * deltaTime; angle += Oyster::Math::pi/16 * deltaTime;
//m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle) * Oyster::Math3D::RotationMatrix_AxisX(-Oyster::Math::pi/2); 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); /*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; Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;*/
//ma *= 50; //ma *= 50;
//ma.m44 = 1; //ma.m44 = 1;
//m2->WorldMatrix = m2->WorldMatrix * ma; //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); //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; return S_OK;
} }
@ -210,8 +210,8 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::SetView(V); Oyster::Graphics::API::SetView(V);
Oyster::Graphics::API::NewFrame(); Oyster::Graphics::API::NewFrame();
//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::EndFrame(); Oyster::Graphics::API::EndFrame();