29 if (!graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_VERTEX_BIT,
"main", renderer.
getInfo().
shadersRoot +
"skybox.vert.spv")
30 || !graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_FRAGMENT_BIT,
"main", renderer.
getInfo().
shadersRoot +
"skybox.frag.spv")) {
31 LUG_LOG.error(
"initPipeline: Can't create skybox shader");
36 auto vertexBinding = graphicsPipelineBuilder.addInputBinding(
sizeof(lug::Math::Vec3f), VK_VERTEX_INPUT_RATE_VERTEX);
38 vertexBinding.addAttributes(VK_FORMAT_R32G32B32_SFLOAT, 0);
42 graphicsPipelineBuilder.setInputAssemblyInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
false);
45 const VkViewport viewport{
54 const VkRect2D scissor{
59 auto viewportState = graphicsPipelineBuilder.getViewportState();
60 viewportState.addViewport(viewport);
61 viewportState.addScissor(scissor);
64 auto rasterizationState = graphicsPipelineBuilder.getRasterizationState();
65 rasterizationState.setFrontFace(VK_FRONT_FACE_CLOCKWISE);
68 const VkPipelineColorBlendAttachmentState colorBlendAttachment{
71 VK_BLEND_FACTOR_CONSTANT_COLOR,
74 VK_BLEND_FACTOR_CONSTANT_COLOR,
76 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
79 auto colorBlendState = graphicsPipelineBuilder.getColorBlendState();
80 colorBlendState.addAttachment(colorBlendAttachment);
82 auto depthStencilState = graphicsPipelineBuilder.getDepthStencilState();
83 depthStencilState.enableDepthTest(VK_COMPARE_OP_LESS_OR_EQUAL);
86 graphicsPipelineBuilder.setDynamicStates({
87 VK_DYNAMIC_STATE_VIEWPORT,
88 VK_DYNAMIC_STATE_SCISSOR
92 std::vector<Vulkan::API::DescriptorSetLayout> descriptorSetLayouts(2);
101 const VkDescriptorSetLayoutBinding binding{
103 VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
105 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
110 VkResult result{VK_SUCCESS};
111 if (!descriptorSetLayoutBuilder.build(descriptorSetLayouts[0], &result)) {
112 LUG_LOG.error(
"initPipeline: Can't create pipeline descriptor sets layout 0: {}", result);
122 const VkDescriptorSetLayoutBinding binding{
124 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
126 VK_SHADER_STAGE_FRAGMENT_BIT,
131 VkResult result{VK_SUCCESS};
132 if (!descriptorSetLayoutBuilder.build(descriptorSetLayouts[1], &result)) {
133 LUG_LOG.error(
"initPipeline: Can't create pipeline descriptor sets layout 1: {}", result);
146 VkResult result{VK_SUCCESS};
147 if (!pipelineLayoutBuilder.build(pipelineLayout, &result)) {
148 LUG_LOG.error(
"initPipeline: Can't create pipeline layout: {}", result);
152 graphicsPipelineBuilder.setPipelineLayout(std::move(pipelineLayout));
159 const VkAttachmentDescription colorAttachment{
162 VK_SAMPLE_COUNT_1_BIT,
163 VK_ATTACHMENT_LOAD_OP_CLEAR,
164 VK_ATTACHMENT_STORE_OP_STORE,
165 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
166 VK_ATTACHMENT_STORE_OP_DONT_CARE,
167 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
168 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
171 auto colorAttachmentIndex = renderPassBuilder.addAttachment(colorAttachment);
175 {VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT},
176 VK_IMAGE_TILING_OPTIMAL,
177 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
180 const VkAttachmentDescription depthAttachment{
183 VK_SAMPLE_COUNT_1_BIT,
184 VK_ATTACHMENT_LOAD_OP_CLEAR,
185 VK_ATTACHMENT_STORE_OP_STORE,
186 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
187 VK_ATTACHMENT_STORE_OP_DONT_CARE,
188 VK_IMAGE_LAYOUT_UNDEFINED,
189 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
192 auto depthAttachmentIndex = renderPassBuilder.addAttachment(depthAttachment);
195 VK_PIPELINE_BIND_POINT_GRAPHICS,
197 {{colorAttachmentIndex, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}},
199 {depthAttachmentIndex, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL},
203 renderPassBuilder.addSubpass(subpassDescription);
205 VkResult result{VK_SUCCESS};
207 if (!renderPassBuilder.build(renderPass, &result)) {
208 LUG_LOG.error(
"initPipeline: Can't create render pass: {}", result);
212 graphicsPipelineBuilder.setRenderPass(std::move(renderPass), 0);
215 VkResult result{VK_SUCCESS};
216 if (!graphicsPipelineBuilder.build(skyBoxPipeline, &result)) {
217 LUG_LOG.error(
"initPipeline: Can't create pipeline: {}", result);
229 if (!graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_VERTEX_BIT,
"main", renderer.
getInfo().
shadersRoot +
"filtercube.vert.spv")
230 || !graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_FRAGMENT_BIT,
"main", renderer.
getInfo().
shadersRoot +
"irradiance.frag.spv")) {
231 LUG_LOG.error(
"initPipeline: Can't create skybox shader");
236 auto vertexBinding = graphicsPipelineBuilder.addInputBinding(
sizeof(lug::Math::Vec3f), VK_VERTEX_INPUT_RATE_VERTEX);
238 vertexBinding.addAttributes(VK_FORMAT_R32G32B32_SFLOAT, 0);
242 graphicsPipelineBuilder.setInputAssemblyInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
false);
245 const VkViewport viewport{
254 const VkRect2D scissor{
259 auto viewportState = graphicsPipelineBuilder.getViewportState();
260 viewportState.addViewport(viewport);
261 viewportState.addScissor(scissor);
264 auto rasterizationState = graphicsPipelineBuilder.getRasterizationState();
265 rasterizationState.setFrontFace(VK_FRONT_FACE_CLOCKWISE);
268 const VkPipelineColorBlendAttachmentState colorBlendAttachment{
271 VK_BLEND_FACTOR_CONSTANT_COLOR,
274 VK_BLEND_FACTOR_CONSTANT_COLOR,
276 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
279 auto colorBlendState = graphicsPipelineBuilder.getColorBlendState();
280 colorBlendState.addAttachment(colorBlendAttachment);
283 graphicsPipelineBuilder.setDynamicStates({
284 VK_DYNAMIC_STATE_VIEWPORT,
285 VK_DYNAMIC_STATE_SCISSOR
289 std::vector<Vulkan::API::DescriptorSetLayout> descriptorSetLayouts(1);
296 const VkDescriptorSetLayoutBinding binding{
298 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
300 VK_SHADER_STAGE_FRAGMENT_BIT,
305 VkResult result{VK_SUCCESS};
306 if (!descriptorSetLayoutBuilder.build(descriptorSetLayouts[0], &result)) {
307 LUG_LOG.error(
"initPipeline: Can't create pipeline descriptor sets layout 1: {}", result);
321 const VkPushConstantRange pushConstant{
322 VK_SHADER_STAGE_VERTEX_BIT,
324 sizeof(Math::Mat4x4f)
327 pipelineLayoutBuilder.setPushConstants({pushConstant});
329 VkResult result{VK_SUCCESS};
330 if (!pipelineLayoutBuilder.build(pipelineLayout, &result)) {
331 LUG_LOG.error(
"initPipeline: Can't create pipeline layout: {}", result);
335 graphicsPipelineBuilder.setPipelineLayout(std::move(pipelineLayout));
342 const VkAttachmentDescription colorAttachment{
344 VK_FORMAT_R32G32B32A32_SFLOAT,
345 VK_SAMPLE_COUNT_1_BIT,
346 VK_ATTACHMENT_LOAD_OP_CLEAR,
347 VK_ATTACHMENT_STORE_OP_STORE,
348 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
349 VK_ATTACHMENT_STORE_OP_DONT_CARE,
350 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
351 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
354 auto colorAttachmentIndex = renderPassBuilder.
addAttachment(colorAttachment);
357 VK_PIPELINE_BIND_POINT_GRAPHICS,
359 {{colorAttachmentIndex, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}},
365 renderPassBuilder.addSubpass(subpassDescription);
367 VkResult result{VK_SUCCESS};
369 if (!renderPassBuilder.build(renderPass, &result)) {
370 LUG_LOG.error(
"initPipeline: Can't create render pass: {}", result);
374 graphicsPipelineBuilder.setRenderPass(std::move(renderPass), 0);
377 VkResult result{VK_SUCCESS};
378 if (!graphicsPipelineBuilder.build(irradianceMapPipeline, &result)) {
379 LUG_LOG.error(
"initPipeline: Can't create pipeline: {}", result);
391 if (!graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_VERTEX_BIT,
"main", renderer.
getInfo().
shadersRoot +
"filtercube.vert.spv")
392 || !graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_FRAGMENT_BIT,
"main", renderer.
getInfo().
shadersRoot +
"prefiltered.frag.spv")) {
393 LUG_LOG.error(
"initPipeline: Can't create skybox shader");
398 auto vertexBinding = graphicsPipelineBuilder.addInputBinding(
sizeof(lug::Math::Vec3f), VK_VERTEX_INPUT_RATE_VERTEX);
400 vertexBinding.addAttributes(VK_FORMAT_R32G32B32_SFLOAT, 0);
404 graphicsPipelineBuilder.setInputAssemblyInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
false);
407 const VkViewport viewport{
416 const VkRect2D scissor{
421 auto viewportState = graphicsPipelineBuilder.getViewportState();
422 viewportState.addViewport(viewport);
423 viewportState.addScissor(scissor);
426 auto rasterizationState = graphicsPipelineBuilder.getRasterizationState();
427 rasterizationState.setFrontFace(VK_FRONT_FACE_CLOCKWISE);
430 const VkPipelineColorBlendAttachmentState colorBlendAttachment{
433 VK_BLEND_FACTOR_CONSTANT_COLOR,
436 VK_BLEND_FACTOR_CONSTANT_COLOR,
438 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
441 auto colorBlendState = graphicsPipelineBuilder.getColorBlendState();
442 colorBlendState.addAttachment(colorBlendAttachment);
445 graphicsPipelineBuilder.setDynamicStates({
446 VK_DYNAMIC_STATE_VIEWPORT,
447 VK_DYNAMIC_STATE_SCISSOR
451 std::vector<Vulkan::API::DescriptorSetLayout> descriptorSetLayouts(1);
458 const VkDescriptorSetLayoutBinding binding{
460 VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
462 VK_SHADER_STAGE_FRAGMENT_BIT,
467 VkResult result{VK_SUCCESS};
468 if (!descriptorSetLayoutBuilder.build(descriptorSetLayouts[0], &result)) {
469 LUG_LOG.error(
"initPipeline: Can't create pipeline descriptor sets layout 1: {}", result);
483 const VkPushConstantRange pushConstantMVP{
484 VK_SHADER_STAGE_VERTEX_BIT,
486 sizeof(Math::Mat4x4f)
490 const VkPushConstantRange pushConstantRoughness{
491 VK_SHADER_STAGE_FRAGMENT_BIT,
492 sizeof(Math::Mat4x4f),
496 pipelineLayoutBuilder.setPushConstants({pushConstantMVP, pushConstantRoughness});
498 VkResult result{VK_SUCCESS};
499 if (!pipelineLayoutBuilder.build(pipelineLayout, &result)) {
500 LUG_LOG.error(
"initPipeline: Can't create pipeline layout: {}", result);
504 graphicsPipelineBuilder.setPipelineLayout(std::move(pipelineLayout));
511 const VkAttachmentDescription colorAttachment{
513 VK_FORMAT_R32G32B32A32_SFLOAT,
514 VK_SAMPLE_COUNT_1_BIT,
515 VK_ATTACHMENT_LOAD_OP_CLEAR,
516 VK_ATTACHMENT_STORE_OP_STORE,
517 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
518 VK_ATTACHMENT_STORE_OP_DONT_CARE,
519 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
520 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
523 auto colorAttachmentIndex = renderPassBuilder.
addAttachment(colorAttachment);
526 VK_PIPELINE_BIND_POINT_GRAPHICS,
528 {{colorAttachmentIndex, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}},
534 renderPassBuilder.addSubpass(subpassDescription);
536 VkResult result{VK_SUCCESS};
538 if (!renderPassBuilder.build(renderPass, &result)) {
539 LUG_LOG.error(
"initPipeline: Can't create render pass: {}", result);
543 graphicsPipelineBuilder.setRenderPass(std::move(renderPass), 0);
546 VkResult result{VK_SUCCESS};
547 if (!graphicsPipelineBuilder.build(irradianceMapPipeline, &result)) {
548 LUG_LOG.error(
"initPipeline: Can't create pipeline: {}", result);
560 if (!graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_VERTEX_BIT,
"main", renderer.
getInfo().
shadersRoot +
"genbrdflut.vert.spv")
561 || !graphicsPipelineBuilder.setShaderFromFile(VK_SHADER_STAGE_FRAGMENT_BIT,
"main", renderer.
getInfo().
shadersRoot +
"genbrdflut.frag.spv")) {
562 LUG_LOG.error(
"initPipeline: Can't create skybox shader");
568 graphicsPipelineBuilder.setInputAssemblyInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
false);
571 const VkViewport viewport{
580 const VkRect2D scissor{
585 auto viewportState = graphicsPipelineBuilder.getViewportState();
586 viewportState.addViewport(viewport);
587 viewportState.addScissor(scissor);
590 auto rasterizationState = graphicsPipelineBuilder.getRasterizationState();
591 rasterizationState.setCullMode(VK_CULL_MODE_NONE);
594 const VkPipelineColorBlendAttachmentState colorBlendAttachment{
597 VK_BLEND_FACTOR_CONSTANT_COLOR,
600 VK_BLEND_FACTOR_CONSTANT_COLOR,
602 VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
605 auto colorBlendState = graphicsPipelineBuilder.getColorBlendState();
606 colorBlendState.addAttachment(colorBlendAttachment);
609 graphicsPipelineBuilder.setDynamicStates({
610 VK_DYNAMIC_STATE_VIEWPORT,
611 VK_DYNAMIC_STATE_SCISSOR
619 VkResult result{VK_SUCCESS};
620 if (!pipelineLayoutBuilder.build(pipelineLayout, &result)) {
621 LUG_LOG.error(
"initPipeline: Can't create pipeline layout: {}", result);
625 graphicsPipelineBuilder.setPipelineLayout(std::move(pipelineLayout));
632 const VkAttachmentDescription colorAttachment{
634 VK_FORMAT_R16G16_SFLOAT,
635 VK_SAMPLE_COUNT_1_BIT,
636 VK_ATTACHMENT_LOAD_OP_CLEAR,
637 VK_ATTACHMENT_STORE_OP_STORE,
638 VK_ATTACHMENT_LOAD_OP_DONT_CARE,
639 VK_ATTACHMENT_STORE_OP_DONT_CARE,
640 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
641 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
644 auto colorAttachmentIndex = renderPassBuilder.
addAttachment(colorAttachment);
647 VK_PIPELINE_BIND_POINT_GRAPHICS,
649 {{colorAttachmentIndex, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL}},
655 renderPassBuilder.addSubpass(subpassDescription);
657 VkResult result{VK_SUCCESS};
659 if (!renderPassBuilder.build(renderPass, &result)) {
660 LUG_LOG.error(
"initPipeline: Can't create render pass: {}", result);
664 graphicsPipelineBuilder.setRenderPass(std::move(renderPass), 0);
667 VkResult result{VK_SUCCESS};
668 if (!graphicsPipelineBuilder.build(brdfLutPipeline, &result)) {
669 LUG_LOG.error(
"initPipeline: Can't create pipeline: {}", result);
677 const std::vector<lug::Math::Vec3f> positions = {
679 {-1.0f, -1.0f, -1.0f},
680 {1.0f, -1.0f, -1.0f},
681 {-1.0f, 1.0f, -1.0f},
685 {-1.0f, -1.0f, 1.0f},
691 {-1.0f, -1.0f, -1.0f},
692 {-1.0f, -1.0f, 1.0f},
693 {-1.0f, 1.0f, -1.0f},
697 {1.0f, -1.0f, -1.0f},
703 {-1.0f, -1.0f, -1.0f},
704 {-1.0f, -1.0f, 1.0f},
705 {1.0f, -1.0f, -1.0f},
709 {-1.0f, 1.0f, -1.0f},
715 const std::vector<uint16_t> indices = {
753 static_cast<uint32_t>(indices.size()),
759 sizeof(lug::Math::Vec3f),
760 static_cast<uint32_t>(positions.size()),
764 skyBoxMesh = meshBuilder.
build();
767 LUG_LOG.error(
"initMesh: Can't create the skyBox mesh");
776 constexpr uint32_t brdfLutSize = 512;
788 LUG_LOG.error(
"Application: Can't create the brdf lut texture layer");
792 brdfLut = textureBuilder.
build();
794 LUG_LOG.error(
"Application: Can't create the brdf lut texture");
806 VkResult result{VK_SUCCESS};
810 if (!graphicsQueue) {
811 LUG_LOG.error(
"Skybox::initBrdfLut: Can't find queue with name queue_graphics");
817 if (!commandPoolBuilder.build(commandPool, &result)) {
818 LUG_LOG.error(
"Skybox::initBrdfLut: Can't create the graphics command pool: {}", result);
824 commandBufferBuilder.
setLevel(VK_COMMAND_BUFFER_LEVEL_PRIMARY);
827 if (!commandBufferBuilder.build(cmdBuffer, &result)) {
828 LUG_LOG.error(
"Skybox::initBrdfLut: Can't create the command buffer: {}", result);
836 if (!fenceBuilder.build(fence, &result)) {
837 LUG_LOG.error(
"Skybox::initBrdfLut: Can't create render fence: {}", result);
848 framebufferBuilder.setRenderPass(renderPass);
849 framebufferBuilder.addAttachment(&vKBrdfLut->
getImageView());
850 framebufferBuilder.setWidth(brdfLutSize);
851 framebufferBuilder.setHeight(brdfLutSize);
853 if (!framebufferBuilder.build(framebuffer, &result)) {
854 LUG_LOG.error(
"tFramebuffers: Can't create framebuffer: {}", result);
862 if (!cmdBuffer.
begin()) {
866 cmdBuffer.bindPipeline(brdfLutPipeline);
871 pipelineBarrier.imageMemoryBarriers.resize(1);
872 pipelineBarrier.imageMemoryBarriers[0].srcAccessMask = 0;
873 pipelineBarrier.imageMemoryBarriers[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
874 pipelineBarrier.imageMemoryBarriers[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
875 pipelineBarrier.imageMemoryBarriers[0].newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
876 pipelineBarrier.imageMemoryBarriers[0].image = &vKBrdfLut->
getImage();
877 pipelineBarrier.imageMemoryBarriers[0].subresourceRange.layerCount = 1;
879 cmdBuffer.pipelineBarrier(pipelineBarrier);
902 const VkViewport vkViewport{
905 static_cast<float>(brdfLutSize),
906 static_cast<float>(brdfLutSize),
911 const VkRect2D scissor{
917 static_cast<uint32_t
>(brdfLutSize),
918 static_cast<uint32_t>(brdfLutSize)
922 cmdBuffer.setViewport({vkViewport});
923 cmdBuffer.setScissor({scissor});
934 cmdBuffer.endRenderPass();
939 pipelineBarrier.imageMemoryBarriers.resize(1);
940 pipelineBarrier.imageMemoryBarriers[0].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
941 pipelineBarrier.imageMemoryBarriers[0].dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
942 pipelineBarrier.imageMemoryBarriers[0].oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
943 pipelineBarrier.imageMemoryBarriers[0].newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
944 pipelineBarrier.imageMemoryBarriers[0].image = &vKBrdfLut->
getImage();
945 pipelineBarrier.imageMemoryBarriers[0].subresourceRange.layerCount = 1;
947 cmdBuffer.pipelineBarrier(pipelineBarrier);
950 if (!cmdBuffer.
end()) {
955 if (!graphicsQueue->
submit(
960 static_cast<VkFence>(fence)
962 LUG_LOG.error(
"Skybox::initBrdfLut: Can't submit work to graphics queue: {}", result);
967 LUG_LOG.error(
"Skybox::initBrdfLut:: Can't wait fence");
987 if (builder._backgroundFilename.size())
994 textureBuilder.
setWrapS(builder._wrapS);
995 textureBuilder.
setWrapT(builder._wrapT);
997 if (!textureBuilder.
addLayer(builder._backgroundFilename)) {
998 LUG_LOG.error(
"Resource::SharedPtr<::lug::Graphics::Render::SkyBox>::build Can't create skybox layers");
1004 LUG_LOG.error(
"Resource::SharedPtr<::lug::Graphics::Render::SkyBox>::build Can't create skyBox texture");
1010 if (builder._environnementFilename.size())
1017 textureBuilder.
setWrapS(builder._wrapS);
1018 textureBuilder.
setWrapT(builder._wrapT);
1020 if (!textureBuilder.
addLayer(builder._environnementFilename,
true)) {
1021 LUG_LOG.error(
"Resource::SharedPtr<::lug::Graphics::Render::SkyBox>::build Can't create skybox layers");
1027 LUG_LOG.error(
"Resource::SharedPtr<::lug::Graphics::Render::SkyBox>::build Can't create skyBox texture");
1041 LUG_LOG.error(
"Resource::SharedPtr<::lug::Graphics::Render::SkyBox>::build Can't init skybox pipeline/mesh resources");
const RenderPass * getRenderPass() const
Resource::SharedPtr< Render::Mesh > build()
lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Texture > _environnementTexture
const API::Image & getImage() const
PrimitiveSet * addPrimitiveSet()
Adds a primitive set to the builder and returns it.
lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Texture > _backgroundTexture
void setDescriptorSetLayouts(std::vector< API::DescriptorSetLayout > descriptorSetLayouts)
void setBindings(const std::vector< VkDescriptorSetLayoutBinding > &bindings)
static bool initMesh(Renderer &renderer, lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Mesh > &skyBoxMesh)
void setMinFilter(Render::Texture::Filter minFilter)
void setName(const std::string &name)
Sets the name.
static lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Mesh > _mesh
void pipelineBarrier(const CmdPipelineBarrier ¶meters, VkDependencyFlags dependencyFlags=VK_DEPENDENCY_BY_REGION_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) const
const API::Queue * getQueue(const std::string &queueName) const
bool submit(const CommandBuffer &commandBuffer, const std::vector< VkSemaphore > &signalSemaphores={}, const std::vector< VkSemaphore > &waitSemaphores={}, const std::vector< VkPipelineStageFlags > &waitDstStageMasks={}, VkFence fence=VK_NULL_HANDLE) const
void setWrapS(Render::Texture::WrappingMode wrapS)
void addAttributeBuffer(const void *data, uint32_t elementSize, uint32_t elementsCount, Render::Mesh::PrimitiveSet::Attribute::Type type)
void setLevel(VkCommandBufferLevel level)
static uint32_t _skyBoxCount
Store the number of skybox created to know when to create/destroy the pipeline and mesh...
static API::GraphicsPipeline _pipeline
AttachmentIndex addAttachment(const VkAttachmentDescription &attachmentDescription)
static bool initPrefilteredMapPipeline(Renderer &renderer, API::GraphicsPipeline &irradianceMapPipeline)
static bool initBrdfLutPipeline(Renderer &renderer, API::GraphicsPipeline &brdfLutPipeline)
static bool initIrradianceMapPipeline(Renderer &renderer, API::GraphicsPipeline &irradianceMapPipeline)
const API::Swapchain & getSwapchain() const
void setMagFilter(Render::Texture::Filter magFilter)
const VkSurfaceFormatKHR & getFormat() const
void beginRenderPass(const API::RenderPass &renderPass, const CmdBeginRenderPass ¶meters, VkSubpassContents contents=VK_SUBPASS_CONTENTS_INLINE) const
bool addLayer(const std::string &filename, bool hdr=false)
static bool initBrdfLut(Renderer &renderer, API::GraphicsPipeline &brdfLutPipeline, lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Texture > &brdfLut)
const QueueFamily * getQueueFamily() const
void setWrapT(Render::Texture::WrappingMode wrapT)
static API::GraphicsPipeline _prefilteredMapPipeline
static bool initSkyBoxPipeline(Renderer &renderer, API::GraphicsPipeline &skyBoxPipeline)
static VkFormat findSupportedFormat(const Device &device, const std::set< VkFormat > &formats, VkImageTiling tiling, VkFormatFeatureFlags features)
Resource::SharedPtr< lug::Graphics::Render::SkyBox > build(const ::lug::Graphics::Builder::SkyBox &builder)
Render::Window * getRenderWindow() const
static SharedPtr< T > cast(const SharedPtr< RhsT > &rhs)
Dynamic casting of a SharedPtr to another one (RhsT to T)
const InitInfo & getInfo() const
void setMipMapFilter(Render::Texture::Filter mipMapFilter)
API::Device & getDevice()
void setMode(Render::Mesh::PrimitiveSet::Mode mode)
const API::ImageView & getImageView() const
Resource::SharedPtr< Render::Texture > build()
static lug::Graphics::Resource::SharedPtr< lug::Graphics::Render::Texture > _brdfLut
bool begin(VkCommandBufferUsageFlags flags=VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) const
static API::GraphicsPipeline _irradianceMapPipeline
static API::GraphicsPipeline _brdfLutPipeline