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

This commit is contained in:
Pontus Fransson 2014-02-12 09:11:11 +01:00
commit 291e60d7b4
7 changed files with 55 additions and 44 deletions

View File

@ -50,11 +50,11 @@ namespace Oyster
{
if(Lights.size())
{
Render::DefaultRenderer::NewFrame(View, Projection, Lights[0], (int)Lights.size());
Render::DefaultRenderer::NewFrame(View, Projection, &Lights[0], (int)Lights.size());
}
else
{
Render::DefaultRenderer::NewFrame(View, Projection, Definitions::Pointlight(), 0);
Render::DefaultRenderer::NewFrame(View, Projection, NULL, 0);
}
}
@ -178,7 +178,7 @@ namespace Oyster
m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second;
m->Animation.AnimationTime=0;
m->Animation.LoopAnimation = looping;
return m->Animation.AnimationPlaying->duration;
return (float)m->Animation.AnimationPlaying->duration;
}
void API::Update(float dt)

View File

@ -14,11 +14,12 @@ namespace Oyster
{
Definitions::Pointlight pl;
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights)
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
{
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0));
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass);
Lights[1];
void* data;
@ -35,12 +36,12 @@ namespace Oyster
Resources::Light::LightConstantsData.Unmap();
data = Resources::Light::PointLightsData.Map();
memcpy(data, &Lights, sizeof(Definitions::Pointlight) * numLights);
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
Resources::Light::PointLightsData.Unmap();
Definitions::PostData pd;
pd.x = lc.Pixels.x;
pd.y = lc.Pixels.y;
pd.x = (int)lc.Pixels.x;
pd.y = (int)lc.Pixels.y;
data = Resources::Post::Data.Map();
memcpy(data, &pd, sizeof(Definitions::PostData));
@ -164,11 +165,11 @@ namespace Oyster
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
//Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass);
//Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
//Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass);
//Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Post::Pass);

View File

@ -13,7 +13,7 @@ namespace Oyster
class DefaultRenderer
{
public:
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights);
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0);
static void EndFrame();
};

View File

