Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameClient

This commit is contained in:
lindaandersson 2014-02-20 08:44:03 +01:00
commit 80b2a9edd7
16 changed files with 72 additions and 51 deletions

View File

@ -106,9 +106,9 @@ namespace DanBias
Graphics::API::Update( dt ); Graphics::API::Update( dt );
data.capFrame += dt; data.capFrame += dt;
if(data.capFrame > 0.03) if(data.capFrame > 0.03f)
{ {
switch( Update(dt) ) switch( Update(data.capFrame) )
{ {
case Result_continue: break; case Result_continue: break;
case Result_quit: return DanBiasClientReturn_Success; case Result_quit: return DanBiasClientReturn_Success;
@ -117,7 +117,7 @@ namespace DanBias
} }
if(Render() != S_OK) if(Render() != S_OK)
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
data.capFrame = 0; data.capFrame -= 0.03f;
} }
if(data.networkClient.IsConnected()) if(data.networkClient.IsConnected())
@ -143,7 +143,7 @@ namespace DanBias
p.texturePath = L"..\\Content\\Textures\\"; p.texturePath = L"..\\Content\\Textures\\";
p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f ); p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f );
//! @todo fix proper amb value //! @todo fix proper amb value
p.AmbientValue = 1.0f; p.AmbientValue = 1.3f;
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess) if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess)
return E_FAIL; return E_FAIL;

View File

@ -20,5 +20,5 @@ bool C_Player::Init(ModelInitData modelInit)
void C_Player::playAnimation(std::wstring animation, bool loop) void C_Player::playAnimation(std::wstring animation, bool loop)
{ {
if(model) if(model)
Oyster::Graphics::API::PlayAnimation(model, L"movement", loop); Oyster::Graphics::API::PlayAnimation(model, animation, loop);
} }

View File

@ -89,6 +89,8 @@ bool GameState::Init( SharedStateContent &shared )
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
gfxOp.AmbientValue = 2.0f;
Graphics::API::SetOptions(gfxOp);
//tell server ready //tell server ready
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) ); this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
@ -105,6 +107,7 @@ bool GameState::Init( SharedStateContent &shared )
light->second->Render(); light->second->Render();
} }
return true; return true;
} }
@ -239,6 +242,7 @@ bool GameState::Render()
bool GameState::Release() bool GameState::Release()
{ {
Graphics::API::Option o = Graphics::API::GetOption();
if( privData ) if( privData )
{ {
auto staticObject = this->privData->staticObjects->begin(); auto staticObject = this->privData->staticObjects->begin();

View File

@ -77,7 +77,7 @@ Game::PlayerData* Game::CreatePlayer()
found = true; found = true;
freeID = i; freeID = i;
for(int j = 0; j < players.Size(); j++) for(int j = 0; j < (int)players.Size(); j++)
{ {
if(this->players[j] && this->players[j]->GetID() == freeID) if(this->players[j] && this->players[j]->GetID() == freeID)

View File

@ -209,7 +209,7 @@ bool Level::InitiateLevel(std::wstring levelPath)
//Convert from wstring to string //Convert from wstring to string
typedef std::codecvt_utf8<wchar_t> convert_typeX; typedef std::codecvt_utf8<wchar_t> convert_typeX;
std::wstring_convert<convert_typeX, wchar_t> converterX; std::wstring_convert<convert_typeX, wchar_t> converterX;
std::string convertedLevelPath = converterX.to_bytes(levelPath); std::string convertedLevelPath = converterX.to_bytes(levelPath);
objects = ll.LoadLevel(convertedLevelPath); objects = ll.LoadLevel(convertedLevelPath);
@ -220,7 +220,7 @@ bool Level::InitiateLevel(std::wstring levelPath)
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
API::Instance().SetGravity(200); API::Instance().SetGravity(200);
int objCount = objects.size(); int objCount = (int)objects.size();
for (int i = 0; i < objCount; i++) for (int i = 0; i < objCount; i++)
{ {

View File

@ -40,15 +40,15 @@ namespace Oyster
} }
inline unsigned int GetResourceSize() const inline unsigned int GetResourceSize() const
{ {
return this->resourceSize; return (unsigned int)this->resourceSize;
} }
inline unsigned int GetResourceElementSize() const inline unsigned int GetResourceElementSize() const
{ {
return this->resourceElementSize; return (unsigned int)this->resourceElementSize;
} }
inline unsigned int GetResourceID() const inline unsigned int GetResourceID() const
{ {
return this->resourceID; return (unsigned int)this->resourceID;
} }
inline void SetResourceID(int id) inline void SetResourceID(int id)
{ {

View File

@ -58,7 +58,7 @@ void Broadcast()
addr.append(buff); addr.append(buff);
dest.sin_addr.s_addr = inet_addr( addr.c_str() ); dest.sin_addr.s_addr = inet_addr( addr.c_str() );
// send the pkt // send the pkt
int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, sizeof(dest) ); int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, (int)sizeof(dest) );
} }
} }

View File

@ -205,9 +205,9 @@ namespace Oyster
void API::StartRenderWireFrame() void API::StartRenderWireFrame()
{ {
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); Core::deviceContext->OMSetRenderTargets((UINT)Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
Core::deviceContext->RSSetState(wire); Core::deviceContext->RSSetState(wire);
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); Core::deviceContext->OMSetRenderTargets((UINT)Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
} }
void API::RenderDebugCube(Math::Matrix world) void API::RenderDebugCube(Math::Matrix world)

View File

@ -146,7 +146,7 @@ namespace Oyster
return NULL; return NULL;
} }
#endif #endif
Core::UsedMem += data.size; Core::UsedMem += (int)data.size;
return Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type)); return Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type));
} }
} }

