From 5722e62605a0a3145f7d6d5f4c7c15ccf1b4fa4d Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 26 Oct 2020 22:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E6=B8=B2=E6=9F=93=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E4=B8=96=E7=95=8C=E5=9D=90=E6=A0=87=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=B7=B1=E5=BA=A6=E9=80=86=E6=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMSceneGraph | 2 +- example/Vulkan/DeferredModel.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMSceneGraph b/CMSceneGraph index 62a1367e..2a750452 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit 62a1367e8b346bdcf107e8d586fb5b1f28cd0f04 +Subproject commit 2a750452cb0e0fef7e4c7a5c55d02e2cbb45d94e diff --git a/example/Vulkan/DeferredModel.cpp b/example/Vulkan/DeferredModel.cpp index a9ff57de..11c183c9 100644 --- a/example/Vulkan/DeferredModel.cpp +++ b/example/Vulkan/DeferredModel.cpp @@ -27,14 +27,13 @@ using Texture2DPointer=Texture2D *; enum class GBufferAttachment { - Position=0, - Color, + Color=0, Normal, - ENUM_CLASS_RANGE(Position,Normal) + ENUM_CLASS_RANGE(Color,Normal) };// -constexpr VkFormat gbuffer_color_format[size_t(GBufferAttachment::RANGE_SIZE)]={UFMT_RGBA32F,UFMT_RGBA32F,UFMT_RGBA32F}; +constexpr VkFormat gbuffer_color_format[size_t(GBufferAttachment::RANGE_SIZE)]={UFMT_RGBA32F,UFMT_RGBA32F}; constexpr VkFormat gbuffer_depth_format=FMT_D32F; struct alignas(16) PhongPointLight @@ -99,7 +98,12 @@ private: { List gbuffer_color_format_list(gbuffer_color_format,size_t(GBufferAttachment::RANGE_SIZE)); - gbuffer_rt=device->CreateRenderTarget(SCREEN_WIDTH,SCREEN_HEIGHT,gbuffer_color_format_list,gbuffer_depth_format); + gbuffer_rt=device->CreateRenderTarget( SCREEN_WIDTH, + SCREEN_HEIGHT, + gbuffer_color_format_list, + gbuffer_depth_format, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); return(true); } @@ -183,9 +187,9 @@ private: sp_composition.material_instance->BindUBO("world",GetCameraMatrixBuffer()); sp_composition.material_instance->BindUBO("lights",ubo_lights); - sp_composition.material_instance->BindSampler("GB_Position" ,gbuffer_rt->GetColorTexture((uint)GBufferAttachment::Position),sampler); - sp_composition.material_instance->BindSampler("GB_Normal" ,gbuffer_rt->GetColorTexture((uint)GBufferAttachment::Normal),sampler); sp_composition.material_instance->BindSampler("GB_Color" ,gbuffer_rt->GetColorTexture((uint)GBufferAttachment::Color),sampler); + sp_composition.material_instance->BindSampler("GB_Normal" ,gbuffer_rt->GetColorTexture((uint)GBufferAttachment::Normal),sampler); + sp_composition.material_instance->BindSampler("GB_Depth" ,gbuffer_rt->GetDepthTexture(),sampler); sp_composition.material_instance->Update(); return(true);