@ -9,7 +9,7 @@ namespace Oyster
namespace Render
{
const int TEXT_NR_LETTERS=95;
const float TEXT_SIZE=2.5;
const float TEXT_SPACING=1.8f;
void Gui::Begin2DRender()
{
@ -45,37 +45,21 @@ namespace Oyster
void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size)
{
//Pos.x -= instance.sizeX/2;
//Pos.x += size.x;
//Pos.y -= instance.sizeY/2;
//Pos.y += size.y;
//Matrix m;
//m = Math::Matrix::identity;
//float width = (1.0f/(instance.sizeX/2.0f));
//float height = (1.0f/(instance.sizeY/2.0f));
//m.m41=Pos.x * width;
//m.m42=-Pos.y * height;
//m.m43=Pos.z;
//m.m11=width*size.x;
//m.m22=height*size.y;
//void* dest = Resources::Buffers::CBufferGs.Map();
//memcpy(dest,&m.GetTranspose(),64);
//Resources::Buffers::CBufferGs.Unmap();
//Oyster::Render::Textbox::Update(text, size.x);
//Oyster::Engine::PrepareForRendering::Begin2DTextRender();
//Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&(Oyster::Render::Textbox::Texture));
////Should be able to be outside of the for loop. Keeping it here for now though.
//Oyster::Core::DeviceContext->Draw(Oyster::Render::Textbox::NumLetters, 0);
size.x = size.x / (text.length() * TEXT_SPACING /2);
pos *= 2;
pos -= 1;
pos.y *= -1;
pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2);
Definitions::GuiData gd;
gd.Translation = Math::Matrix::identity;
gd.Translation.m41 = (pos.x - (size.x/2 * text.length()));
gd.Translation.m41 = pos.x;
gd.Translation.m42 = pos.y;
gd.Translation.m11 = size.x;
gd.Translation.m22 = size.y;
@ -93,7 +77,7 @@ namespace Oyster
{
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
tmpInst.offset=text[i]-32;
tmpInst.pos=i*(size.x*2);
tmpInst.pos=i*(size.x * TEXT_SPACING);
//float tst=getCharID(_str[i]);
//tmpInst.offset=tst;
//tmpInst.charOffset.x=_pos.x-i*TEXT_SIZE;

View File

@ -163,8 +163,8 @@ namespace Oyster
D3D11_SAMPLER_DESC sdesc;
sdesc.Filter = D3D11_FILTER_ANISOTROPIC;
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
sdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
sdesc.MipLODBias = 0;
sdesc.MaxAnisotropy =4;
@ -389,6 +389,7 @@ namespace Oyster
Gui::Pass.RenderStates.SampleCount = 1;
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
////---------------- Blur Pass Setup ----------------------------
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");

View File

@ -17,7 +17,7 @@ void main( uint3 DTid : SV_DispatchThreadID )
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
float4 Amb = float4(Ambient[DTid.xy/2].xyz * Ambient[DTid.xy/2].w, 0);
float4 GUI;
uint2 index = DTid.xy/2 + int2(Pixels.x/2,0);
uint2 index = DTid.xy/2 + uint2(Pixels.x/2,0);
float3 PostLight = Amb.xyz * AmbFactor;
PostLight = PostLight + Light.xyz;
GUI = float4(Ambient[index]);

View File

@ -21,6 +21,7 @@ Oyster::Graphics::Model::Model* m = NULL;
Oyster::Graphics::Model::Model* m2 = NULL;
Oyster::Graphics::Model::Model* m3 = NULL;
Oyster::Graphics::API::Texture t = NULL;
Oyster::Graphics::API::Texture t2 = NULL;
Oyster::Math::Float4x4 V;
Oyster::Math::Float4x4 P;
Oyster::Graphics::Definitions::Pointlight pl;
@ -170,11 +171,15 @@ HRESULT InitDirect3D()
}
m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan");
m->WorldMatrix.m[0][0] = 50;
m->WorldMatrix.m[1][1] = 50;
m->WorldMatrix.m[2][2] = 0.00000005f;
m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
Oyster::Graphics::API::PlayAnimation(m2, L"movement",true);
t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png");
t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png");
P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000);
Oyster::Graphics::API::SetProjection(P);
@ -184,9 +189,23 @@ HRESULT InitDirect3D()
pl.Color = Oyster::Math::Float3(1,0,1);
pl.Color = Oyster::Math::Float3(1,0,0);
pl.Bright = 1;
pl.Pos = Oyster::Math::Float3(0,-20.0f,0.4f);
pl.Pos = Oyster::Math::Float3(-20,0,0);
pl.Radius = 90;
Oyster::Graphics::API::AddLight(pl);
pl.Color = Oyster::Math::Float3(0,1,0);
pl.Bright = 1;
pl.Pos = Oyster::Math::Float3(0,20,0);
pl.Radius = 90;
Oyster::Graphics::API::AddLight(pl);
pl.Color = Oyster::Math::Float3(0,0,1);
pl.Bright = 1;
pl.Pos = Oyster::Math::Float3(0,0,20);
pl.Radius = 90;
Oyster::Graphics::API::AddLight(pl);
@ -213,9 +232,15 @@ HRESULT Render(float deltaTime)
Oyster::Graphics::API::RenderModel(m);
Oyster::Graphics::API::RenderModel(m2);
Oyster::Graphics::API::StartGuiRender();
Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.8f,0.2f));
Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1));
Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
Oyster::Graphics::API::StartTextRender();
Oyster::Graphics::API::RenderText(L"Lanariel Was Here",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f));
std::wstring fps;
float f = 1/deltaTime;
fps = std::to_wstring(f);
//Oyster::Graphics::API::RenderText(L"Lanariel",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
//Oyster::Graphics::API::RenderText(L"Lanariel WAS HERE",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
//Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f));
Oyster::Graphics::API::EndFrame();
return S_OK;