Ambient lightning + Multitexture (Les shaders ne se superposent pas)
This commit is contained in:
@@ -34,14 +34,14 @@ bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||
|
||||
|
||||
// Set the filename of the vertex shader.
|
||||
error = wcscpy_s(vsFilename, 128, L"../enginecustom/light.vs");
|
||||
error = wcscpy_s(vsFilename, 128, L"light.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"../enginecustom/light.ps");
|
||||
error = wcscpy_s(psFilename, 128, L"light.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
return false;
|
||||
@@ -68,13 +68,13 @@ void LightShaderClass::Shutdown()
|
||||
|
||||
|
||||
bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor)
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, diffuseColor);
|
||||
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, ambientColor, diffuseColor);
|
||||
if(!result)
|
||||
{
|
||||
return false;
|
||||
@@ -340,8 +340,8 @@ void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
|
||||
}
|
||||
|
||||
|
||||
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
|
||||
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor)
|
||||
{
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
@@ -393,6 +393,7 @@ bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
|
||||
dataPtr2 = (LightBufferType*)mappedResource.pData;
|
||||
|
||||
// Copy the lighting variables into the constant buffer.
|
||||
dataPtr2->ambientColor = ambientColor;
|
||||
dataPtr2->diffuseColor = diffuseColor;
|
||||
dataPtr2->lightDirection = lightDirection;
|
||||
dataPtr2->padding = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user