merge 3d diffuse lighting

This commit is contained in:
StratiX0 2024-03-26 12:02:03 +01:00
parent deea6fa3ba
commit ccb666faaf
7 changed files with 1674 additions and 1679 deletions

View File

@ -8,7 +8,6 @@
/////////////
Texture2D shaderTexture : register(t0);
SamplerState SampleType : register(s0);
cbuffer LightBuffer
{
float4 diffuseColor;
@ -48,9 +47,6 @@ float4 LightPixelShader(PixelInputType input) : SV_TARGET
// Calculate the amount of light on this pixel.
lightIntensity = saturate(dot(input.normal, lightDir));
// Change the diffuse color to red (0, 1, 0)
float3 greenDiffuseColor = float3(1, 0, 0);
// Determine the final amount of diffuse color based on the diffuse color combined with the light intensity.
color = saturate(diffuseColor * lightIntensity);

View File

@ -13,7 +13,6 @@ cbuffer MatrixBuffer
matrix projectionMatrix;
};
//////////////
// TYPEDEFS //
//////////////

View File

@ -1,3 +1,4 @@
#pragma once
////////////////////////////////////////////////////////////////////////////////
// Filename: lightclass.h
////////////////////////////////////////////////////////////////////////////////
@ -22,11 +23,11 @@ public:
LightClass(const LightClass&);
~LightClass();
void SetDiffuseColor(float, float, float, float);
void SetDirection(float, float, float);
void SetDiffuseColor(float, float, float, float);
XMFLOAT4 GetDiffuseColor();
XMFLOAT3 GetDirection();
XMFLOAT4 GetDiffuseColor();
private:
XMFLOAT4 m_diffuseColor;

View File

@ -32,16 +32,15 @@ bool LightShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
int error;
bool result;
// 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;
@ -66,7 +65,6 @@ void LightShaderClass::Shutdown()
return;
}
bool LightShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{
@ -93,10 +91,12 @@ bool LightShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
ID3D10Blob* errorMessage;
ID3D10Blob* vertexShaderBuffer;
ID3D10Blob* pixelShaderBuffer;
D3D11_INPUT_ELEMENT_DESC polygonLayout[3];
unsigned int numElements;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_BUFFER_DESC matrixBufferDesc;
D3D11_BUFFER_DESC lightBufferDesc;
@ -339,7 +339,6 @@ void LightShaderClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
return;
}
bool LightShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor)
{

File diff suppressed because it is too large Load Diff