From 2de2ef9cd0e72fd61fc8cbb174b10eb996c6ca88 Mon Sep 17 00:00:00 2001 From: lanariel Date: Tue, 26 Nov 2013 13:44:58 +0100 Subject: [PATCH] Pre merge Commit --- Code/OysterGraphics/Core/Core.h | 2 +- .../Core/{CoreIncludes.h => Dx11Includes.h} | 0 .../Definitions/GraphicalDefinition.h | 2 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 34 +++++++++++++++ Code/OysterGraphics/DllInterfaces/GFXAPI.h | 36 ++++++++++++++++ .../DllInterfaces/SimpleInterface.h | 29 ------------- Code/OysterGraphics/FileLoader/ObjReader.cpp | 3 ++ .../FileLoader/TextureLoader.cpp | 7 ++++ .../OysterGraphics/FileLoader/TextureLoader.h | 13 ++++++ Code/OysterGraphics/OysterGraphics.vcxproj | 25 +++++++++-- .../OysterGraphics.vcxproj.filters | 25 +++++++---- .../Render/Rendering/BasicRender.cpp | 2 +- .../Render/Resources/Resources.cpp | 1 + .../Gather/PixelGatherData.hlsl | 25 ----------- .../Gather/VertexGatherData.hlsl | 37 ----------------- .../GatherGBuffer/GBufferHeader.hlsli | 41 +++++++++++++++++++ .../GatherGBuffer/PixelGatherData.hlsl | 9 ++++ .../GatherGBuffer/VertexGatherData.hlsl | 12 ++++++ .../HLSL/SimpleDebug/DebugCameraVertex.hlsl | 6 +-- Code/Tester/MainTest.cpp | 4 +- 20 files changed, 204 insertions(+), 109 deletions(-) rename Code/OysterGraphics/Core/{CoreIncludes.h => Dx11Includes.h} (100%) create mode 100644 Code/OysterGraphics/DllInterfaces/GFXAPI.cpp create mode 100644 Code/OysterGraphics/DllInterfaces/GFXAPI.h delete mode 100644 Code/OysterGraphics/DllInterfaces/SimpleInterface.h create mode 100644 Code/OysterGraphics/FileLoader/TextureLoader.cpp create mode 100644 Code/OysterGraphics/FileLoader/TextureLoader.h delete mode 100644 Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/PixelGatherData.hlsl delete mode 100644 Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/VertexGatherData.hlsl create mode 100644 Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/GBufferHeader.hlsli create mode 100644 Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/PixelGatherData.hlsl create mode 100644 Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/VertexGatherData.hlsl diff --git a/Code/OysterGraphics/Core/Core.h b/Code/OysterGraphics/Core/Core.h index fa56c7b9..4efb5b8d 100644 --- a/Code/OysterGraphics/Core/Core.h +++ b/Code/OysterGraphics/Core/Core.h @@ -4,7 +4,7 @@ #define Core_h -#include "CoreIncludes.h" +#include "Dx11Includes.h" #include #include "OysterMath.h" diff --git a/Code/OysterGraphics/Core/CoreIncludes.h b/Code/OysterGraphics/Core/Dx11Includes.h similarity index 100% rename from Code/OysterGraphics/Core/CoreIncludes.h rename to Code/OysterGraphics/Core/Dx11Includes.h diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 88f63fe2..177c6763 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -1,4 +1,4 @@ -#include "..\OysterGraphics\Core\CoreIncludes.h" +#include "..\OysterGraphics\Core\Dx11Includes.h" #include "OysterMath.h" namespace Oyster diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp new file mode 100644 index 00000000..d13adbc5 --- /dev/null +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -0,0 +1,34 @@ +#include "GFXAPI.h" +#include "../Core/Core.h" +#include "../Render/Resources/Resources.h" +#include "../Render/Rendering/Render.h" + +namespace Oyster +{ + namespace Graphics + { + API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen) + { + if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail) + { + return API::Fail; + } + if(Render::Resources::Init() == Core::Init::Fail) + { + return API::Fail; + } + return API::Sucsess; + } + + void API::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection) + { + Render::Rendering::Basic::NewFrame(View, Projection); + } + + void API::RenderScene(Model::Model* models, int count) + { + Render::Rendering::Basic::RenderScene(models,count); + } + + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h new file mode 100644 index 00000000..0200514a --- /dev/null +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -0,0 +1,36 @@ +#pragma once +#include +#include "..\Model\Model.h" +#include "OysterMath.h" +#include + + +namespace Oyster +{ + namespace Graphics + { + class API + { + public: + enum State + { + Sucsess, + Fail + }; + struct Option + { + }; + + State Init(HWND Window, bool MSAA_Quality, bool Fullscreen); + //! @brief from Oyster::Math Float4x4, expects corect methods + static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection); + static void RenderScene(Oyster::Graphics::Model::Model* models, int count); + static void EndFrame(); + + static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename); + static void DeleteModel(Oyster::Graphics::Model::Model* model); + + static State SetOptions(Option); + }; + } +} diff --git a/Code/OysterGraphics/DllInterfaces/SimpleInterface.h b/Code/OysterGraphics/DllInterfaces/SimpleInterface.h deleted file mode 100644 index a2591956..00000000 --- a/Code/OysterGraphics/DllInterfaces/SimpleInterface.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include "..\Model\Model.h" -#include "OysterMath.h" - - -class SimpleInterface -{ -public: - enum State - { - Sucsess, - Fail - }; - struct Option - { - }; - - State Init(HWND Window, bool MSAA_Quality, bool Fullscreen); - //! @brief from Oyster::Math Float4x4, expects corect methods - static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection); - static void RenderScene(Oyster::Graphics::Model::Model* models, int count); - static void EndFrame(); - - static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename); - static void DeleteModel(Oyster::Graphics::Model::Model* model); - - static State SetOptions(Option); -}; diff --git a/Code/OysterGraphics/FileLoader/ObjReader.cpp b/Code/OysterGraphics/FileLoader/ObjReader.cpp index 22a2ec2f..aa613710 100644 --- a/Code/OysterGraphics/FileLoader/ObjReader.cpp +++ b/Code/OysterGraphics/FileLoader/ObjReader.cpp @@ -2,6 +2,7 @@ #include "..\Definitions\GraphicalDefinition.h" #include #include +#include "TextureLoader.h" using namespace std; OBJReader::OBJReader() @@ -117,6 +118,8 @@ Oyster::Graphics::Model::ModelInfo* OBJReader::toModel() modelInfo->VertexCount = (int)desc.NumElements; modelInfo->Vertices = b; + //Oyster::Resource::OysterResource::LoadResource(L"Normal.png",(Oyster::Resource::CustomLoadFunction)Oyster::Graphics::Loading::LoadTexture); + return modelInfo; } diff --git a/Code/OysterGraphics/FileLoader/TextureLoader.cpp b/Code/OysterGraphics/FileLoader/TextureLoader.cpp new file mode 100644 index 00000000..24caeae3 --- /dev/null +++ b/Code/OysterGraphics/FileLoader/TextureLoader.cpp @@ -0,0 +1,7 @@ +#include "TextureLoader.h" +#include "..\Core\Dx11Includes.h" + +Oyster::Resource::CustomData* Oyster::Graphics::Loading::LoadTexture() +{ + return NULL; +} \ No newline at end of file diff --git a/Code/OysterGraphics/FileLoader/TextureLoader.h b/Code/OysterGraphics/FileLoader/TextureLoader.h new file mode 100644 index 00000000..a5148fb4 --- /dev/null +++ b/Code/OysterGraphics/FileLoader/TextureLoader.h @@ -0,0 +1,13 @@ +#pragma once +#include "..\..\Misc\Resource\OysterResource.h" +namespace Oyster +{ + namespace Graphics + { + namespace Loading + { + void UnloadTexture(); + Oyster::Resource::CustomData* LoadTexture(); + } + } +} \ No newline at end of file diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index da7aceae..b18d333b 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -145,17 +145,19 @@ + + - - - + + + @@ -172,6 +174,20 @@ + + Pixel + Pixel + Pixel + Pixel + 5.0 + + + Vertex + Vertex + Vertex + Vertex + 5.0 + Vertex Vertex @@ -204,6 +220,9 @@ + + + diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters index 2fcc4beb..6525139a 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters @@ -39,17 +39,17 @@ Source Files + + Source Files + + + Source Files + - - Header Files - Header Files - - Header Files - Header Files @@ -71,7 +71,13 @@ Header Files - + + Header Files + + + Header Files + + Header Files @@ -79,5 +85,10 @@ + + + + + \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp index cbefee45..5e1fbb48 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp @@ -36,7 +36,7 @@ namespace Oyster if(models[i].Visible) { void* data = Resources::ModelData.Map(); - memcpy(data,&(models[i].WorldMatrix),64); + memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4)); Resources::ModelData.Unmap(); //Set Materials :: NONE diff --git a/Code/OysterGraphics/Render/Resources/Resources.cpp b/Code/OysterGraphics/Render/Resources/Resources.cpp index 80dc5975..3ff3fa3c 100644 --- a/Code/OysterGraphics/Render/Resources/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources/Resources.cpp @@ -99,6 +99,7 @@ namespace Oyster obj.CBuffers.Vertex.push_back(&VPData); obj.RenderStates.Rasterizer = rs; + ModelData.Apply(1); #pragma endregion return Core::Init::Sucsess; } diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/PixelGatherData.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/PixelGatherData.hlsl deleted file mode 100644 index 501771e7..00000000 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/PixelGatherData.hlsl +++ /dev/null @@ -1,25 +0,0 @@ -struct VertexOut -{ - float4 pos : SV_POSITION; - float4 ViewPos: POSITION; - float2 UV : TEXCOORD; - float4 normal : NORMAL; -}; - -struct PixelOut -{ - float4 Diffuse3Glow1 : SV_TARGET0; - float4 Normal3Specular1 : SV_TARGET1; - float4 VPos : SV_TARGET2; -}; - -Texture2D Diffuse; -Texture2D Specular; - -PixelOut main(VertexOut input) -{ - PixelOut output; - output.Diffuse3Glow1 = float4(1.0f, 0.0f, 0.0f, 1.0f); - output.Normal3Specular1 = float4(input.normal, 1.0f); - return output; -} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/VertexGatherData.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/VertexGatherData.hlsl deleted file mode 100644 index 6844635a..00000000 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Gather/VertexGatherData.hlsl +++ /dev/null @@ -1,37 +0,0 @@ -cbuffer PerFrame : register(b0) -{ - matrix View; - float4x4 Projection; - matrix VP; -} - -cbuffer PerModel : register(b1) -{ - matrix World; -} - -struct VertexIn -{ - float3 pos : POSITION; - float2 UV : TEXCOORD; - float3 normal : NORMAL; -}; - -struct VertexOut -{ - float4 pos : SV_POSITION; - float4 ViewPos: POSITION; - float2 UV : TEXCOORD; - float4 normal : NORMAL; -}; - -VertexOut main( VertexIn input ) -{ - VertexOut output; - matrix WV = mul(View, World); - output.ViewPos = mul(WV, float4(input.pos,1)); - output.pos = mul(Projection, output.ViewPos); - output.UV = input.UV; - output.normal = float4(input.normal, 0); - return output; -} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/GBufferHeader.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/GBufferHeader.hlsli new file mode 100644 index 00000000..d39f6ae5 --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/GBufferHeader.hlsli @@ -0,0 +1,41 @@ +struct VertexIn +{ + float3 pos : POSITION; + float2 UV : TEXCOORD; + float3 normal : NORMAL; + float3 tangent : TANGENT; + float3 biTangent : BITANGENT; + float4 boneIndex : BONEINDEX; + float4 boneWeight : BONEWEIGHT; +}; + +struct VertexOut +{ + float4 pos : SV_POSITION; + float4 ViewPos : POSITION; + float2 UV : TEXCOORD; + float3 normal : NORMAL; + float3 tangent : TANGENT; + float3 biTangent : BITANGENT; +}; + +struct PixelOut +{ + float4 DiffuseGlow : SV_TARGET0; + float4 NormalSpec : SV_TARGET1; +}; + +Texture2D Diffuse : register(t0); +Texture2D Specular : register(t1); + +cbuffer PerFrame : register(b0) +{ + matrix View; + float4x4 Projection; + matrix VP; +} + +cbuffer PerModel : register(b1) +{ + matrix World; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/PixelGatherData.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/PixelGatherData.hlsl new file mode 100644 index 00000000..61f0e20f --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/PixelGatherData.hlsl @@ -0,0 +1,9 @@ +#include "GBufferHeader.hlsli" + +PixelOut main(VertexOut input) +{ + PixelOut output; + output.DiffuseGlow = float4(1.0f, 0.0f, 0.0f, 1.0f); + output.NormalSpec = float4(input.normal, 1.0f); + return output; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/VertexGatherData.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/VertexGatherData.hlsl new file mode 100644 index 00000000..d5751ac4 --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GatherGBuffer/VertexGatherData.hlsl @@ -0,0 +1,12 @@ +#include "GBufferHeader.hlsli" + +VertexOut main( VertexIn input ) +{ + VertexOut output; + matrix WV = mul(View, World); + output.ViewPos = mul(WV, float4(input.pos,1)); + output.pos = mul(Projection, output.ViewPos); + output.UV = input.UV; + output.normal = float4(input.normal, 0); + return output; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl b/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl index fadd7332..76e7dbed 100644 --- a/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/SimpleDebug/DebugCameraVertex.hlsl @@ -18,11 +18,11 @@ struct VertexIn float4 main( VertexIn input ) : SV_POSITION { - float4 postTransform = float4(input.pos*0.1f,1); - postTransform.y += 1.5f; + float4 postTransform = mul( World, float4(input.pos,1) ); + //float4 postTransform = float4(input.pos,1); //return postTransform; //return mul(View, float4(input.pos,1)); matrix VP = mul(Projection, View); //matrix WVP = mul(World, VP); - return mul(VP, float4(input.pos*0.1f,1) ); + return mul(VP, postTransform ); } \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index aa0ade78..17b543b7 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -177,12 +177,12 @@ HRESULT InitDirect3D() #pragma region Obj OBJReader or; - or.readOBJFile(L"bth.obj"); + or.readOBJFile(L"crate.obj"); m->info = (void*)or.toModel(); m->Visible=true; #pragma endregion - //*((Oyster::Math::Matrix)m->data) = Oyster::Math::Matrix::identity; + m->WorldMatrix = Oyster::Math::Matrix::identity; P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,16.0f/9.0f,.1f,100);