From d286e71ebe2911dbe2ae43424663a7ac578e457e Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:57:31 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Light=20Shader=20=C3=A0=20corriger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enginecustom/applicationclass.cpp | 75 ++++++++++++----------------- enginecustom/applicationclass.h | 3 -- enginecustom/shadermanagerclass.cpp | 33 +++++++++++++ enginecustom/shadermanagerclass.h | 3 ++ 4 files changed, 66 insertions(+), 48 deletions(-) diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index cb466a9..bb5523b 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -5,9 +5,6 @@ ApplicationClass::ApplicationClass() m_Direct3D = 0; m_Camera = 0; m_Model = 0; - m_LightShader = 0; - m_Light = 0; - m_TextureShader = 0; m_Bitmap = 0; m_Sprite = 0; m_Timer = 0; @@ -94,17 +91,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) - { - MessageBox(hwnd, L"Could not initialize the texture shader object.", L"Error", MB_OK); - return false; - } - - // Create and initialize the render to texture object. m_RenderTexture = new RenderTextureClass; @@ -196,16 +182,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) - { - MessageBox(hwnd, L"Could not initialize the light shader object.", L"Error", MB_OK); - return false; - } - // Create and initialize the light object. m_Light = new LightClass; @@ -259,8 +235,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) return false; } - - // Create and initialize the font shader object. m_FontShader = new FontShaderClass; @@ -454,14 +428,6 @@ void ApplicationClass::Shutdown() m_Light = 0; } - // Release the light shader object. - if (m_LightShader) - { - m_LightShader->Shutdown(); - delete m_LightShader; - m_LightShader = 0; - } - // Release the model object. if (m_Model) { @@ -637,7 +603,8 @@ bool ApplicationClass::RenderSceneToTexture(float rotation) // Render the model using the texture shader. m_Model->Render(m_Direct3D->GetDeviceContext()); - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(1)); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_Model->GetTexture(1)); if (!result) { return false; @@ -697,7 +664,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t m_Model->Render(m_Direct3D->GetDeviceContext()); // Render the model using the light shader. - result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition); for (auto cube : m_cubes) @@ -719,7 +686,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t cube->Render(m_Direct3D->GetDeviceContext()); - result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition); if (!result) { @@ -742,7 +709,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t object->Render(m_Direct3D->GetDeviceContext()); - result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition); if (!result) @@ -764,7 +731,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t chunk->Render(m_Direct3D->GetDeviceContext()); - result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(1), + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition); if (!result) { @@ -778,7 +745,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Render the display plane using the texture shader and the render texture resource. m_DisplayPlane->Render(m_Direct3D->GetDeviceContext()); - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView()); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_RenderTexture->GetShaderResourceView()); if (!result) { return false; @@ -790,7 +758,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Render the display plane using the texture shader and the render texture resource. m_DisplayPlane->Render(m_Direct3D->GetDeviceContext()); - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView()); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_RenderTexture->GetShaderResourceView()); if (!result) { return false; @@ -802,7 +771,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Render the display plane using the texture shader and the render texture resource. m_DisplayPlane->Render(m_Direct3D->GetDeviceContext()); - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView()); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_RenderTexture->GetShaderResourceView()); if (!result) { return false; @@ -838,8 +808,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t // Render the model using the light shader. m_Model->Render(m_Direct3D->GetDeviceContext()); - result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, - m_Model->GetTexture(0), diffuseColor, lightPosition); + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), + diffuseColor, lightPosition); if (!result) { return false; @@ -905,7 +875,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t } // Render the sprite with the texture shader. - result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_Sprite->GetIndexCount(), worldMatrix, viewMatrix, orthoMatrix, m_Sprite->GetTexture()); + result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, orthoMatrix, + m_Sprite->GetTexture()); if (!result) { return false; @@ -1056,6 +1027,20 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t return false; } + //// Setup matrices. + //rotateMatrix = XMMatrixRotationY(rotation); + //translateMatrix = XMMatrixTranslation(-10.0f, -2.0f, -20.0f); + //worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); + + // Render the model using the transparent shader. + //m_Model->Render(m_Direct3D->GetDeviceContext()); + + //result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), m_Lights[0]->GetDiffuseColor(), m_Lights[0]->GetPosition()); + //if (!result) + //{ + // return false; + //} + // Turn off alpha blending. m_Direct3D->DisableAlphaBlending(); diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 3aaad14..50314eb 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -16,7 +16,6 @@ #include "lightmapshaderclass.h" #include "bitmapclass.h" #include "spriteclass.h" -#include "textureshaderclass.h" #include "timerclass.h" #include "fontshaderclass.h" #include "fontclass.h" @@ -30,8 +29,6 @@ #include "rendertextureclass.h" #include "displayplaneclass.h" #include "reflectionshaderclass.h" -#include "transparentshaderclass.h" - ///////////// diff --git a/enginecustom/shadermanagerclass.cpp b/enginecustom/shadermanagerclass.cpp index 79baf23..ecdedaa 100644 --- a/enginecustom/shadermanagerclass.cpp +++ b/enginecustom/shadermanagerclass.cpp @@ -9,6 +9,7 @@ ShaderManagerClass::ShaderManagerClass() m_AlphaMapShader = 0; m_SpecMapShader = 0; m_TransparentShader = 0; + m_LightShader = 0; } @@ -89,6 +90,15 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd) return false; } + // Create and initialize the light map shader object. + m_LightShader = new LightShaderClass; + + result = m_LightShader->Initialize(device, hwnd); + if (!result) + { + return false; + } + return true; } @@ -150,6 +160,14 @@ void ShaderManagerClass::Shutdown() m_TransparentShader = 0; } + // Release the transparent shader object. + if (m_LightShader) + { + m_LightShader->Shutdown(); + delete m_LightShader; + m_LightShader = 0; + } + return; } @@ -258,5 +276,20 @@ bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceCont return false; } + return true; +} + +bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, + ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[]) +{ + bool result; + + + result = m_LightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition); + if (!result) + { + return false; + } + return true; } \ No newline at end of file diff --git a/enginecustom/shadermanagerclass.h b/enginecustom/shadermanagerclass.h index 542093d..228e959 100644 --- a/enginecustom/shadermanagerclass.h +++ b/enginecustom/shadermanagerclass.h @@ -11,6 +11,7 @@ #include "alphamapshaderclass.h" #include "specmapshaderclass.h" #include "transparentshaderclass.h" +#include "lightshaderclass.h" //////////////////////////////////////////////////////////////////////////////// @@ -33,6 +34,7 @@ public: bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float); bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float); + bool RenderlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[]); private: TextureShaderClass* m_TextureShader; @@ -42,6 +44,7 @@ private: AlphaMapShaderClass* m_AlphaMapShader; SpecMapShaderClass* m_SpecMapShader; TransparentShaderClass* m_TransparentShader; + LightShaderClass* m_LightShader; }; #endif \ No newline at end of file From 1bba2047b1bd48a0e6119958367a25da4fbe6568 Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:05:59 +0200 Subject: [PATCH 2/5] Minor: Ajout Light Shader --- enginecustom/applicationclass.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index bb5523b..215842f 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -1027,19 +1027,19 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t return false; } - //// Setup matrices. - //rotateMatrix = XMMatrixRotationY(rotation); - //translateMatrix = XMMatrixTranslation(-10.0f, -2.0f, -20.0f); - //worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); + // Setup matrices. + rotateMatrix = XMMatrixRotationY(rotation); + translateMatrix = XMMatrixTranslation(-10.0f, -2.0f, -20.0f); + worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix); // Render the model using the transparent shader. - //m_Model->Render(m_Direct3D->GetDeviceContext()); + m_Model->Render(m_Direct3D->GetDeviceContext()); - //result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), m_Lights[0]->GetDiffuseColor(), m_Lights[0]->GetPosition()); - //if (!result) - //{ - // return false; - //} + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition); + if (!result) + { + return false; + } // Turn off alpha blending. m_Direct3D->DisableAlphaBlending(); From 1345537486abcb374be6a4e5e4f7ffa45dc2b862 Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:19:20 +0200 Subject: [PATCH 3/5] Fix merge --- enginecustom/enginecustom.vcxproj | 3 +- enginecustom/enginecustom.vcxproj.filters | 100 +++++++--------------- 2 files changed, 32 insertions(+), 71 deletions(-) diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj index 7eb8b74..868cc9b 100644 --- a/enginecustom/enginecustom.vcxproj +++ b/enginecustom/enginecustom.vcxproj @@ -188,7 +188,6 @@ - @@ -206,10 +205,10 @@ - + diff --git a/enginecustom/enginecustom.vcxproj.filters b/enginecustom/enginecustom.vcxproj.filters index 46ace05..05baaa3 100644 --- a/enginecustom/enginecustom.vcxproj.filters +++ b/enginecustom/enginecustom.vcxproj.filters @@ -307,81 +307,15 @@ assets - - assets - - - assets - assets - - assets - - - assets - - - Assets - Assets - - - - - shader - - - shader - - - shader - - - shader - - - texture - - - texture - - - shader - - - shader - - - Texture - - - Texture - - - Texture - - - Texture - - - shader - - - shader - - - - - - - @@ -390,6 +324,9 @@ assets + + Assets + @@ -424,11 +361,36 @@ Assets - - Assets - Assets + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c6f97490d19965df6d5e3df1f1c46b3af5ab3e3a Mon Sep 17 00:00:00 2001 From: GolfOcean334 <130740013+GolfOcean334@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:49:49 +0200 Subject: [PATCH 4/5] Minor: Ajout du Light Map Shader au Sheder Manager --- enginecustom/applicationclass.cpp | 54 ++++++----------------- enginecustom/applicationclass.h | 6 +-- enginecustom/enginecustom.vcxproj.filters | 47 ++++++++++++++------ enginecustom/shadermanagerclass.cpp | 39 ++++++++++++++-- enginecustom/shadermanagerclass.h | 3 ++ 5 files changed, 86 insertions(+), 63 deletions(-) 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 From cf434ffca02098e5d792850b3e36b0598925230a Mon Sep 17 00:00:00 2001 From: Axel Gathelier <130740013+GolfOcean334@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:52:08 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 028b802..f482d70 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab - **Diffuse Lighting** - **Ambiant Lighting** - **Specular Lighting** + - **Light Shader** + - **Light Map Shader** - **Alpha Mapping** - **Normal Mapping** - **Specular Mapping**