View File

@ -50,7 +50,12 @@ namespace Oyster
if(models[i].Visible) if(models[i].Visible)
{ {
Definitions::PerModel pm; Definitions::PerModel pm;
pm.WV = View * models[i].WorldMatrix.GetTranspose().GetInverse(); Math::Float3x3 normalTransform;
normalTransform = Math::Float3x3(models[i].WorldMatrix.v[0].xyz, models[i].WorldMatrix.v[1].xyz, models[i].WorldMatrix.v[2].xyz);
normalTransform.Transpose().Invert();
Math::Matrix m = Math::Matrix(Math::Vector4(normalTransform.v[0],0.0f), Math::Vector4(normalTransform.v[1],0.0f), Math::Vector4(normalTransform.v[2],0.0f), Math::Vector4(0.0f));
pm.WV = View * m;
//pm.WV = models[i].WorldMatrix.GetTranspose().GetInverse();
pm.WVP = Projection * View * models[i].WorldMatrix; pm.WVP = Projection * View * models[i].WorldMatrix;
Model::ModelInfo* info = models[i].info; Model::ModelInfo* info = models[i].info;
@ -159,10 +164,10 @@ namespace Oyster
{ {
Definitions::BlurrData bd; Definitions::BlurrData bd;
bd.BlurMask = Math::Float4(1,1,1,1); bd.BlurMask = Math::Float4(1,1,1,1);
bd.StopX = Core::resolution.x/2; bd.StopX = (UINT)Core::resolution.x/2;
bd.StopY = Core::resolution.y; bd.StopY = (UINT)Core::resolution.y;
bd.StartX = 0; bd.StartX = 0;
bd.StartY = Core::resolution.y/2; bd.StartY = (UINT)Core::resolution.y/2;
void* data = Resources::Blur::Data.Map(); void* data = Resources::Blur::Data.Map();
memcpy(data,&bd,sizeof(Definitions::BlurrData)); memcpy(data,&bd,sizeof(Definitions::BlurrData));
@ -179,8 +184,8 @@ namespace Oyster
{ {
Definitions::BlurrData bd; Definitions::BlurrData bd;
bd.BlurMask = Math::Float4(0,0,0,1); bd.BlurMask = Math::Float4(0,0,0,1);
bd.StopX = Core::resolution.x/2; bd.StopX = (UINT)Core::resolution.x/2;
bd.StopY = Core::resolution.y/2; bd.StopY = (UINT)Core::resolution.y/2;
bd.StartX = 0; bd.StartX = 0;
bd.StartY = 0; bd.StartY = 0;

View File

@ -103,7 +103,7 @@ namespace Oyster
Resources::Gui::Text::Vertex.Unmap(); Resources::Gui::Text::Vertex.Unmap();
Core::deviceContext->Draw(text.length(), 0); Core::deviceContext->Draw((UINT)text.length(), 0);
} }
} }
} }

View File

@ -349,9 +349,6 @@ namespace Oyster
Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth); Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth);
depthstencil->Release(); depthstencil->Release();
D3D11_DEPTH_STENCIL_DESC dDesc;
return Core::Init::Success; return Core::Init::Success;
} }

View File

