Light Shader à corriger
This commit is contained in:
parent
05f12d15f9
commit
d286e71ebe
@ -5,9 +5,6 @@ ApplicationClass::ApplicationClass()
|
|||||||
m_Direct3D = 0;
|
m_Direct3D = 0;
|
||||||
m_Camera = 0;
|
m_Camera = 0;
|
||||||
m_Model = 0;
|
m_Model = 0;
|
||||||
m_LightShader = 0;
|
|
||||||
m_Light = 0;
|
|
||||||
m_TextureShader = 0;
|
|
||||||
m_Bitmap = 0;
|
m_Bitmap = 0;
|
||||||
m_Sprite = 0;
|
m_Sprite = 0;
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
@ -94,17 +91,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
|||||||
return false;
|
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.
|
// Create and initialize the render to texture object.
|
||||||
m_RenderTexture = new RenderTextureClass;
|
m_RenderTexture = new RenderTextureClass;
|
||||||
|
|
||||||
@ -196,16 +182,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
|||||||
return false;
|
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.
|
// Create and initialize the light object.
|
||||||
m_Light = new LightClass;
|
m_Light = new LightClass;
|
||||||
|
|
||||||
@ -259,8 +235,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create and initialize the font shader object.
|
// Create and initialize the font shader object.
|
||||||
m_FontShader = new FontShaderClass;
|
m_FontShader = new FontShaderClass;
|
||||||
|
|
||||||
@ -454,14 +428,6 @@ void ApplicationClass::Shutdown()
|
|||||||
m_Light = 0;
|
m_Light = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the light shader object.
|
|
||||||
if (m_LightShader)
|
|
||||||
{
|
|
||||||
m_LightShader->Shutdown();
|
|
||||||
delete m_LightShader;
|
|
||||||
m_LightShader = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the model object.
|
// Release the model object.
|
||||||
if (m_Model)
|
if (m_Model)
|
||||||
{
|
{
|
||||||
@ -637,7 +603,8 @@ bool ApplicationClass::RenderSceneToTexture(float rotation)
|
|||||||
// Render the model using the texture shader.
|
// Render the model using the texture shader.
|
||||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
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)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
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());
|
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
// Render the model using the light shader.
|
// 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);
|
diffuseColor, lightPosition);
|
||||||
|
|
||||||
for (auto cube : m_cubes)
|
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());
|
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);
|
diffuseColor, lightPosition);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@ -742,7 +709,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
|||||||
|
|
||||||
object->Render(m_Direct3D->GetDeviceContext());
|
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);
|
diffuseColor, lightPosition);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
@ -764,7 +731,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
|||||||
|
|
||||||
chunk->Render(m_Direct3D->GetDeviceContext());
|
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);
|
diffuseColor, lightPosition);
|
||||||
if (!result)
|
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.
|
// Render the display plane using the texture shader and the render texture resource.
|
||||||
m_DisplayPlane->Render(m_Direct3D->GetDeviceContext());
|
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)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
// Render the display plane using the texture shader and the render texture resource.
|
||||||
m_DisplayPlane->Render(m_Direct3D->GetDeviceContext());
|
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)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
// Render the display plane using the texture shader and the render texture resource.
|
||||||
m_DisplayPlane->Render(m_Direct3D->GetDeviceContext());
|
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)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
// Render the model using the light shader.
|
||||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||||
m_Model->GetTexture(0), diffuseColor, lightPosition);
|
diffuseColor, lightPosition);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
// 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)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -1056,6 +1027,20 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
|||||||
return false;
|
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.
|
// Turn off alpha blending.
|
||||||
m_Direct3D->DisableAlphaBlending();
|
m_Direct3D->DisableAlphaBlending();
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "lightmapshaderclass.h"
|
#include "lightmapshaderclass.h"
|
||||||
#include "bitmapclass.h"
|
#include "bitmapclass.h"
|
||||||
#include "spriteclass.h"
|
#include "spriteclass.h"
|
||||||
#include "textureshaderclass.h"
|
|
||||||
#include "timerclass.h"
|
#include "timerclass.h"
|
||||||
#include "fontshaderclass.h"
|
#include "fontshaderclass.h"
|
||||||
#include "fontclass.h"
|
#include "fontclass.h"
|
||||||
@ -30,8 +29,6 @@
|
|||||||
#include "rendertextureclass.h"
|
#include "rendertextureclass.h"
|
||||||
#include "displayplaneclass.h"
|
#include "displayplaneclass.h"
|
||||||
#include "reflectionshaderclass.h"
|
#include "reflectionshaderclass.h"
|
||||||
#include "transparentshaderclass.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -9,6 +9,7 @@ ShaderManagerClass::ShaderManagerClass()
|
|||||||
m_AlphaMapShader = 0;
|
m_AlphaMapShader = 0;
|
||||||
m_SpecMapShader = 0;
|
m_SpecMapShader = 0;
|
||||||
m_TransparentShader = 0;
|
m_TransparentShader = 0;
|
||||||
|
m_LightShader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +90,15 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +160,14 @@ void ShaderManagerClass::Shutdown()
|
|||||||
m_TransparentShader = 0;
|
m_TransparentShader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release the transparent shader object.
|
||||||
|
if (m_LightShader)
|
||||||
|
{
|
||||||
|
m_LightShader->Shutdown();
|
||||||
|
delete m_LightShader;
|
||||||
|
m_LightShader = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -258,5 +276,20 @@ bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceCont
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
@ -11,6 +11,7 @@
|
|||||||
#include "alphamapshaderclass.h"
|
#include "alphamapshaderclass.h"
|
||||||
#include "specmapshaderclass.h"
|
#include "specmapshaderclass.h"
|
||||||
#include "transparentshaderclass.h"
|
#include "transparentshaderclass.h"
|
||||||
|
#include "lightshaderclass.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -33,6 +34,7 @@ public:
|
|||||||
bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
|
bool RenderSpecMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*,
|
||||||
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
|
XMFLOAT3, XMFLOAT4, XMFLOAT3, XMFLOAT4, float);
|
||||||
bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
|
bool RenderTransparentShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, float);
|
||||||
|
bool RenderlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4[], XMFLOAT4[]);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureShaderClass* m_TextureShader;
|
TextureShaderClass* m_TextureShader;
|
||||||
@ -42,6 +44,7 @@ private:
|
|||||||
AlphaMapShaderClass* m_AlphaMapShader;
|
AlphaMapShaderClass* m_AlphaMapShader;
|
||||||
SpecMapShaderClass* m_SpecMapShader;
|
SpecMapShaderClass* m_SpecMapShader;
|
||||||
TransparentShaderClass* m_TransparentShader;
|
TransparentShaderClass* m_TransparentShader;
|
||||||
|
LightShaderClass* m_LightShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user