mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added back environment clear color
This commit is contained in:
@@ -224,6 +224,10 @@ PSOutput main(PSInput input)
|
||||
int depthTexture = pushConstants.DepthInputTextureId;
|
||||
float depth = textures[depthTexture].Sample(mySampler, input.UV).r;
|
||||
|
||||
if(depth == 0.0f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ void RenderPass::ClearAttachments(PassRenderContext& ctx, PassAttachments& input
|
||||
{
|
||||
if (attachment->GetUsage() != ImageUsage::Depth)
|
||||
{
|
||||
ctx.commandBuffer.ClearColorImage(attachment);
|
||||
ctx.commandBuffer.ClearColorImage(attachment, this->ClearColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,11 @@ void RenderPass::SetShaders(Ref<VulkanShader> vertShader, Ref<VulkanShader> frag
|
||||
FragShader = fragShader;
|
||||
}
|
||||
|
||||
void RenderPass::SetClearColor(const Color& clearColor)
|
||||
{
|
||||
this->ClearColor = clearColor;
|
||||
}
|
||||
|
||||
void RenderPass::Build()
|
||||
{
|
||||
// Push constant range
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Nuake
|
||||
RenderPass* renderPass = nullptr;
|
||||
UUID cameraID;
|
||||
float selectedEntity;
|
||||
Color clearColor;
|
||||
};
|
||||
|
||||
class TextureAttachment
|
||||
@@ -63,6 +64,8 @@ namespace Nuake
|
||||
std::any PushConstant;
|
||||
size_t PushConstantSize;
|
||||
|
||||
Color ClearColor;
|
||||
|
||||
std::function<void(PassRenderContext& ctx)> PreRender;
|
||||
std::function<void(PassRenderContext& ctx)> RenderCb;
|
||||
std::function<void(PassRenderContext& ctx)> PostRender;
|
||||
@@ -97,6 +100,8 @@ namespace Nuake
|
||||
void SetInput(const std::string& name, TextureAttachment attachment);
|
||||
void SetShaders(Ref<VulkanShader> vertShader, Ref<VulkanShader> fragShader);
|
||||
|
||||
void SetClearColor(const Color& color);
|
||||
|
||||
template<typename T>
|
||||
void SetPushConstant(T& pushConstant)
|
||||
{
|
||||
|
||||
@@ -156,7 +156,6 @@ SceneRenderPipeline::SceneRenderPipeline()
|
||||
|
||||
ZoneScopedN("Render Models");
|
||||
gbufferConstant.CameraID = ctx.cameraID;
|
||||
|
||||
auto view = scene->m_Registry.view<TransformComponent, ModelComponent, VisibilityComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
@@ -229,6 +228,7 @@ SceneRenderPipeline::SceneRenderPipeline()
|
||||
auto& cmd = ctx.commandBuffer;
|
||||
cmd.PushConstants(ctx.renderPass->PipelineLayout, sizeof(ShadingConstant), &shadingConstant);
|
||||
|
||||
ctx.renderPass->SetClearColor(ctx.scene->GetEnvironment()->AmbientColor);
|
||||
// Draw full screen quad
|
||||
auto& quadMesh = VkSceneRenderer::QuadMesh;
|
||||
cmd.BindDescriptorSet(ctx.renderPass->PipelineLayout, quadMesh->GetDescriptorSet(), 1);
|
||||
@@ -265,6 +265,8 @@ SceneRenderPipeline::SceneRenderPipeline()
|
||||
auto& cmd = ctx.commandBuffer;
|
||||
cmd.PushConstants(ctx.renderPass->PipelineLayout, sizeof(TonemapConstant), &tonemapConstant);
|
||||
|
||||
ctx.renderPass->SetClearColor(ctx.scene->GetEnvironment()->AmbientColor);
|
||||
|
||||
// Draw full screen quad
|
||||
auto& quadMesh = VkSceneRenderer::QuadMesh;
|
||||
cmd.BindDescriptorSet(ctx.renderPass->PipelineLayout, quadMesh->GetDescriptorSet(), 1);
|
||||
@@ -333,6 +335,9 @@ void SceneRenderPipeline::Render(PassRenderContext& ctx)
|
||||
|
||||
OutlineOutput = ResizeImage(ctx, OutlineOutput, ctx.resolution);
|
||||
|
||||
Color clearColor = ctx.scene->GetEnvironment()->AmbientColor;
|
||||
ctx.clearColor = clearColor;
|
||||
|
||||
PipelineAttachments pipelineInputs
|
||||
{
|
||||
{ GBufferAlbedo, GBufferDepth, GBufferNormal, GBufferMaterial, GBufferEntityID }, // GBuffer
|
||||
|
||||
Reference in New Issue
Block a user