Skybox WIP
This commit is contained in:
parent
296e04692a
commit
172db0b96d
@ -222,11 +222,8 @@ bool SystemClass::Frame()
|
||||
LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
|
||||
Logger::Get().Log("Message received: " + std::to_string(umsg), __FILE__, __LINE__, Logger::LogLevel::Input);
|
||||
|
||||
if (ImGui_ImplWin32_WndProcHandler(hwnd, umsg, wparam, lparam))
|
||||
{
|
||||
Logger::Get().Log("ImGui_ImplWin32_WndProcHandler handled the message", __FILE__, __LINE__, Logger::LogLevel::Input);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -235,7 +232,6 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
|
||||
// Check if a key has been pressed on the keyboard.
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
Logger::Get().Log("WM_KEYDOWN received: " + std::to_string(wparam), __FILE__, __LINE__, Logger::LogLevel::Input);
|
||||
// If a key is pressed send it to the input object so it can record that state.
|
||||
m_Input->KeyDown((unsigned int)wparam);
|
||||
return 0;
|
||||
@ -244,7 +240,6 @@ LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam
|
||||
// Check if a key has been released on the keyboard.
|
||||
case WM_KEYUP:
|
||||
{
|
||||
Logger::Get().Log("WM_KEYUP received: " + std::to_string(wparam), __FILE__, __LINE__,Logger::LogLevel::Input);
|
||||
// If a key is released then send it to the input object so it can unset the state for that key.
|
||||
m_Input->KeyUp((unsigned int)wparam);
|
||||
return 0;
|
||||
|
@ -62,6 +62,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
m_RenderQueues.push_back(std::ref(m_object));
|
||||
m_RenderQueues.push_back(std::ref(m_cubes));
|
||||
m_RenderQueues.push_back(std::ref(m_terrainChunk));
|
||||
m_RenderQueues.push_back(std::ref(m_Skybox));
|
||||
|
||||
m_screenWidth = screenWidth;
|
||||
m_screenHeight = screenHeight;
|
||||
@ -424,6 +425,8 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
|
||||
m_PhysicsThread = std::thread(&ApplicationClass::PhysicsThreadFunction, this);
|
||||
|
||||
ConstructSkybox();
|
||||
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@ -791,10 +794,6 @@ bool ApplicationClass::Frame(InputClass* Input)
|
||||
m_Inputs.m_KeyUp = Input->IsUpArrowPressed();
|
||||
m_Inputs.m_KeyDown = Input->IsDownArrowPressed();
|
||||
|
||||
|
||||
|
||||
//RenderPhysics(m_Inputs.m_KeyLeft, m_Inputs.m_KeyRight, m_Inputs.m_KeyUp, m_Inputs.m_KeyDown, frameTime);
|
||||
|
||||
// Render the scene to a render texture.
|
||||
result = RenderSceneToTexture(rotation);
|
||||
if (!result)
|
||||
@ -967,6 +966,9 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
projectionMatrix = m_Direct3D->GetProjectionMatrix();
|
||||
orthoMatrix = m_Direct3D->GetOrthoMatrix();
|
||||
|
||||
//Render Sky box
|
||||
//RenderSkybox(viewMatrix, projectionMatrix);
|
||||
|
||||
// Get the light properties.
|
||||
for (i = 0; i < m_numLights; i++)
|
||||
{
|
||||
@ -1012,7 +1014,6 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||
diffuseColor, lightPosition, ambientColor);
|
||||
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// ------------ Render the object in the queue ------------ //
|
||||
// -------------------------------------------------------- //
|
||||
@ -1837,6 +1838,12 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
float z = XMVectorGetZ(objposition);
|
||||
float radius = object->GetBoundingRadius();
|
||||
|
||||
// Check if the object has physics enabled
|
||||
if (object->IsPhysicsEnabled())
|
||||
{
|
||||
object->UpdatePosition(m_Timer->GetTime());
|
||||
}
|
||||
|
||||
// Vérifie si l'objet est dans le frustum
|
||||
if (!m_FrustumCulling.CheckCube(x, y, z, radius, GetFrustumTolerance()))
|
||||
{
|
||||
@ -1904,6 +1911,40 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApplicationClass::ConstructSkybox() {
|
||||
Logger::Get().Log("Constructing skybox", __FILE__, __LINE__);
|
||||
// Set the file name of the model.
|
||||
char modelFilename[128];
|
||||
strcpy_s(modelFilename, "assets/Model/TXT/cube.txt");
|
||||
// Liste des fichiers de texture
|
||||
std::vector<std::wstring> skyboxTexture = {
|
||||
L"assets/Skybox/skybox_front.png",
|
||||
L"assets/Skybox/skybox_back.png",
|
||||
L"assets/Skybox/skybox_left.png",
|
||||
L"assets/Skybox/skybox_right.png",
|
||||
L"assets/Skybox/skybox_top.png",
|
||||
L"assets/Skybox/skybox_bottom.png"
|
||||
};
|
||||
textures.clear();
|
||||
for (const auto& textureFilename : skyboxTexture)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), textureFilename.c_str(), nullptr, &texture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
}
|
||||
Object* newSkybox = new Object();
|
||||
newSkybox->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
newSkybox->SetScaleMatrix(XMMatrixScaling(100.0f, 100.0f, 100.0f));
|
||||
newSkybox->SetTranslateMatrix(XMMatrixTranslation(0.0f, 0.0f, 0.0f));
|
||||
newSkybox->SetType(ObjectType::Cube);
|
||||
m_object.push_back(newSkybox);
|
||||
}
|
||||
|
||||
void ApplicationClass::ConstructFrustum()
|
||||
{
|
||||
XMMATRIX projectionMatrix = m_Direct3D->GetProjectionMatrix();
|
||||
@ -1980,10 +2021,6 @@ bool ApplicationClass::RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bo
|
||||
object->SetVelocity(velocity);
|
||||
}
|
||||
|
||||
XMVECTOR position = object->GetPosition();
|
||||
position = position + object->GetVelocity() * deltaTime;
|
||||
object->SetPosition(position);
|
||||
|
||||
m_Physics->ApplyGravity(object, deltaTime);
|
||||
|
||||
if (XMVectorGetY(object->GetPosition()) < -30.0f) {
|
||||
@ -2022,3 +2059,29 @@ void ApplicationClass::PhysicsThreadFunction()
|
||||
}
|
||||
}
|
||||
|
||||
bool ApplicationClass::LoadSkyboxTextures()
|
||||
{
|
||||
std::vector<std::wstring> skyboxTextures = {
|
||||
L"assets/Skybox/skybox_front.png",
|
||||
L"assets/Skybox/skybox_back.png",
|
||||
L"assets/Skybox/skybox_left.png",
|
||||
L"assets/Skybox/skybox_right.png",
|
||||
L"assets/Skybox/skybox_top.png",
|
||||
L"assets/Skybox/skybox_bottom.png"
|
||||
};
|
||||
|
||||
for (const auto& textureFilename : skyboxTextures)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), textureFilename.c_str(), nullptr, &texture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to load skybox texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
m_SkyboxTextures.push_back(texture);
|
||||
}
|
||||
Logger::Get().Log("Loaded " + std::to_string(m_SkyboxTextures.size()) + " skybox textures", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
return true;
|
||||
}
|
@ -104,8 +104,6 @@ public:
|
||||
|
||||
void SetCelShading(bool enable) { m_enableCelShading = enable; };
|
||||
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
|
||||
void SetVsync(bool vsync);
|
||||
bool GetVsync() const { return VSYNC_ENABLED; };
|
||||
|
||||
@ -148,6 +146,12 @@ private:
|
||||
bool RenderReflectionToTexture();
|
||||
bool RenderPass(const std::vector<std::reference_wrapper<std::vector<Object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
|
||||
|
||||
bool LoadSkyboxTextures();
|
||||
void ConstructSkybox();
|
||||
|
||||
public :
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
std::vector<ID3D11ShaderResourceView*> m_SkyboxTextures;
|
||||
|
||||
private :
|
||||
|
||||
@ -186,6 +190,7 @@ private :
|
||||
std::vector<Object*> m_object;
|
||||
int m_ObjectId = 0;
|
||||
std::vector<std::reference_wrapper<std::vector<Object*>>> m_RenderQueues;
|
||||
std::vector<Object*> m_Skybox;
|
||||
|
||||
// ----------------------------------- //
|
||||
// ------------- LIGHTS -------------- //
|
||||
|
BIN
enginecustom/assets/Skybox/skybox_back.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 302 KiB |
BIN
enginecustom/assets/Skybox/skybox_bottom.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 230 KiB |
BIN
enginecustom/assets/Skybox/skybox_front.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_front.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 441 KiB |
BIN
enginecustom/assets/Skybox/skybox_left.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 KiB |
BIN
enginecustom/assets/Skybox/skybox_right.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 458 KiB |
BIN
enginecustom/assets/Skybox/skybox_top.png
Normal file
BIN
enginecustom/assets/Skybox/skybox_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 352 KiB |
@ -314,6 +314,24 @@
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture\</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_back.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_bottom.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_front.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_left.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_right.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_top.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox\</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<Image Include="KhaoticIcon.ico" />
|
||||
<CopyFileToFolders Include="sprite01.tga" />
|
||||
<CopyFileToFolders Include="sprite02.tga" />
|
||||
|
@ -61,6 +61,9 @@
|
||||
<Filter Include="Fichiers sources\System">
|
||||
<UniqueIdentifier>{b2659b1e-695d-488e-9a1c-341691d312bc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Assets\Skybox">
|
||||
<UniqueIdentifier>{4bfa47c6-e23c-4cae-a7af-3fc870a448e4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp">
|
||||
@ -623,5 +626,23 @@
|
||||
<CopyFileToFolders Include="assets\Texture\water01.png">
|
||||
<Filter>Assets\Texture</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_back.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_bottom.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_front.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_left.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_right.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox_top.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -10,14 +10,14 @@ Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=8,407
|
||||
Size=290,377
|
||||
Pos=8,27
|
||||
Size=290,826
|
||||
Collapsed=0
|
||||
DockId=0x0000000A,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=8,27
|
||||
Size=290,566
|
||||
Size=290,413
|
||||
Collapsed=0
|
||||
DockId=0x00000009,0
|
||||
|
||||
@ -35,7 +35,7 @@ DockId=0x00000004,2
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1180,27
|
||||
Size=396,566
|
||||
Size=396,598
|
||||
Collapsed=0
|
||||
DockId=0x00000005,1
|
||||
|
||||
@ -44,8 +44,8 @@ Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Render Window]
|
||||
Pos=8,27
|
||||
Size=1170,826
|
||||
Pos=300,27
|
||||
Size=878,826
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
@ -66,8 +66,8 @@ Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=8,595
|
||||
Size=1568,258
|
||||
Pos=8,627
|
||||
Size=1568,226
|
||||
Collapsed=0
|
||||
DockId=0x0000000E,0
|
||||
|
||||
@ -78,7 +78,7 @@ DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||
DockNode ID=0x00000006 Parent=0x00000001 SizeRef=330,485 Selected=0x031DC75C
|
||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
||||
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,566 Split=Y
|
||||
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,598 Split=Y
|
||||
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X
|
||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=290,826 Split=Y Selected=0x393905AB
|
||||
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x393905AB
|
||||
@ -87,5 +87,5 @@ DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
||||
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=878,826 CentralNode=1 Selected=0x9204953B
|
||||
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=396,826 Selected=0x9F035453
|
||||
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
|
||||
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,258 Selected=0xAB74BEE9
|
||||
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
||||
|
||||
|
@ -253,3 +253,10 @@ float Object::GetBoundingRadius() const
|
||||
{
|
||||
return m_boundingRadius;
|
||||
}
|
||||
|
||||
void Object::UpdatePosition(float deltaTime)
|
||||
{
|
||||
XMVECTOR position = GetPosition();
|
||||
position = position + GetVelocity() * deltaTime;
|
||||
SetPosition(position);
|
||||
}
|
@ -55,6 +55,8 @@ public:
|
||||
void UpdateRotateMatrix();
|
||||
void UpdateTranslateMatrix();
|
||||
|
||||
void UpdatePosition(float deltaTime);
|
||||
|
||||
void Update();
|
||||
|
||||
std::string GetName();
|
||||
|
@ -13,20 +13,17 @@ ShaderManagerClass::ShaderManagerClass()
|
||||
m_LightMapShader = 0;
|
||||
m_RefractionShader = 0;
|
||||
m_WaterShader = 0;
|
||||
m_CelShadingShader = 0;
|
||||
m_CelShadingShader = 0;
|
||||
}
|
||||
|
||||
|
||||
ShaderManagerClass::ShaderManagerClass(const ShaderManagerClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ShaderManagerClass::~ShaderManagerClass()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
Logger::Get().Log("Initializing ShaderManagerClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
@ -35,7 +32,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the texture shader object.
|
||||
m_TextureShader = new TextureShaderClass;
|
||||
|
||||
result = m_TextureShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -45,7 +41,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the normal map shader object.
|
||||
m_NormalMapShader = new NormalMapShaderClass;
|
||||
|
||||
result = m_NormalMapShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -55,7 +50,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the multitexture shader object.
|
||||
m_MultitextureShader = new MultiTextureShaderClass;
|
||||
|
||||
result = m_MultitextureShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -65,7 +59,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the translate shader object.
|
||||
m_TranslateShader = new TranslateShaderClass;
|
||||
|
||||
result = m_TranslateShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -75,7 +68,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the alpha map shader object.
|
||||
m_AlphaMapShader = new AlphaMapShaderClass;
|
||||
|
||||
result = m_AlphaMapShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -85,7 +77,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the specular map shader object.
|
||||
m_SpecMapShader = new SpecMapShaderClass;
|
||||
|
||||
result = m_SpecMapShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -95,7 +86,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the transparent shader object.
|
||||
m_TransparentShader = new TransparentShaderClass;
|
||||
|
||||
result = m_TransparentShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -105,7 +95,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the light shader object.
|
||||
m_LightShader = new LightShaderClass;
|
||||
|
||||
result = m_LightShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -115,7 +104,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the light map shader object.
|
||||
m_LightMapShader = new LightMapShaderClass;
|
||||
|
||||
result = m_LightMapShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -125,7 +113,6 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the refraction shader object.
|
||||
m_RefractionShader = new RefractionShaderClass;
|
||||
|
||||
result = m_RefractionShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
@ -134,20 +121,18 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
// Create and initialize the water shader object.
|
||||
m_WaterShader = new WaterShaderClass;
|
||||
|
||||
result = m_WaterShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_CelShadingShader = new CelShadingShader;
|
||||
|
||||
result = m_CelShadingShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_CelShadingShader = new CelShadingShader;
|
||||
result = m_CelShadingShader->Initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("ShaderManagerClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
@ -182,7 +167,7 @@ void ShaderManagerClass::Shutdown()
|
||||
m_MultitextureShader = 0;
|
||||
}
|
||||
|
||||
// Release the multitexture shader object.
|
||||
// Release the translate shader object.
|
||||
if (m_TranslateShader)
|
||||
{
|
||||
m_TranslateShader->Shutdown();
|
||||
@ -246,10 +231,15 @@ void ShaderManagerClass::Shutdown()
|
||||
m_WaterShader = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("ShaderManagerClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
// Release the cel shading shader object.
|
||||
if (m_CelShadingShader)
|
||||
{
|
||||
m_CelShadingShader->Shutdown();
|
||||
delete m_CelShadingShader;
|
||||
m_CelShadingShader = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
Logger::Get().Log("ShaderManagerClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
||||
|
||||
bool ShaderManagerClass::RenderTextureShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
@ -257,7 +247,6 @@ bool ShaderManagerClass::RenderTextureShader(ID3D11DeviceContext* deviceContext,
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_TextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture);
|
||||
if (!result)
|
||||
{
|
||||
@ -273,7 +262,6 @@ bool ShaderManagerClass::RenderNormalMapShader(ID3D11DeviceContext* deviceContex
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_NormalMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, colorTexture, normalTexture, lightDirection, diffuseColor);
|
||||
if (!result)
|
||||
{
|
||||
@ -289,7 +277,6 @@ bool ShaderManagerClass::RenderMultitextureShader(ID3D11DeviceContext* deviceCon
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_MultitextureShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
@ -305,7 +292,6 @@ bool ShaderManagerClass::RenderTranslateShader(ID3D11DeviceContext* deviceContex
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_TranslateShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, valeur);
|
||||
if (!result)
|
||||
{
|
||||
@ -321,7 +307,6 @@ bool ShaderManagerClass::RenderAlphaMapShader(ID3D11DeviceContext* deviceContext
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_AlphaMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3);
|
||||
if (!result)
|
||||
{
|
||||
@ -338,8 +323,7 @@ bool ShaderManagerClass::RenderSpecMapShader(ID3D11DeviceContext* deviceContext,
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_SpecMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
|
||||
result = m_SpecMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, texture3, lightDirection,
|
||||
diffuseColor, cameraPosition, specularColor, specularPower);
|
||||
if (!result)
|
||||
{
|
||||
@ -355,7 +339,6 @@ bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceCont
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_TransparentShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, blendAmount);
|
||||
if (!result)
|
||||
{
|
||||
@ -371,7 +354,6 @@ bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, i
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_LightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition, ambientColor);
|
||||
if (!result)
|
||||
{
|
||||
@ -386,7 +368,6 @@ bool ShaderManagerClass::RenderlightMapShader(ID3D11DeviceContext* deviceContext
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_LightMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
|
||||
if (!result)
|
||||
{
|
||||
@ -401,7 +382,6 @@ bool ShaderManagerClass::RenderRefractionShader(ID3D11DeviceContext* deviceConte
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_RefractionShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor, lightPosition, clipPlane);
|
||||
if (!result)
|
||||
{
|
||||
@ -417,7 +397,6 @@ bool ShaderManagerClass::RenderWaterShader(ID3D11DeviceContext* deviceContext, i
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
result = m_WaterShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, reflectionTexture,
|
||||
refractionTexture, normalTexture, waterTranslation, reflectRefractScale);
|
||||
if (!result)
|
||||
@ -434,10 +413,10 @@ bool ShaderManagerClass::RenderCelShadingShader(ID3D11DeviceContext* deviceConte
|
||||
bool result;
|
||||
|
||||
result = m_CelShadingShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, diffuseColor, lightPosition);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
#ifndef _SHADERMANAGERCLASS_H_
|
||||
#define _SHADERMANAGERCLASS_H_
|
||||
|
||||
///////////////////////
|
||||
// MY CLASS INCLUDES //
|
||||
///////////////////////
|
||||
// Inclure les en-têtes nécessaires
|
||||
#include <d3d11.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <vector>
|
||||
#include "textureshaderclass.h"
|
||||
#include "normalmapshaderclass.h"
|
||||
#include "Multitextureshaderclass.h"
|
||||
#include "multitextureshaderclass.h"
|
||||
#include "translateshaderclass.h"
|
||||
#include "alphamapshaderclass.h"
|
||||
#include "specmapshaderclass.h"
|
||||
@ -15,12 +16,10 @@
|
||||
#include "lightmapshaderclass.h"
|
||||
#include "refractionshaderclass.h"
|
||||
#include "watershaderclass.h"
|
||||
#include "CelShadingShader.h"
|
||||
#include "celshadingshader.h"
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: ShaderManagerClass
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class ShaderManagerClass
|
||||
{
|
||||
public:
|
||||
@ -30,21 +29,21 @@ public:
|
||||
|
||||
bool Initialize(ID3D11Device*, HWND);
|
||||
void Shutdown();
|
||||
|
||||
bool RenderTextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);
|
||||
bool RenderNormalMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4);
|
||||
bool RenderMultitextureShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
|
||||
bool RenderTranslateShader(ID3D11DeviceContext*,int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
|
||||
bool RenderTranslateShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
|
||||
bool RenderAlphaMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
|
||||
bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
|
||||
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
|
||||
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[], XMFLOAT4[]);
|
||||
bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
|
||||
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
|
||||
XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
|
||||
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*,
|
||||
ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
|
||||
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
|
||||
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
|
||||
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
|
||||
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
|
||||
bool RenderSkyboxShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, const std::vector<ID3D11ShaderResourceView*>&);
|
||||
|
||||
private:
|
||||
TextureShaderClass* m_TextureShader;
|
||||
NormalMapShaderClass* m_NormalMapShader;
|
||||
@ -53,12 +52,12 @@ private:
|
||||
AlphaMapShaderClass* m_AlphaMapShader;
|
||||
SpecMapShaderClass* m_SpecMapShader;
|
||||
TransparentShaderClass* m_TransparentShader;
|
||||
|
||||
LightShaderClass* m_LightShader;
|
||||
LightMapShaderClass* m_LightMapShader;
|
||||
RefractionShaderClass* m_RefractionShader;
|
||||
WaterShaderClass* m_WaterShader;
|
||||
CelShadingShader* m_CelShadingShader;
|
||||
CelShadingShader* m_CelShadingShader;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user