forked from vixorien/AdvancedDX11Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterial.h
49 lines (39 loc) · 1.54 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
#pragma once
#include <d3d11.h>
#include <DirectXMath.h>
#include <wrl/client.h>
#include <unordered_map>
#include "SimpleShader.h"
#include "Camera.h"
#include "Lights.h"
class Material
{
public:
Material(
SimpleVertexShader* vs,
SimplePixelShader* ps,
DirectX::XMFLOAT4 color,
float shininess,
DirectX::XMFLOAT2 uvScale);
~Material();
void PrepareMaterial(Transform* transform, Camera* cam);
void SetPerMaterialDataAndResources(bool copyToGPUNow = true);
SimpleVertexShader* GetVS() { return vs; }
SimplePixelShader* GetPS() { return ps; }
void SetVS(SimpleVertexShader* vs) { this->vs = vs; }
void SetPS(SimplePixelShader* ps) { this->ps = ps; }
void AddPSTextureSRV(std::string shaderName, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv);
void AddVSTextureSRV(std::string shaderName, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> srv);
void AddPSSampler(std::string shaderName, Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler);
void AddVSSampler(std::string shaderName, Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler);
private:
SimpleVertexShader* vs;
SimplePixelShader* ps;
DirectX::XMFLOAT2 uvScale;
DirectX::XMFLOAT4 color;
float shininess;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>> psTextureSRVs;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>> vsTextureSRVs;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11SamplerState>> psSamplers;
std::unordered_map<std::string, Microsoft::WRL::ComPtr<ID3D11SamplerState>> vsSamplers;
};