-
Notifications
You must be signed in to change notification settings - Fork 13
/
Material.h
60 lines (47 loc) · 1.81 KB
/
Material.h
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
#pragma once
#include <d3d11.h>
#include <wrl/client.h>
#include <DirectXMath.h>
#include <memory>
#include <unordered_map>
#include "SimpleShader.h"
#include "Camera.h"
#include "Transform.h"
class Material
{
public:
Material(
std::shared_ptr<SimplePixelShader> ps,
std::shared_ptr<SimpleVertexShader> vs,
DirectX::XMFLOAT3 tint,
DirectX::XMFLOAT2 uvScale = DirectX::XMFLOAT2(1, 1),
DirectX::XMFLOAT2 uvOffset = DirectX::XMFLOAT2(0, 0));
std::shared_ptr<SimplePixelShader> GetPixelShader();
std::shared_ptr<SimpleVertexShader> GetVertexShader();
DirectX::XMFLOAT2 GetUVScale();
DirectX::XMFLOAT2 GetUVOffset();
DirectX::XMFLOAT3 GetColorTint();
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> GetTextureSRV(std::string name);
Microsoft::WRL::ComPtr<ID3D11SamplerState> GetSampler(std::string name);
void SetPixelShader(std::shared_ptr<SimplePixelShader> ps);
void SetVertexShader(std::shared_ptr<SimpleVertexShader> ps);
void SetUVScale(DirectX::XMFLOAT2 scale);
void SetUVOffset(DirectX::XMFLOAT2 offset);
void SetColorTint(DirectX::XMFLOAT3 tint);
void AddTextureSRV(std::string name, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv);
void AddSampler(std::string name, Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler);
void RemoveTextureSRV(std::string name);
void RemoveSampler(std::string name);
void PrepareMaterial(Transform* transform, std::shared_ptr<Camera> camera);
private:
// Shaders
std::shared_ptr<SimplePixelShader> ps;
std::shared_ptr<SimpleVertexShader> vs;
// Material properties
DirectX::XMFLOAT3 colorTint;
// Texture-related
DirectX::XMFLOAT2 uvOffset;
DirectX::XMFLOAT2 uvScale;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>> textureSRVs;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11SamplerState>> samplers;
};