From adcac0ec129880ccd42f7cf28a0d07f4e69c84ff Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 14 Feb 2014 14:27:38 +0100 Subject: [PATCH] Random Updates --- Code/OysterGraphics/Core/PipelineManager.cpp | 1 + Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 4 ++++ Code/OysterGraphics/FileLoader/DanLoader.cpp | 7 ++++-- .../OysterGraphics/FileLoader/ModelLoader.cpp | 1 + .../Shader/Passes/2D/2DGeometry.hlsl | 8 +++---- .../Shader/Passes/2D/Text/2DTextGeometry.hlsl | 8 +++---- .../Shader/Passes/Light/LightPass.hlsl | 3 ++- .../Shader/Passes/Post/PostPass.hlsl | 5 ++-- Code/Tester/MainTest.cpp | 24 +++++++++---------- 9 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Code/OysterGraphics/Core/PipelineManager.cpp b/Code/OysterGraphics/Core/PipelineManager.cpp index d60c1641..9004ec3d 100644 --- a/Code/OysterGraphics/Core/PipelineManager.cpp +++ b/Code/OysterGraphics/Core/PipelineManager.cpp @@ -362,6 +362,7 @@ namespace Oyster } Core::deviceContext->RSSetState(se.RenderStates.Rasterizer); Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState); + Core::deviceContext->CSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState); Core::deviceContext->OMSetDepthStencilState(se.RenderStates.DepthStencil,0); float test[4] = {0}; Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1); diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 381b12cf..537ed63d 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -94,6 +94,8 @@ namespace Oyster if(!mi || mi->Vertices->GetBufferPointer() == NULL) { delete m; + Core::loader.ReleaseResource(mi); + delete mi; return NULL; } @@ -176,6 +178,8 @@ namespace Oyster float API::PlayAnimation(Model::Model* m, std::wstring name,bool looping) { + if(m==NULL) + return 0; m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second; m->Animation.AnimationTime=0; m->Animation.LoopAnimation = looping; diff --git a/Code/OysterGraphics/FileLoader/DanLoader.cpp b/Code/OysterGraphics/FileLoader/DanLoader.cpp index 69af2158..b6d8ed28 100644 --- a/Code/OysterGraphics/FileLoader/DanLoader.cpp +++ b/Code/OysterGraphics/FileLoader/DanLoader.cpp @@ -175,7 +175,6 @@ static void ReadData(void* Destination, std::ifstream& file, int size) /// void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) { - // Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo(); modelInfo->Indexed = false; modelInfo->Animated = false; @@ -184,7 +183,10 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) std::ifstream danFile; danFile.open(filename, std::ios::binary); if (!danFile.is_open()) + { + delete modelInfo; return NULL; + } // Read file header char* buffer = new char[sizeof(FileHeader)]; @@ -195,6 +197,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) // If problem with compatability then close file and return from method if (fileHeader.versionMajor != DANFILEVERSIONMAJOR) { + delete modelInfo; danFile.close(); return NULL; } @@ -290,7 +293,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) //read normal map name length ReadData(&materialHeader.normalMapPathLength,danFile,4); - //read difuse map name + //read normal map name materialHeader.normalMapPath = new char[materialHeader.normalMapPathLength + 1]; ReadData(materialHeader.normalMapPath,danFile,materialHeader.normalMapPathLength); materialHeader.normalMapPath[materialHeader.normalMapPathLength] = 0; diff --git a/Code/OysterGraphics/FileLoader/ModelLoader.cpp b/Code/OysterGraphics/FileLoader/ModelLoader.cpp index 96fa0362..ba0928cc 100644 --- a/Code/OysterGraphics/FileLoader/ModelLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ModelLoader.cpp @@ -645,6 +645,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice, if ( SUCCEEDED(hr) && ( fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN ) ) { autogen = true; + autogen = false; } } diff --git a/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl index 56b6294f..86fea579 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl @@ -4,19 +4,19 @@ void main(point Vertex2DIn input[1],inout TriangleStream Quads) { Pixel2DIn output; - output.Pos = mul(float4(-1,-1,0,1) ,Translation); + output.Pos = mul(float4(-1,-1,1,1) ,Translation); output.Uv = float2(0,1); Quads.Append(output); - output.Pos = mul(float4(-1,1,0,1), Translation); + output.Pos = mul(float4(-1,1,1,1), Translation); output.Uv = float2(0,0); Quads.Append(output); - output.Pos = mul(float4(1,-1,0,1), Translation); + output.Pos = mul(float4(1,-1,1,1), Translation); output.Uv = float2(1,1); Quads.Append(output); - output.Pos = mul(float4(1,1,0,1), Translation); + output.Pos = mul(float4(1,1,1,1), Translation); output.Uv = float2(1,0); Quads.Append(output); } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl index feefbed7..4e0bed02 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl @@ -7,22 +7,22 @@ void main(point Text2DIn input[1],inout TriangleStream Quads) float endoff=startoff+input[0].coff; Pixel2DIn output; - output.Pos = mul(float4(-1,-1,0,1), Translation); + output.Pos = mul(float4(-1,-1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(startoff,1); Quads.Append(output); - output.Pos = mul(float4(-1,1,0,1), Translation); + output.Pos = mul(float4(-1,1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(startoff,0); Quads.Append(output); - output.Pos = mul(float4(1,-1,0,1), Translation); + output.Pos = mul(float4(1,-1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(endoff,1); Quads.Append(output); - output.Pos = mul(float4(1,1,0,1), Translation); + output.Pos = mul(float4(1,1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(endoff,0); Quads.Append(output); diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 8e303455..3504a6a8 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -36,7 +36,8 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2); Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue); Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; - Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffuseGlow[DTid.xy].xyz * DiffuseGlow[DTid.xy].w*10,1); + Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffuseGlow[DTid.xy].xyz * DiffuseGlow[DTid.xy].w,1); + Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].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 85c74fb7..ba835e18 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -20,6 +20,7 @@ float4 SuperSample(float4 Glow, uint3 DTid) index += float2(0,Output.Length.y/2); index = index / Output.Length; Glow = Ambient.SampleLevel(S1, index,1); + Glow = Glow * Glow.w*10; //Line Y+1 //Glow += Ambient[DTid.xy/2 + uint2(1,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(0,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(-1,(Output.Length.y/2)+1)]; //Line Y-1 @@ -34,7 +35,7 @@ float4 SuperSample(float4 Glow, uint3 DTid) 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 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0); //float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; @@ -48,5 +49,5 @@ void main( uint3 DTid : SV_DispatchThreadID ) PostLight = PostLight * (1 - GUI.w); Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); - //Output[DTid.xy] = Glow; + //Output[DTid.xy] = Ambient[DTid.xy]; } \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index c6956971..d30529a8 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -170,19 +170,19 @@ HRESULT InitDirect3D() return E_FAIL; } - m = Oyster::Graphics::API::CreateModel(L"building_corporation.dan"); - m->WorldMatrix.m[0][0] = 0.0002f; - m->WorldMatrix.m[1][1] = 0.0002f; - m->WorldMatrix.m[2][2] = 0.0002f; - m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); + //m->WorldMatrix.m[0][0] = 0.0002f; + //m->WorldMatrix.m[1][1] = 0.0002f; + //m->WorldMatrix.m[2][2] = 0.0002f; + m2 = Oyster::Graphics::API::CreateModel(L"char_orca.dan"); m2->Tint = Oyster::Math::Float3(0.1f,0.1f,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); + m3 = Oyster::Graphics::API::CreateModel(L"char_orca.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); 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"); + t2 = Oyster::Graphics::API::CreateTexture(L"color_white.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -220,14 +220,14 @@ float angle = 0; HRESULT Update(float deltaTime) { //angle += Oyster::Math::pi/16 * deltaTime; - m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); + m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); 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; ma.m[0][0] = 0.2f; ma.m[1][1] = 0.2f; ma.m[2][2] = 0.2f; - m->WorldMatrix = m->WorldMatrix * ma; + //m->WorldMatrix = m->WorldMatrix * ma; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; @@ -242,7 +242,7 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m2); 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::Float3(0.5f,0.7f,0.1f),Oyster::Math::Float2(0.2f,0.2f), Oyster::Math::Float3(1,1,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; @@ -250,7 +250,7 @@ HRESULT Render(float 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::Float3(0.5f,0.1f,1.0f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float3(0.5f,0.1f,0.1f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0)); Oyster::Graphics::API::EndFrame(); return S_OK;