diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp index edf6e7af..1b2e099a 100644 --- a/Code/Game/GameClient/DanBiasGame_Impl.cpp +++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp @@ -40,7 +40,7 @@ namespace DanBias { public: WindowShell* window; - Utility::WinTimer timer; + Utility::WinTimer timer, graphicalTimer; UniquePointer state; NetworkClient networkClient; @@ -155,11 +155,14 @@ namespace DanBias Oyster::Graphics::API::Option p; p.modelPath = L"..\\Content\\Models\\"; p.texturePath = L"..\\Content\\Textures\\"; - p.Resolution = Oyster::Math::Float2( 1920.0f, 1080.0f ); + p.resolution = Oyster::Math::Float2( 1920.0f, 1080.0f ); //! @todo fix proper amb value - p.AmbientValue = 1.3f; + p.ambientValue = 0.3f; + p.globalGlowTint = Math::Float3(1); + p.globalTint = Math::Float3(1); + p.fullscreen = false; - if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess) + if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, p) != Oyster::Graphics::API::Sucsess) return E_FAIL; return S_OK; } diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 0824d8bc..d6ebeafc 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -74,19 +74,10 @@ bool GameState::Init( SharedStateContent &shared ) this->privData->lights = &shared.lights; Graphics::API::Option gfxOp = Graphics::API::GetOption(); - Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; - this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 1.0f, 100.0f ); - - // HACK: debug test - Matrix debug_p = this->privData->camera.GetProjectionMatrix(); - Float debug_n = - debug_p.m34 / debug_p.m33; - Float debug_f = debug_p.m34 / (1.0f - debug_p.m33); + Float aspectRatio = gfxOp.resolution.x / gfxOp.resolution.y; + this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.5f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); - gfxOp.AmbientValue = 0.3f; - gfxOp.GlobalGlowTint = Math::Float3(1,1,1); - gfxOp.GlobalTint = Math::Float3(1,1,1); - Graphics::API::SetOptions(gfxOp); // DEGUG KEYS this->key_Reload_Shaders = false; diff --git a/Code/Game/GameClient/Include/DanBiasGame.h b/Code/Game/GameClient/Include/DanBiasGame.h index f6f0cdee..8213f879 100644 --- a/Code/Game/GameClient/Include/DanBiasGame.h +++ b/Code/Game/GameClient/Include/DanBiasGame.h @@ -45,6 +45,7 @@ namespace DanBias static DanBiasClientReturn Initiate(DanBiasGameDesc& desc); static DanBiasClientReturn Run(); static void Release(); + static HRESULT Render(); private: enum Result @@ -58,7 +59,6 @@ namespace DanBias static HRESULT InitInput( HWND handle ); static Result Update(float deltaTime); - static HRESULT Render(); static HRESULT CleanUp(); }; diff --git a/Code/OysterGraphics/Core/Core.cpp b/Code/OysterGraphics/Core/Core.cpp index 8cb4c5e0..0874e2cc 100644 --- a/Code/OysterGraphics/Core/Core.cpp +++ b/Code/OysterGraphics/Core/Core.cpp @@ -36,3 +36,7 @@ ID3D11RenderTargetView* Core::rtvNULL[8] = {0}; ID3D11UnorderedAccessView* Core::uavNULL[8] = {0}; int Core::UsedMem = 0; + +HWND Core::window = 0; + +bool Core::fullscreen = false; \ No newline at end of file diff --git a/Code/OysterGraphics/Core/Core.h b/Code/OysterGraphics/Core/Core.h index ae234ee4..79f63227 100644 --- a/Code/OysterGraphics/Core/Core.h +++ b/Code/OysterGraphics/Core/Core.h @@ -40,7 +40,8 @@ namespace Oyster //ViewPort static D3D11_VIEWPORT* viewPort; - static Oyster::Math::Float2 resolution; + static Oyster::Math::Float2 resolution; + static bool fullscreen; static ID3D11ShaderResourceView* srvNULL[16]; static ID3D11RenderTargetView* rtvNULL[8]; @@ -48,6 +49,8 @@ namespace Oyster static int UsedMem; + static HWND window; + class Buffer { public: @@ -250,11 +253,12 @@ namespace Oyster static State FullInit(HWND Window, bool MSAA_Quality, bool Fullscreen); - static State ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen); + static State ReInitialize(bool MSAA_Quality, bool Fullscreen, Math::Float2 Size); static State CreateLinkedShaderResourceFromTexture(ID3D11RenderTargetView** rtv, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav); static State CreateLinkedShaderResourceFromStructuredBuffer(Buffer** Structured, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav); + static State CreateLinkedShaderResourceFromStructuredBuffer(void* InitData, int numElem, int ElemSize, Buffer** Structured, ID3D11ShaderResourceView** srv, ID3D11UnorderedAccessView** uav); }; diff --git a/Code/OysterGraphics/Core/Init.cpp b/Code/OysterGraphics/Core/Init.cpp index 47731dbf..c9e2e07c 100644 --- a/Code/OysterGraphics/Core/Init.cpp +++ b/Code/OysterGraphics/Core/Init.cpp @@ -110,7 +110,7 @@ namespace Oyster if(Core::swapChain) { Core::swapChain->Release(); - Core::UsedMem -= desc.BufferDesc.Height * desc.BufferDesc.Width * 16; + Core::UsedMem -= Core::resolution.x * Core::resolution.y * 4; delete Core::swapChain; } @@ -168,7 +168,7 @@ namespace Oyster } dxgiFactory->Release(); - Core::UsedMem += desc.BufferDesc.Height * desc.BufferDesc.Width * 16; + Core::UsedMem += desc.BufferDesc.Height * desc.BufferDesc.Width * 4; return Init::Success; } @@ -188,7 +188,7 @@ namespace Oyster if(Core::depthStencil) { Core::depthStencil->Release(); - Core::UsedMem -= desc.Height * desc.Width * 4; + Core::UsedMem -= Core::resolution.x * Core::resolution.y * 4; delete Core::depthStencil; } @@ -327,12 +327,16 @@ namespace Oyster return Init::Fail; } + + Core::window = Window; + Core::fullscreen = Fullscreen; + return Init::Success; } - Core::Init::State Core::Init::ReInitialize(HWND Window, bool MSAA_Quality, bool Fullscreen) + Core::Init::State Core::Init::ReInitialize(bool MSAA_Quality, bool Fullscreen, Math::Float2 Size) { - if(Init::CreateSwapChain(Window, 1, MSAA_Quality, Fullscreen, Core::resolution) == Init::Fail) + if(Init::CreateSwapChain(Core::window, 1, MSAA_Quality, Fullscreen, Size) == Init::Fail) { return Init::Fail; } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 46145430..5efde879 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -31,13 +31,14 @@ namespace Oyster #endif } - API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, API::Option o) + API::State API::Init(HWND Window, bool MSAA_Quality, API::Option o) { - Core::resolution = o.Resolution; + Core::resolution = o.resolution; Core::modelPath = o.modelPath; Core::texturePath = o.texturePath; + Core::fullscreen = o.fullscreen; - if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail) + if(Core::Init::FullInit(Window, MSAA_Quality, o.fullscreen) == Core::Init::Fail) { return API::Fail; } @@ -45,7 +46,9 @@ namespace Oyster Render::Resources::Init(); Definitions::PostData pd; - pd.Amb = o.AmbientValue; + pd.Amb = o.ambientValue; + pd.GlowTint = o.globalGlowTint; + pd.Tint = o.globalTint; void* data = Render::Resources::Post::Data.Map(); memcpy(data,&pd,sizeof(Definitions::PostData)); @@ -127,14 +130,22 @@ namespace Oyster Core::texturePath = option.texturePath; Definitions::PostData pd; - pd.Amb = option.AmbientValue; - pd.Tint = option.GlobalTint; - pd.GlowTint = option.GlobalGlowTint; + pd.Amb = option.ambientValue; + pd.Tint = option.globalTint; + pd.GlowTint = option.globalGlowTint; void* data = Render::Resources::Post::Data.Map(); memcpy(data,&pd,sizeof(Definitions::PostData)); Render::Resources::Post::Data.Unmap(); + if(option.resolution != Core::resolution || option.fullscreen != Core::fullscreen) + { + //RESIZE + Core::Init::ReInitialize(false,option.fullscreen,option.resolution); + Core::fullscreen = option.fullscreen; + Core::resolution = option.resolution; + } + return API::Sucsess; } @@ -302,10 +313,11 @@ namespace Oyster API::Option API::GetOption() { Option o; - o.BytesUsed = Core::UsedMem; + o.bytesUsed = Core::UsedMem; o.modelPath = Core::modelPath; o.texturePath = Core::texturePath; - o.Resolution = Core::resolution; + o.resolution = Core::resolution; + o.fullscreen = Core::fullscreen; return o; } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 7f338cce..4fe0c281 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -28,19 +28,21 @@ namespace Oyster { std::wstring modelPath, texturePath; //between 0-1 - float AmbientValue; + float ambientValue; - Math::Float3 GlobalTint; - Math::Float3 GlobalGlowTint; + Math::Float3 globalTint; + Math::Float3 globalGlowTint; - Math::Float2 Resolution; + Math::Float2 resolution; //Bytes on the GPU - int BytesUsed; + int bytesUsed; + + bool fullscreen; }; typedef void* Texture; - static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options); + static State Init(HWND Window, bool MSAA_Quality, Option options); static void BeginLoadingModels(); diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 78d7975b..adec6575 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -93,18 +93,12 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uin PointLight pl = Points[lightIndex]; bool inFrustrum = true; - float d = dot(frustumPlanes[0], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); - d = dot(frustumPlanes[1], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); - d = dot(frustumPlanes[2], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); - d = dot(frustumPlanes[3], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); - d = dot(frustumPlanes[4], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); - d = dot(frustumPlanes[5], float4(pl.Pos, 1.0f)); - inFrustrum = inFrustrum && (d >= -pl.Radius); + [unroll] + for(int i = 0; i < 6; ++i) + { + float d = dot(frustumPlanes[i], float4(pl.Pos, 1.0f)); + inFrustrum = inFrustrum && (d >= -pl.Radius); + } [branch] if(inFrustrum) @@ -152,7 +146,8 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uin //Ambient[DTid.xy/2] = float4(DiffBase.xyz, 1); Ambient[DTid.xy/2 + float2(Diffuse.Length.x/2, 0)] = GUI[DTid.xy]; Ambient[DTid.xy/2 + float2(0, Diffuse.Length.y/2)] = float4(DiffBase.xyz * DiffBase.w ,DiffBase.w); - Ambient[DTid.xy/2 + Diffuse.Length.xy/2] = float4(numVisiblePointLights * (1.0f/Lights), 0, 0 ,1); + //Ambient[DTid.xy/2 + Diffuse.Length.xy/2] = float4(numVisiblePointLights * (1.0f/Lights), 0, 0 ,1); + Ambient[DTid.xy/2 + Diffuse.Length.xy/2] = float4(NormalSpec[DTid.xy/2].xyz ,1); } } \ 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 87c7c95a..2a498804 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -27,7 +27,7 @@ void main( uint3 DTid : SV_DispatchThreadID ) SSAO = SSAO / 16; - float4 Light = Diffuse[DTid.xy];// + saturate(Specular[DTid.xy]); + float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); float3 Amb = Ambient[DTid.xy/2].xyz * SSAO * Color; float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; @@ -43,6 +43,6 @@ void main( uint3 DTid : SV_DispatchThreadID ) //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1); //Output[DTid.xy] = SSAO * float4(1,1,1,1); - Output[DTid.xy] = Ambient[DTid.xy]; + //Output[DTid.xy] = Ambient[DTid.xy]; //Output[DTid.xy] = Diffuse[DTid.xy]; } \ No newline at end of file