59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <sophia/math.hpp>
|
|
#include <vulkan/vulkan.hpp>
|
|
|
|
#include "vulkan/device.hpp"
|
|
#include "vulkan/pipelines/graphics_pipeline.hpp"
|
|
#include "vulkan/shader.hpp"
|
|
|
|
namespace sophia {
|
|
|
|
class Material {
|
|
public:
|
|
struct PushConstants {
|
|
vk::DeviceAddress data0;
|
|
u64 padding;
|
|
vec4 data1;
|
|
vec4 data2;
|
|
vec4 data3;
|
|
};
|
|
|
|
Material(const Material&) = delete;
|
|
Material& operator=(const Material&) = delete;
|
|
|
|
Material(Device& device, std::unique_ptr<Shader> vertexShader,
|
|
std::unique_ptr<Shader> fragmentShader, vk::Format colorFormat,
|
|
vk::Format depthFormat);
|
|
~Material();
|
|
|
|
void bind(vk::CommandBuffer commandBuffer) const {
|
|
pipeline->bind(commandBuffer);
|
|
}
|
|
vk::PipelineLayout getLayout() const { return pipelineLayout.get(); }
|
|
|
|
private:
|
|
void createPipelineLayout(Device& device);
|
|
|
|
vk::UniquePipelineLayout pipelineLayout;
|
|
std::unique_ptr<GraphicsPipeline> pipeline;
|
|
};
|
|
|
|
class MaterialInstance {
|
|
public:
|
|
void setBaseColor();
|
|
|
|
private:
|
|
Material* material;
|
|
|
|
vec3 base_color = {};
|
|
};
|
|
|
|
// !NOTE: eventually add ecs support for ecs
|
|
// struct MaterialComponent {
|
|
// MaterialInstanceHandle handle;
|
|
// };
|
|
|
|
} // namespace sophia
|