touched up SSAO and fixed wireframe rendering in release

This commit is contained in:
lanariel 2014-02-20 09:00:02 +01:00
parent 3b70e0baec
commit 745a3802dc
4 changed files with 67 additions and 47 deletions

View File

@ -89,7 +89,7 @@ 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; gfxOp.AmbientValue = 1.0f;
Graphics::API::SetOptions(gfxOp); Graphics::API::SetOptions(gfxOp);
//tell server ready //tell server ready
@ -193,45 +193,45 @@ bool GameState::Render()
}*/ }*/
// RB DEBUG render wire frame // RB DEBUG render wire frame
//if(this->privData->renderWhireframe) if(this->privData->renderWhireframe)
//{ {
// Oyster::Graphics::API::StartRenderWireFrame(); Oyster::Graphics::API::StartRenderWireFrame();
//
// Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
// Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
// Oyster::Math3D::Float4x4 world = translation * scale; Oyster::Math3D::Float4x4 world = translation * scale;
// Oyster::Graphics::API::RenderDebugCube( world ); Oyster::Graphics::API::RenderDebugCube( world );
// Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
//
// staticObject = this->privData->staticObjects->begin(); staticObject = this->privData->staticObjects->begin();
// for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
// { {
// if( staticObject->second->getBRtype() == RB_Type_Cube) if( staticObject->second->getBRtype() == RB_Type_Cube)
// { {
// Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld());
// } }
// if( staticObject->second->getBRtype() == RB_Type_Sphere) if( staticObject->second->getBRtype() == RB_Type_Sphere)
// { {
// Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld());
// } }
// } }
//
// dynamicObject = this->privData->dynamicObjects->begin(); dynamicObject = this->privData->dynamicObjects->begin();
// for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
// { {
// if( dynamicObject->second ) if( dynamicObject->second )
// { {
// if( dynamicObject->second->getBRtype() == RB_Type_Cube) if( dynamicObject->second->getBRtype() == RB_Type_Cube)
// { {
// Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
// } }
// if( dynamicObject->second->getBRtype() == RB_Type_Sphere) if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
// { {
// Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
// } }
// } }
// } }
//} }
// !RB DEBUG // !RB DEBUG
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
@ -487,7 +487,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
if( !Within(position.Dot(position), 2500.0f, 90000.0f) ) if( !Within(position.Dot(position), 2500.0f, 90000.0f) )
{ // HACK: bug trap { // HACK: bug trap
const char *breakPoint = "Something is wrong."; const char *breakPoint = "Something is wrong.";
//position = Float3( 0.0f, 160.0f, 0.0f ); position = Float3( 0.0f, 160.0f, 0.0f );
} }
this->privData->camera.SetPosition( position ); this->privData->camera.SetPosition( position );

View File

@ -154,7 +154,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2;
RBData.type = RB_Type_Cube; RBData.type = RB_Type_Cube;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
@ -163,7 +163,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2;
RBData.type = RB_Type_Sphere; RBData.type = RB_Type_Sphere;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
@ -198,7 +198,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2;
RBData.type = RB_Type_Cube; RBData.type = RB_Type_Cube;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }
@ -207,7 +207,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2;
RBData.type = RB_Type_Sphere; RBData.type = RB_Type_Sphere;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }

View File

@ -221,6 +221,26 @@ namespace Oyster
sphere->WorldMatrix = world; sphere->WorldMatrix = world;
Render::DefaultRenderer::RenderScene(sphere,1,View,Projection); Render::DefaultRenderer::RenderScene(sphere,1,View,Projection);
} }
#else
API::State API::ReloadShaders()
{
}
void API::StartRenderWireFrame()
{
}
void API::RenderDebugCube(Math::Matrix world)
{
}
void API::RenderDebugSphere(Math::Matrix world)
{
}
#endif #endif
API::Option API::GetOption() API::Option API::GetOption()

View File

@ -1,7 +1,7 @@
#include "Defines.hlsli" #include "Defines.hlsli"
#include "PosManipulation.hlsli" #include "PosManipulation.hlsli"
static float Radius = 100; static float Radius = 10;
float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID)
{ {
@ -41,7 +41,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID)
float sampleDepth = ViewPos.z; float sampleDepth = ViewPos.z;
//compare to depth from sample //compare to depth from sample
float rangeCheck = (abs(pos.z - sampleDepth) < Radius) ? 1.0f : 0.0f; float rangeCheck = (abs(pos.z - sampleDepth) > Radius) ? 1.0f : 0.0f;
occlusion += (sampleDepth <= sampled.z ? 1.0f : 0.0f) * rangeCheck; occlusion += (sampleDepth <= sampled.z ? 1.0f : 0.0f) * rangeCheck;
} }
occlusion /= (float)(SSAOKernel.Length.x); occlusion /= (float)(SSAOKernel.Length.x);