-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterial.cpp
More file actions
54 lines (51 loc) · 1.8 KB
/
Material.cpp
File metadata and controls
54 lines (51 loc) · 1.8 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
#include"Material.h"
//シェーダー上のマテリアルデータを記録するバッファを作成
void Material::createBuffer()
{
shaderMaterialBuffer = bufferFactory->Create(sizeof(ShaderMaterial)
, &shaderMaterial, BufferUsage::UNIFORM, BufferTransferType::NONE);
}
//ディスクリプタセットを作成
void Material::createDescriptorSet(const MaterialProperty& prop)
{
const std::shared_ptr<DescriptorSetLayout> layout =
layoutFactory->Create(LayoutPattern::MATERIAL);
descriptorSet = descriptorSetFactory->Create
(
descriptorSetFactory->getBuilder()
->initProperty()
->withBindingBuffer(0)
->withBuffer(shaderMaterialBuffer)
->withDescriptorSetCount(1)
->withDescriptorSetLayout(layout)
->withRange(sizeof(ShaderMaterial))
->withTypeBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)
->addBufferInfo()
->withBindingImage(1)
->withImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
->withTexture(prop.baseColorTexture)
->withTypeImage(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
->addImageInfo()
->withBindingImage(2)
->withImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
->withTexture(prop.metallicRoughnessTexture)
->withTypeImage(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
->addImageInfo()
->withBindingImage(3)
->withImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
->withTexture(prop.normalTexture)
->withTypeImage(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
->addImageInfo()
->withBindingImage(4)
->withImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
->withTexture(prop.occlusionTexture)
->withTypeImage(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
->addImageInfo()
->withBindingImage(5)
->withImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
->withTexture(prop.emissiveTexture)
->withTypeImage(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
->addImageInfo()
->Build()
);
}