Specular Lighting
This commit is contained in:
@@ -114,7 +114,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
}
|
||||
|
||||
// Set the file name of the model.
|
||||
strcpy_s(modelFilename, "cube.txt");
|
||||
strcpy_s(modelFilename, "sphere.txt");
|
||||
|
||||
// Set the file name of the textures.
|
||||
strcpy_s(textureFilename1, "stone01.tga");
|
||||
@@ -146,7 +146,9 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
|
||||
m_Light->SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
m_Light->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Light->SetDirection(1.0f, 0.0f, 0.0f);
|
||||
m_Light->SetDirection(1.0f, 0.0f, 1.0f);
|
||||
m_Light->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Light->SetSpecularPower(32.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -356,7 +358,8 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
||||
|
||||
// Render the model using the light shader.
|
||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||
m_Light->GetDirection(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor());
|
||||
m_Light->GetDirection(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor(),
|
||||
m_Camera->GetPosition(), m_Light->GetSpecularColor(), m_Light->GetSpecularPower());
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@@ -373,14 +376,6 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
||||
// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
|
||||
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),
|
||||
m_Light->GetDirection(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor());
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Turn the Z buffer back on now that all 2D rendering has completed.
|
||||
m_Direct3D->TurnZBufferOn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user