-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseMaterial.h
More file actions
67 lines (61 loc) · 1.19 KB
/
BaseMaterial.h
File metadata and controls
67 lines (61 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "Material.h"
#include "Cube.h"
class BaseMaterial : public Material
{
public:
struct VertexInput
{
struct Vertex
{
float x;
float y;
float z;
} vertex;
struct Color
{
UINT8 r;
UINT8 g;
UINT8 b;
UINT8 a;
} color;
struct UV
{
float u;
float v;
} uv;
struct Normal
{
float x;
float y;
float z;
} normal;
};
struct VertexUniforms
{
DirectX::XMMATRIX ObjectToWorld;
DirectX::XMMATRIX WorldToView;
DirectX::XMVECTOR CamPos;
UINT16 TextureMode;
};
struct FragmentUniforms
{
UINT32 TextureMode;
float LightIntensity;
float LightPos[2];
};
static const UINT32 TEXTUREMODE_DIFFUSE = 0b1;
static const UINT32 TEXTUREMODE_AMBIENT = 0b10;
static const UINT32 TEXTUREMODE_SPECULAR= 0b100;
static const UINT32 TEXTUREMODE_HEIGHT = 0b1000;
BaseMaterial(GraphicsD11& gfx);
~BaseMaterial() = default;
void Draw(GraphicsD11& gfx, Renderable& rend) override;
void Begin(GraphicsD11& gfx, Camera& cam) override;
void UpdateUniforms(GraphicsD11& gfx, Renderable& rend);
void SetTextureMode(UINT32 TextureMode);
private:
VertexUniforms mCurVertexUniforms;
FragmentUniforms mCurFragUniforms;
bool* gTM = nullptr;
};