@ -17,8 +17,8 @@ float3x3 cotangent_frame( float3 N, float3 p, float2 uv )
float3 B = dp2perp * duv1.y + dp1perp * duv2.y; float3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// construct a scale-invariant frame // construct a scale-invariant frame
float invmax = 1/sqrt( max( dot(T,T), dot(B,B) ) ); float invmax = rsqrt( max( dot(T,T), dot(B,B) ) );
return float3x3( T * invmax, B * invmax, N ); return transpose(float3x3( T * invmax, B * invmax, N ));
} }
float3 perturb_normal( float3 N, float3 V, float2 texcoord ) float3 perturb_normal( float3 N, float3 V, float2 texcoord )
@ -41,11 +41,20 @@ PixelOut main(VertexOut input)
{ {
PixelOut output; PixelOut output;
output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1); output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1);
float3 normal = normalize(input.normal);
normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV ); //NORMALIZE
float3x3 CoTangentFrame = cotangent_frame(input.normal, normalize(input.ViewPos), input.UV);
//output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255); float3 map = Normal.Sample(S1,input.UV).xyz;
output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*0); //map = normalize((map * 2) -1);
map = map * 255./127. - 128./127.;
//map = map * 255;
float3 normal = normalize(mul(CoTangentFrame, map));
//normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV );
output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255);
//output.NormalSpec = float4(input.normal, Normal.Sample(S1, input.UV).w * 0);
//output.NormalSpec = float4(map,0);
return output; return output;
} }

View File

@ -11,7 +11,7 @@ VertexOut main( VertexIn input )
input.pos = mul(boneTrans,float4(input.pos,1)).xyz * Animated + input.pos * int(1-Animated); input.pos = mul(boneTrans,float4(input.pos,1)).xyz * Animated + input.pos * int(1-Animated);
input.normal = mul(boneTrans,float4(input.normal,1)).xyz * Animated + input.normal * int(1-Animated); input.normal = mul(boneTrans,float4(input.normal,0)).xyz * Animated + input.normal * int(1-Animated);
output.pos = mul(WVP, float4(input.pos,1)); output.pos = mul(WVP, float4(input.pos,1));
output.ViewPos = mul(WV, float4(input.pos,1)); output.ViewPos = mul(WV, float4(input.pos,1));

View File

@ -39,10 +39,16 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
DiffBase += DiffuseGlow[DTid.xy + uint2(0,1)]; DiffBase += DiffuseGlow[DTid.xy + uint2(0,1)];
DiffBase += DiffuseGlow[DTid.xy + uint2(1,1)]; DiffBase += DiffuseGlow[DTid.xy + uint2(1,1)];
DiffBase = DiffBase / 4; DiffBase = DiffBase / 4;
float4 DepthBase = DepthTexture[DTid.xy];
DepthBase = DepthTexture[DTid.xy + uint2(1,0)];
DepthBase = DepthTexture[DTid.xy + uint2(0,1)];
DepthBase = DepthTexture[DTid.xy + uint2(1,1)];
DepthBase = DepthBase /4;
Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue); Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue);
Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy];
Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w,1); Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w * 10 /* * (2-DepthBase) */,1);
Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz,1); Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1);
} }
} }

View File

@ -11,33 +11,33 @@ cbuffer Size : register(b0)
float AmbFactor; float AmbFactor;
} }
float4 SuperSample(float4 Glow, uint3 DTid)
{
// Line X
float2 index = (float2)(DTid.xy/2);
index += float2(0,Output.Length.y/2);
index = index / Output.Length;
Glow = Ambient.SampleLevel(S1, index,1);
Glow = Glow;
return Glow;
}
[numthreads(16, 16, 1)] [numthreads(16, 16, 1)]
void main( uint3 DTid : SV_DispatchThreadID ) void main( uint3 DTid : SV_DispatchThreadID )
{ {
float SSAO = 0;
for(int x = 0; x < 4; ++x)
{
for(int y = 0; y < 4; ++y)
{
SSAO += Ambient[DTid.xy/2 + uint2(-2+x,-2+y)].w;
}
}
SSAO = SSAO / 16;
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0); float3 Amb = Ambient[DTid.xy/2].xyz * SSAO;
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz;
float4 GUI; float4 GUI;
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0); uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
float3 PostLight = Amb.xyz * AmbFactor; float3 PostLight = Amb * AmbFactor;
PostLight = PostLight + Light.xyz + Glow; PostLight = PostLight + Light.xyz + Glow;
GUI = float4(Ambient[index]); GUI = float4(Ambient[index]);
PostLight = PostLight * (1 - GUI.w); PostLight = PostLight * (1 - GUI.w);
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1); //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1);
//Output[DTid.xy] = Ambient[DTid.xy]; //Output[DTid.xy] = SSAO * float4(1,1,1,1);
} }