diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index cca2786c..0e38eeb2 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -83,7 +83,7 @@ namespace Oyster m->WorldMatrix = Oyster::Math::Float4x4::identity; m->Visible = true; - m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadOBJ); + m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadDAN); Model::ModelInfo* mi = (Model::ModelInfo*)m->info; if(mi->Vertices->GetBufferPointer() == NULL) diff --git a/Code/OysterGraphics/FileLoader/DanLoader.cpp b/Code/OysterGraphics/FileLoader/DanLoader.cpp new file mode 100644 index 00000000..73f0c8c8 --- /dev/null +++ b/Code/OysterGraphics/FileLoader/DanLoader.cpp @@ -0,0 +1,307 @@ +#include "GeneralLoader.h" +#include "../Definitions/GraphicalDefinition.h" +#include "../Model/ModelInfo.h" +#include "../Core/Core.h" +#include +#include + +#define DANFILEVERSIONMAJOR 1 +#define DANFILEVERSIONMINOR 1 + +#define FILEHEADERSIZE 8 +#define VERTEXHEADERSIZE 4 +#define VERTEXSIZE 88 + + + +/// +enum HeaderType +{ + VERTEXHEADER = 0, ///< + INDEXHEADER = 1, ///< + MATERIALHEADER = 2, ///< + SKELETONHEADER = 3, ///< + ANIMATIONHEADER = 4 ///< +}; + +/// +struct FileHeader +{ + unsigned int versionMajor; ///< + unsigned int versionMinor; ///< + + /// + FileHeader(char* data) + { + char* memPos = data; // + + memcpy(&versionMajor, memPos, sizeof(unsigned int)); + memPos += 4; + memcpy(&versionMinor, memPos, sizeof(unsigned int)); + } +}; + +/// +struct VertexHeader +{ + unsigned int numVertices; + + /// + VertexHeader(char* data) + { + memcpy(&numVertices, data, sizeof(unsigned int)); + } +}; + +/// +typedef Oyster::Graphics::Definitions::FinalVertex Vertex; + +/// +struct IndexHeader +{ + unsigned int numIndices; + + /// + IndexHeader(char* data) + { + memcpy(&numIndices, data, sizeof(unsigned int)); + } +}; + +/// +struct MaterialHeader +{ + unsigned int diffuseMapPathLength; + char* diffuseMapPath; + + unsigned int normalMapPathLength; + char* normalMapPath; + /* + /// + MaterialHeader(char* data) + { + char* memPos = data; // + + memcpy(&diffuseMapPathLength, memPos, sizeof(unsigned int)); + memPos += 4; + + diffuseMapPath = new char[diffuseMapPathLength]; + memcpy(diffuseMapPath, memPos, diffuseMapPathLength); + memPos += diffuseMapPathLength; + + memcpy(&normalMapPathLength, memPos, sizeof(unsigned int)); + memPos += 4; + + normalMapPath = new char[normalMapPathLength]; + memcpy(normalMapPath, memPos, normalMapPathLength); + memPos += normalMapPathLength; + } + */ +}; + +/// +struct SkeletonHeader +{ + // do this... +}; + +/// +struct AnimationHeader +{ + // do this... +}; + +struct Frame +{ + // do this... +}; + +/// +void Oyster::Graphics::Loading::UnloadDAN(void* data) +{ + Model::ModelInfo* info = (Model::ModelInfo*) data; + SAFE_DELETE(info->Vertices); + if(info->Indexed) + { + SAFE_DELETE(info->Indecies); + } + for(int i =0;iMaterial.size();++i) + { + Oyster::Resource::OysterResource::ReleaseResource(info->Material[i]); + } + delete info; +} + +static wchar_t* charToWChar(const char* text) +{ + // Convert to a wchar_t* + size_t origsize = strlen(text) + 1; + size_t convertedChars = 0; + wchar_t* wcstring = new wchar_t[origsize]; + mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE); + return wcstring; +} + +/// +void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resource::CustomData& out) +{ + // + Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo(); + modelInfo->Indexed = false; + // Open file in binary mode + std::ifstream danFile; + danFile.open(filename, std::ios::binary); + if (!danFile.is_open()) + return; + + // Read file header + char* buffer = new char[sizeof(FileHeader)]; + danFile.read(buffer, sizeof(FileHeader)); + FileHeader fileHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // If problem with compatability then close file and return from method + if (fileHeader.versionMajor != DANFILEVERSIONMAJOR) + { + danFile.close(); + return; + } + + // Read the .dan-file + while (!danFile.eof()) + { + // read header type + unsigned int headerType; + buffer = new char[4]; + danFile.read(buffer, 4); + memcpy(&headerType, buffer, 4); + //delete[] buffer; // ( note: may crash here.) + + // handle header type + switch ((HeaderType)headerType) + { + // vertex header + case HeaderType::VERTEXHEADER: + { + // Fetch vertex header, number of vertices + buffer = new char[4]; + danFile.read(buffer, 4); + VertexHeader vertexHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // Fetch all vertices + Vertex* vertices = new Vertex[vertexHeader.numVertices]; + unsigned int bufferSize = VERTEXSIZE * vertexHeader.numVertices; + buffer = new char[bufferSize]; + danFile.read(buffer, bufferSize); + memcpy(vertices, buffer, bufferSize); + delete[] buffer; // ( note: may crash here.) + + // Do the deed + Oyster::Graphics::Core::Buffer* vertexBuffer = new Oyster::Graphics::Core::Buffer(); + Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; + bufferInitDesc.ElementSize = sizeof(Vertex); + bufferInitDesc.InitData = vertices; + bufferInitDesc.NumElements = vertexHeader.numVertices; + bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::VERTEX_BUFFER; + bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; + vertexBuffer->Init(bufferInitDesc); + modelInfo->VertexCount = vertexHeader.numVertices; + modelInfo->Vertices = vertexBuffer; + + delete[] vertices; // ( note: may crash here.) + + break; + } + case HeaderType::INDEXHEADER: + { + // Fetch vertex header, number of vertices + buffer = new char[4]; + danFile.read(buffer, 4); + IndexHeader indexHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // Fetch all indices + unsigned int* indices = new unsigned int[indexHeader.numIndices]; + unsigned int bufferSize = sizeof(unsigned int) * indexHeader.numIndices; + buffer = new char[bufferSize]; + danFile.read(buffer, bufferSize); + memcpy(indices, buffer, bufferSize); + delete[] buffer; // ( note: may crash here.) + + // Do the deed + Oyster::Graphics::Core::Buffer* indexBuffer = new Oyster::Graphics::Core::Buffer(); + Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; + bufferInitDesc.ElementSize = sizeof(unsigned int); + bufferInitDesc.InitData = indices; + bufferInitDesc.NumElements = indexHeader.numIndices; + bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::INDEX_BUFFER; + bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; + indexBuffer->Init(bufferInitDesc); + modelInfo->IndexCount = indexHeader.numIndices; + modelInfo->Indecies = indexBuffer; + modelInfo->Indexed = true; + + delete[] indices; // ( note: may crash here.) + + break; + } + // material header + case HeaderType::MATERIALHEADER: + { + // Fetch material header, 2 texture path strings + MaterialHeader materialHeader; + buffer = new char[4]; + danFile.read(buffer, 4); + memcpy(&materialHeader.diffuseMapPathLength, buffer, 4); + delete[] buffer; // ( note: may crash here.) + + buffer = new char[materialHeader.diffuseMapPathLength]; + danFile.read(buffer, materialHeader.diffuseMapPathLength); + materialHeader.diffuseMapPath = new char[materialHeader.diffuseMapPathLength+1]; + memcpy(materialHeader.diffuseMapPath, buffer, materialHeader.diffuseMapPathLength); + materialHeader.diffuseMapPath[materialHeader.diffuseMapPathLength] = 0; + delete[] buffer; // ( note: may crash here.) + + buffer = new char[4]; + danFile.read(buffer, 4); + memcpy(&materialHeader.normalMapPathLength, buffer, 4); + delete[] buffer; // ( note: may crash here.) + + buffer = new char[materialHeader.normalMapPathLength]; + danFile.read(buffer, materialHeader.normalMapPathLength); + materialHeader.normalMapPath = new char[materialHeader.normalMapPathLength + 1]; + memcpy(materialHeader.normalMapPath, buffer, materialHeader.normalMapPathLength); + materialHeader.normalMapPath[materialHeader.normalMapPathLength] = 0; + delete[] buffer; // ( note: may crash here.) + + // + ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath), Oyster::Graphics::Loading::LoadTexture); + ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath), Oyster::Graphics::Loading::LoadTexture); + modelInfo->Material.push_back(diffuseMap); + modelInfo->Material.push_back(normalMap); + + break; + } + // skeleton header + case HeaderType::SKELETONHEADER: + { + // not implemented... + break; + } + // animation header + case HeaderType::ANIMATIONHEADER: + { + // not implemented... + break; + } + } + } + + // close file + danFile.close(); + + // Set modelinfo as output data + out.loadedData = modelInfo; + out.resourceUnloadFnc = Oyster::Graphics::Loading::UnloadDAN; +} \ No newline at end of file diff --git a/Code/OysterGraphics/FileLoader/GeneralLoader.h b/Code/OysterGraphics/FileLoader/GeneralLoader.h index 4eab570b..cd6806e1 100644 --- a/Code/OysterGraphics/FileLoader/GeneralLoader.h +++ b/Code/OysterGraphics/FileLoader/GeneralLoader.h @@ -29,6 +29,9 @@ namespace Oyster void UnloadOBJ(void* loadedData); void LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out); + + void UnloadDAN(void* loadedData); + void LoadDAN(const wchar_t filename[], Oyster::Resource::CustomData& out); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Model/ModelInfo.h b/Code/OysterGraphics/Model/ModelInfo.h index 6c1d0cfe..9dcef562 100644 --- a/Code/OysterGraphics/Model/ModelInfo.h +++ b/Code/OysterGraphics/Model/ModelInfo.h @@ -16,7 +16,7 @@ namespace Oyster std::vector Material; Core::Buffer *Vertices,*Indecies; bool Indexed; - int VertexCount; + int VertexCount, IndexCount; }; } } diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index d2196e4e..e9b8ff72 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -1,285 +1,286 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {0EC83E64-230E-48EF-B08C-6AC9651B4F82} - OysterGraphics - - - - DynamicLibrary - true - v110 - MultiByte - - - DynamicLibrary - true - v110 - MultiByte - - - DynamicLibrary - false - v110 - true - MultiByte - - - DynamicLibrary - false - v110 - true - MultiByte - - - - - - - - - - - - - - - - - - - $(SolutionDir)..\Bin\DLL\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) - - - $(SolutionDir)..\Bin\DLL\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) - - - $(SolutionDir)..\Bin\DLL\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) - - - $(SolutionDir)..\Bin\DLL\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) - C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) - - - - Level3 - Disabled - true - $(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) - GFX_DLL_EXPORT;%(PreprocessorDefinitions) - - - true - - - true - - - $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso - 5.0 - - - - - Level3 - Disabled - true - ..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - GFX_DLL_EXPORT;%(PreprocessorDefinitions) - - - true - - - $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso - 5.0 - - - - - Level3 - Disabled - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - GFX_DLL_EXPORT;%(PreprocessorDefinitions) - - - true - true - true - - - $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso - true - 5.0 - - - - - Level3 - Disabled - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - GFX_DLL_EXPORT;%(PreprocessorDefinitions) - - - true - true - true - - - $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso - true - 5.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} - - - {f10cbc03-9809-4cba-95d8-327c287b18ee} - - - - - Compute - Compute - Compute - Compute - - - Pixel - Pixel - Pixel - Pixel - - - Compute - 5.0 - Compute - 5.0 - Compute - 5.0 - Compute - 5.0 - - - Vertex - Vertex - Vertex - Vertex - - - Vertex - Vertex - Vertex - Vertex - - - - - 5.0 - - - Pixel - Pixel - Pixel - Pixel - true - 5.0 - main - - - Vertex - Vertex - Vertex - Vertex - true - 5.0 - main - - - - - Pixel - Pixel - Pixel - Pixel - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {0EC83E64-230E-48EF-B08C-6AC9651B4F82} + OysterGraphics + + + + DynamicLibrary + true + v110 + MultiByte + + + DynamicLibrary + true + v110 + MultiByte + + + DynamicLibrary + false + v110 + true + MultiByte + + + DynamicLibrary + false + v110 + true + MultiByte + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + + Level3 + Disabled + true + $(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) + GFX_DLL_EXPORT;%(PreprocessorDefinitions) + + + true + + + true + + + $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + 5.0 + + + + + Level3 + Disabled + true + ..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + GFX_DLL_EXPORT;%(PreprocessorDefinitions) + + + true + + + $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + 5.0 + + + + + Level3 + Disabled + true + true + true + ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + GFX_DLL_EXPORT;%(PreprocessorDefinitions) + + + true + true + true + + + $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + true + 5.0 + + + + + Level3 + Disabled + true + true + true + ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + GFX_DLL_EXPORT;%(PreprocessorDefinitions) + + + true + true + true + + + $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + true + 5.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + + + + + Compute + Compute + Compute + Compute + + + Pixel + Pixel + Pixel + Pixel + + + Compute + 5.0 + Compute + 5.0 + Compute + 5.0 + Compute + 5.0 + + + Vertex + Vertex + Vertex + Vertex + + + Vertex + Vertex + Vertex + Vertex + + + + + 5.0 + + + Pixel + Pixel + Pixel + Pixel + true + 5.0 + main + + + Vertex + Vertex + Vertex + Vertex + true + 5.0 + main + + + + + Pixel + Pixel + Pixel + Pixel + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp index 06e53e69..0a5a275c 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp @@ -75,7 +75,7 @@ namespace Oyster if(info->Indexed) { info->Indecies->Apply(); - Oyster::Graphics::Core::deviceContext->DrawIndexed(info->VertexCount,0,0); + Oyster::Graphics::Core::deviceContext->DrawIndexed(info->IndexCount,0,0); } else { diff --git a/Code/OysterGraphics/Render/Resources/Deffered.cpp b/Code/OysterGraphics/Render/Resources/Deffered.cpp index b1189f39..f606d57e 100644 --- a/Code/OysterGraphics/Render/Resources/Deffered.cpp +++ b/Code/OysterGraphics/Render/Resources/Deffered.cpp @@ -92,7 +92,7 @@ namespace Oyster D3D11_RASTERIZER_DESC rdesc; rdesc.CullMode = D3D11_CULL_BACK; rdesc.FillMode = D3D11_FILL_SOLID; - rdesc.FrontCounterClockwise = true; + rdesc.FrontCounterClockwise = false; rdesc.DepthBias = 0; rdesc.DepthBiasClamp = 0; rdesc.DepthClipEnable = true; @@ -230,11 +230,14 @@ namespace Oyster { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 } - + { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BITANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 44, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 56, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; - Shader::CreateInputLayout(indesc,3,GetShader::Vertex(L"Geometry"),GeometryPass.IAStage.Layout); + Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Geometry"),GeometryPass.IAStage.Layout); GeometryPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; GeometryPass.CBuffers.Vertex.push_back(VPData); GeometryPass.CBuffers.Vertex.push_back(ModelData); diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli index 74f8cc33..18cac11d 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli @@ -3,15 +3,16 @@ struct VertexIn float3 pos : POSITION; float2 UV : TEXCOORD; float3 normal : NORMAL; - //float3 tangent : TANGENT; - //float3 biTangent : BITANGENT; - //float4 boneIndex : BONEINDEX; - //float4 boneWeight : BONEWEIGHT; + 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; diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli index 8a1ff05a..bd449209 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli @@ -21,8 +21,8 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord) output.Specular * 0; if(d > pl.Radius) { - output.Diffuse = float3(0,0,0); - output.Specular = float3(0,0,0); + output.Diffuse = float4(0,0,0,1); + output.Specular = float4(0,0,0,1); } return output; } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl index 0aec75da..98b2887e 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl @@ -12,13 +12,13 @@ [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) { - float2 UV = DTid.xy / Pixels; + float2 UV = DTid / Pixels; UV.x = UV.x * 2 - 1; UV.y = 1 - 2 * UV.y; float3 ViewPos = ToVpos(DTid.xy, UV); DiffSpec Shaded; - Shaded.Diffuse = float3(0,0,0); - Shaded.Specular = float3(0,0,0); + Shaded.Diffuse = float4(0,0,0,0); + Shaded.Specular = float4(0,0,0,0); for(int i = 0; i < Lights; ++i) { diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli index b7e2a9f1..32f84f90 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli @@ -24,7 +24,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) float4 ProjOffset = sampled; ProjOffset = mul(Proj, ProjOffset); float4 offset = ProjOffset; - float2 UV = offset.xy; + float2 UV = offset; offset /= offset.w; offset.xyz = offset.xyz * 0.5f + 0.5f; //extra invert y axis, DX11 diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index f9ceec99..d25a9adc 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -159,12 +159,10 @@ HRESULT InitDirect3D() return E_FAIL; } - m = Oyster::Graphics::API::CreateModel(L"crate2"); - if(m==NULL) - m = Oyster::Graphics::API::CreateModel(L"christmastree"); - m2 = Oyster::Graphics::API::CreateModel(L"christmastree"); + m = Oyster::Graphics::API::CreateModel(L"cube_tri.dan"); + m2 = Oyster::Graphics::API::CreateModel(L"cube_tri.dan"); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null); - m3 = Oyster::Graphics::API::CreateModel(L"christmastree"); + m3 = Oyster::Graphics::API::CreateModel(L"cube_tri.dan"); m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);