diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 59112d8..8058c58 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -99,17 +99,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) return false; } - // Create and initialize the texture shader object. - m_TextureShader = new TextureShaderClass; - - result = m_TextureShader->Initialize(m_Direct3D->GetDevice(), hwnd); - if (!result) - { - logger.Log("Could not initialize the texture shader object", __FILE__, __LINE__, Logger::LogLevel::Error); - return false; - } - - // Create and initialize the render to texture object. m_RenderTexture = new RenderTextureClass; @@ -198,16 +187,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) return false; } - // Create and initialize the light shader object. - m_LightShader = new LightShaderClass; - - result = m_LightShader->Initialize(m_Direct3D->GetDevice(), hwnd); - if (!result) - { - logger.Log("Could not initialize the light shader object", __FILE__, __LINE__, Logger::LogLevel::Error); - return false; - } - // Create and initialize the light object. m_Light = new LightClass; @@ -1083,27 +1062,20 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t return false; } - // Turn off alpha blending. - m_Direct3D->DisableAlphaBlending(); + // Setup matrices. + rotateMatrix = XMMatrixRotationY(rotation); + translateMatrix = XMMatrixTranslation(-10.0f, 1.0f, -20.0f); + worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); + + // Render the model using the transparent shader. + m_Model->Render(m_Direct3D->GetDeviceContext()); + + result = m_ShaderManager->RenderlightMapShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), m_Model->GetTexture(4)); + if (!result) + { + return false; + } - - // Lighting, utilise plusieurs lights donc Multiple Points Lighting - //result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), - // diffuseColor, lightPosition); - //if (!result) - //{ - // return false; - //} - - // Lightmapping, utiliser light01.tga en deuxieme texture - //result = m_LightMapShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, - // m_Model->GetTexture(0), m_Model->GetTexture(1)); - //if (!result) - //{ - // return false; - //} - - // Enable the Z buffer and disable alpha blending now that 2D rendering is complete. m_Direct3D->TurnZBufferOn(); m_Direct3D->DisableAlphaBlending(); diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 3878353..75012b0 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -101,9 +101,6 @@ private : D3DClass* m_Direct3D; IDXGISwapChain* m_swapChain; ModelClass* m_Model; - TextureShaderClass* m_TextureShader; - /*TransparentShaderClass* m_TransparentShader;*/ - ShaderManagerClass* m_ShaderManager; ModelListClass* m_ModelList; // ------------------------------------- // @@ -140,8 +137,7 @@ private : // ------------- SHADERS ------------- // // ----------------------------------- // - LightShaderClass* m_LightShader; - LightMapShaderClass* m_LightMapShader; + ShaderManagerClass* m_ShaderManager; FontShaderClass* m_FontShader; ReflectionShaderClass* m_ReflectionShader; diff --git a/enginecustom/enginecustom.vcxproj.filters b/enginecustom/enginecustom.vcxproj.filters index 05baaa3..a60fa9b 100644 --- a/enginecustom/enginecustom.vcxproj.filters +++ b/enginecustom/enginecustom.vcxproj.filters @@ -123,9 +123,6 @@ Fichiers sources - - Fichiers sources - Fichiers sources @@ -162,6 +159,9 @@ Fichiers sources + + Fichiers sources + @@ -352,15 +352,12 @@ fonts - - assets Assets - Assets @@ -382,15 +379,37 @@ - - - - - - - - + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + \ No newline at end of file diff --git a/enginecustom/shadermanagerclass.cpp b/enginecustom/shadermanagerclass.cpp index ecdedaa..a92b52d 100644 --- a/enginecustom/shadermanagerclass.cpp +++ b/enginecustom/shadermanagerclass.cpp @@ -10,6 +10,7 @@ ShaderManagerClass::ShaderManagerClass() m_SpecMapShader = 0; m_TransparentShader = 0; m_LightShader = 0; + m_LightMapShader = 0; } @@ -81,7 +82,7 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd) return false; } - // Create and initialize the specular map shader object. + // Create and initialize the transparent shader object. m_TransparentShader = new TransparentShaderClass; result = m_TransparentShader->Initialize(device, hwnd); @@ -90,7 +91,7 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd) return false; } - // Create and initialize the light map shader object. + // Create and initialize the light shader object. m_LightShader = new LightShaderClass; result = m_LightShader->Initialize(device, hwnd); @@ -99,6 +100,15 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd) return false; } + // Create and initialize the light map shader object. + m_LightMapShader = new LightMapShaderClass; + + result = m_LightMapShader->Initialize(device, hwnd); + if (!result) + { + return false; + } + return true; } @@ -160,7 +170,7 @@ void ShaderManagerClass::Shutdown() m_TransparentShader = 0; } - // Release the transparent shader object. + // Release the light shader object. if (m_LightShader) { m_LightShader->Shutdown(); @@ -168,6 +178,14 @@ void ShaderManagerClass::Shutdown() m_LightShader = 0; } + // Release the light map shader object. + if (m_LightMapShader) + { + m_LightMapShader->Shutdown(); + delete m_LightMapShader; + m_LightMapShader = 0; + } + return; } @@ -291,5 +309,20 @@ bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, i return false; } + return true; +} + +bool ShaderManagerClass::RenderlightMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, + XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2) +{ + bool result; + + + result = m_LightMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2); + if (!result) + { + return false; + } + return true; } \ No newline at end of file diff --git a/enginecustom/shadermanagerclass.h b/enginecustom/shadermanagerclass.h index 228e959..caf7876 100644 --- a/enginecustom/shadermanagerclass.h +++ b/enginecustom/shadermanagerclass.h @@ -12,6 +12,7 @@ #include "specmapshaderclass.h" #include "transparentshaderclass.h" #include "lightshaderclass.h" +#include "lightmapshaderclass.h" //////////////////////////////////////////////////////////////////////////////// @@ -35,6 +36,7 @@ public: XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float); bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float); bool RenderlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[]); + bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*); private: TextureShaderClass* m_TextureShader; @@ -45,6 +47,7 @@ private: SpecMapShaderClass* m_SpecMapShader; TransparentShaderClass* m_TransparentShader; LightShaderClass* m_LightShader; + LightMapShaderClass* m_LightMapShader; }; #endif \ No newline at end of file