condense lighting creation

This commit is contained in:
lightling 2022-04-03 15:40:50 -04:00
parent c0843b4ae0
commit 20b3fd7d97
Signed by: lightling
GPG key ID: 016F11E0AA296B67
2 changed files with 30 additions and 48 deletions

View file

@ -120,52 +120,13 @@ void Game::LoadLighting()
{
ambient = XMFLOAT3(0.1f, 0.1f, 0.15f);
Light directionalLight0 = {};
directionalLight0.Type = LIGHT_TYPE_DIRECTIONAL;
directionalLight0.Direction = XMFLOAT3(1, 0.5f, 0.5f);
directionalLight0.Color = XMFLOAT3(1, 1, 1);
directionalLight0.Intensity = 0.5f;
Light directionalLight1 = {};
directionalLight1.Type = LIGHT_TYPE_DIRECTIONAL;
directionalLight1.Direction = XMFLOAT3(-0.25f, -1, 0.75f);
directionalLight1.Color = XMFLOAT3(1, 1, 1);
directionalLight1.Intensity = 0.5f;
Light directionalLight2 = {};
directionalLight2.Type = LIGHT_TYPE_DIRECTIONAL;
directionalLight2.Direction = XMFLOAT3(-1, 1, -0.5f);
directionalLight2.Color = XMFLOAT3(1, 1, 1);
directionalLight2.Intensity = 0.5f;
Light pointLight0 = {};
pointLight0.Type = LIGHT_TYPE_POINT;
pointLight0.Position = XMFLOAT3(-1.5f, 0, 0);
pointLight0.Color = XMFLOAT3(1, 1, 1);
pointLight0.Intensity = 0.5f;
pointLight0.Range = 10;
Light pointLight1 = {};
pointLight1.Type = LIGHT_TYPE_POINT;
pointLight1.Position = XMFLOAT3(1.5f, 0, 0);
pointLight1.Color = XMFLOAT3(1, 1, 1);
pointLight1.Intensity = 0.25f;
pointLight1.Range = 10;
Light pointLight2 = {};
pointLight2.Type = LIGHT_TYPE_POINT;
pointLight2.Position = XMFLOAT3(0, 2, 0);
pointLight2.Color = XMFLOAT3(1, 0, 0);
pointLight2.Intensity = 0.25f;
pointLight2.Range = 10;
lights = {
directionalLight0,
directionalLight1,
directionalLight2,
pointLight0,
pointLight1,
pointLight2,
Light::Directional(XMFLOAT3(1, 0.5f, 0.5f), XMFLOAT3(1, 1, 1), 0.5f),
Light::Directional(XMFLOAT3(-0.25f, -1, 0.75f), XMFLOAT3(1, 1, 1), 0.5f),
Light::Directional(XMFLOAT3(-1, 1, -0.5f), XMFLOAT3(1, 1, 1), 0.5f),
Light::Point(XMFLOAT3(-1.5f, 0, 0), XMFLOAT3(1, 1, 1), 0.5f, 10),
Light::Point(XMFLOAT3(1.5f, 0, 0), XMFLOAT3(1, 1, 1), 0.25f, 10),
Light::Point(XMFLOAT3(0, 2, 0), XMFLOAT3(1, 0, 0), 0.25f, 10),
};
}

View file

@ -2,9 +2,9 @@
#include <DirectXMath.h>
#define LIGHT_TYPE_DIRECTIONAL 0
#define LIGHT_TYPE_POINT 1
#define LIGHT_TYPE_SPOT 2
constexpr auto LIGHT_TYPE_DIRECTIONAL = 0;
constexpr auto LIGHT_TYPE_POINT = 1;
constexpr auto LIGHT_TYPE_SPOT = 2;
struct Light
{
@ -16,4 +16,25 @@ struct Light
DirectX::XMFLOAT3 Color;
float SpotFalloff;
DirectX::XMFLOAT3 Padding;
static Light Directional(DirectX::XMFLOAT3 _direction, DirectX::XMFLOAT3 _color, float _intensity)
{
Light light = {};
light.Type = LIGHT_TYPE_DIRECTIONAL;
light.Direction = _direction;
light.Color = _color;
light.Intensity = _intensity;
return light;
};
static Light Point(DirectX::XMFLOAT3 _position, DirectX::XMFLOAT3 _color, float _intensity, float _range)
{
Light light = {};
light.Type = LIGHT_TYPE_POINT;
light.Position = _position;
light.Color = _color;
light.Intensity = _intensity;
light.Range = _range;
return light;
};
};