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); Texture2D shaderTexture : register(t0);
SamplerState SampleType : register(s0); SamplerState SampleType : register(s0);
cbuffer LightBuffer cbuffer LightBuffer
{ {
float4 diffuseColor; float4 diffuseColor;
@ -48,9 +47,6 @@ float4 LightPixelShader(PixelInputType input) : SV_TARGET
// Calculate the amount of light on this pixel. // Calculate the amount of light on this pixel.
lightIntensity = saturate(dot(input.normal, lightDir)); 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. // Determine the final amount of diffuse color based on the diffuse color combined with the light intensity.
color = saturate(diffuseColor * lightIntensity); color = saturate(diffuseColor * lightIntensity);

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff