diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index b8d8bbae..8cb80fe2 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -87,6 +87,7 @@ namespace Oyster m->WorldMatrix = Oyster::Math::Float4x4::identity; m->Visible = true; m->Animation.AnimationPlaying = NULL; + m->Tint = Math::Float3(1); m->info = (Model::ModelInfo*)Core::loader.LoadResource((Core::modelPath + filename).c_str(),Oyster::Graphics::Loading::LoadDAN, Oyster::Graphics::Loading::UnloadDAN); Model::ModelInfo* mi = (Model::ModelInfo*)m->info; diff --git a/Code/OysterGraphics/Model/Model.h b/Code/OysterGraphics/Model/Model.h index 590d7d6a..b264cf50 100644 --- a/Code/OysterGraphics/Model/Model.h +++ b/Code/OysterGraphics/Model/Model.h @@ -23,6 +23,7 @@ namespace Oyster { ModelInfo* info; Oyster::Math::Float4x4 WorldMatrix; + Oyster::Math::Float3 Tint; bool Visible; AnimationData Animation; }; diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index a92c54d6..8058cd60 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -138,6 +138,10 @@ namespace Oyster memcpy(data,&(pm),sizeof(pm)); Resources::Gather::ModelData.Unmap(); + data = Render::Resources::Color.Map(); + memcpy(data,&models[i].Tint,sizeof(Math::Float3)); + Render::Resources::Color.Unmap(); + if(info->Material.size()) { Core::deviceContext->PSSetShaderResources(0,(UINT)info->Material.size(),&(info->Material[0])); diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index fbdfa37c..7f3285e1 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -35,9 +35,9 @@ namespace Oyster memcpy(data,&gd,sizeof(Definitions::GuiData)); Render::Resources::Gui::Data.Unmap(); - data = Render::Resources::Gui::Color.Map(); + data = Render::Resources::Color.Map(); memcpy(data,&color,sizeof(Math::Float3)); - Render::Resources::Gui::Color.Unmap(); + Render::Resources::Color.Unmap(); Core::deviceContext->Draw(1,0); @@ -76,9 +76,9 @@ namespace Oyster Render::Resources::Gui::Data.Unmap(); Definitions::Text2D tmpInst; - data = Render::Resources::Gui::Color.Map(); + data = Render::Resources::Color.Map(); memcpy(data,&color,sizeof(Math::Float3)); - Render::Resources::Gui::Color.Unmap(); + Render::Resources::Color.Unmap(); void* dest = Resources::Gui::Text::Vertex.Map(); Definitions::Text2D* dataView = reinterpret_cast(dest); diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 73834071..77988417 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -45,7 +45,7 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); - Buffer Resources::Gui::Color = Buffer(); + Buffer Resources::Color = Buffer(); Buffer Resources::Gui::Text::Vertex = Buffer(); Buffer Resources::Post::Data = Buffer(); @@ -121,7 +121,7 @@ namespace Oyster desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS; desc.ElementSize = sizeof(Math::Float3); - Gui::Color.Init(desc); + Color.Init(desc); desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS; desc.NumElements = 1; @@ -342,6 +342,7 @@ namespace Oyster Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData); Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData); + Gather::Pass.CBuffers.Pixel.push_back(Color); Gather::Pass.RenderStates.Rasterizer = RenderStates::rs; Gather::Pass.RenderStates.SampleCount = 1; Gather::Pass.RenderStates.SampleState = RenderStates::ss; @@ -383,7 +384,7 @@ namespace Oyster Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D"); Gui::Pass.RTV.push_back(GBufferRTV[2]); Gui::Pass.CBuffers.Geometry.push_back(Gui::Data); - Gui::Pass.CBuffers.Pixel.push_back(Gui::Color); + Gui::Pass.CBuffers.Pixel.push_back(Color); D3D11_INPUT_ELEMENT_DESC indesc2D[] = { @@ -427,7 +428,7 @@ namespace Oyster Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout); Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data); - Gui::Text::Pass.CBuffers.Pixel.push_back(Gui::Color); + Gui::Text::Pass.CBuffers.Pixel.push_back(Color); Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font); Gui::Text::Pass.RTV.push_back(GBufferRTV[2]); Gui::Text::Pass.RenderStates.SampleCount = 1; @@ -455,7 +456,7 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); - Gui::Color.~Buffer(); + Color.~Buffer(); Gui::Text::Vertex.~Buffer(); Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); diff --git a/Code/OysterGraphics/Render/Resources.h b/Code/OysterGraphics/Render/Resources.h index d43b5756..684762fd 100644 --- a/Code/OysterGraphics/Render/Resources.h +++ b/Code/OysterGraphics/Render/Resources.h @@ -30,6 +30,9 @@ namespace Oyster static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize]; static ID3D11ShaderResourceView* LBufferSRV[LBufferSize]; + + static Core::Buffer Color; + struct RenderStates { @@ -61,7 +64,6 @@ namespace Oyster { static Core::PipelineManager::RenderPass Pass; static Core::Buffer Data; - static Core::Buffer Color; struct Text { static Core::PipelineManager::RenderPass Pass; diff --git a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl index 464da702..542d8c54 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl @@ -40,7 +40,7 @@ float3 perturb_normal( float3 N, float3 V, float2 texcoord ) PixelOut main(VertexOut input) { PixelOut output; - output.DiffuseGlow = Diffuse.Sample(S1, input.UV); + output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1); float3 normal = normalize(input.normal); normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV ); diff --git a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli index 14e0db5a..ea144417 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli @@ -41,4 +41,9 @@ cbuffer PerModel : register(b1) matrix WVP; int Animated; float3 Pad; +} + +cbuffer Tint : register(b0) +{ + float3 Color; } \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index 3813d3e9..2915d62e 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -175,9 +175,12 @@ HRESULT InitDirect3D() m->WorldMatrix.m[1][1] = 50; m->WorldMatrix.m[2][2] = 0.00000005f; m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m2->Tint = Oyster::Math::Float3(0.8f,0.8f,1); + m3 = 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"); - + Oyster::Graphics::API::PlayAnimation(m2, L"movement", true); + Oyster::Graphics::API::PlayAnimation(m3, L"movement", true); + t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png"); @@ -189,21 +192,21 @@ HRESULT InitDirect3D() - pl.Color = Oyster::Math::Float3(1,0,0); + pl.Color = Oyster::Math::Float3(1,1,1); pl.Bright = 1; 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.Color = Oyster::Math::Float3(1,1,1); 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.Color = Oyster::Math::Float3(1,1,1); pl.Bright = 1; pl.Pos = Oyster::Math::Float3(0,0,20); pl.Radius = 90; @@ -218,6 +221,7 @@ HRESULT Update(float deltaTime) { //angle += Oyster::Math::pi/16 * deltaTime; m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); + m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * -angle,Oyster::Math::Float3(-4,0,0),Oyster::Math::Float3::null); //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; @@ -231,8 +235,9 @@ 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(1,1)); + Oyster::Graphics::API::RenderModel(m3); + //Oyster::Graphics::API::StartGuiRender(); + //Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1), Oyster::Math::Float3(0,0,1)); //Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1),Oyster::Math::Float3(1,0,0)); Oyster::Graphics::API::StartTextRender(); std::wstring fps;