diff --git a/Plugins/RenderDocPlugin/Source/Private/RenderDocPlugin.cpp b/Plugins/RenderDocPlugin/Source/Private/RenderDocPlugin.cpp index 36cb52df..3895cba6 100644 --- a/Plugins/RenderDocPlugin/Source/Private/RenderDocPlugin.cpp +++ b/Plugins/RenderDocPlugin/Source/Private/RenderDocPlugin.cpp @@ -25,6 +25,9 @@ void RenderDocPlugin::startup() { } }); } + else { + qWarning() << "Render Doc Load Failed: " << renderdoc.errorString(); + } } void RenderDocPlugin::shutdown() { diff --git a/Source/Core/Source/Private/Render/Pass/QBlurRenderPass.cpp b/Source/Core/Source/Private/Render/Pass/QBlurRenderPass.cpp index ce5a34d0..f196c2e7 100644 --- a/Source/Core/Source/Private/Render/Pass/QBlurRenderPass.cpp +++ b/Source/Core/Source/Private/Render/Pass/QBlurRenderPass.cpp @@ -36,7 +36,7 @@ void QBlurRenderPass::setDownSample(int val) { void QBlurRenderPass::resizeAndLinkNode(const QSize& size) { mSrcTexture = getTextureIn_Src(); for (int i = 0; i < 2; i++) { - mBlurRT[i].colorAttachment.reset(mRhi->newTexture(QRhiTexture::RGBA32F, mSrcTexture->pixelSize() / mDownSampleCount, 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); + mBlurRT[i].colorAttachment.reset(mRhi->newTexture(mSrcTexture->format(), mSrcTexture->pixelSize() / mDownSampleCount, 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); mBlurRT[i].colorAttachment->create(); mBlurRT[i].renderTarget.reset(mRhi->newTextureRenderTarget({ mBlurRT[i].colorAttachment.get() })); } diff --git a/Source/Core/Source/Private/Render/Pass/QMotionBlurRenderPass.cpp b/Source/Core/Source/Private/Render/Pass/QMotionBlurRenderPass.cpp new file mode 100644 index 00000000..d5c62ba3 --- /dev/null +++ b/Source/Core/Source/Private/Render/Pass/QMotionBlurRenderPass.cpp @@ -0,0 +1,176 @@ +#include "Render/Pass/QMotionBlurRenderPass.h" + +QMotionBlurRenderPass::QMotionBlurRenderPass() { + setMotionBlurSize(2); + setMotionBlurSeparation(1.0f); +} + +void QMotionBlurRenderPass::setMotionBlurSize(int size) { + if (size <= 0 || size == mParams.size) + return; + mParams.size = size; + sigUpdateParams.request(); +} + +void QMotionBlurRenderPass::setMotionBlurSeparation(float val) +{ + mParams.separation = val; + sigUpdateParams.request(); +} + + +void QMotionBlurRenderPass::resizeAndLinkNode(const QSize& size) { + auto baseuBaseColor = getTextureIn_BaseColor(); + auto uPosition = getTextureIn_Position(); + mMotionBlurRT.colorAttachment.reset(mRhi->newTexture(QRhiTexture::RGBA32F, baseuBaseColor->pixelSize() , 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); + mMotionBlurRT.colorAttachment->create(); + mMotionBlurRT.renderTarget.reset(mRhi->newTextureRenderTarget({ mMotionBlurRT.colorAttachment.get() })); + + renderPassDesc.reset(mMotionBlurRT.renderTarget->newCompatibleRenderPassDescriptor()); + + mMotionBlurRT.renderTarget->setRenderPassDescriptor(renderPassDesc.get()); + mMotionBlurRT.renderTarget->create(); + + mSampler.reset(mRhi->newSampler(QRhiSampler::Linear, + QRhiSampler::Linear, + QRhiSampler::None, + QRhiSampler::ClampToEdge, + QRhiSampler::ClampToEdge) + ); + mSampler->create(); + + mUniformBuffer.reset(mRhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, sizeof(Params))); + mUniformBuffer->create(); + + mBindings.reset(mRhi->newShaderResourceBindings()); + mBindings->setBindings({ + QRhiShaderResourceBinding::sampledTexture(0,QRhiShaderResourceBinding::FragmentStage, baseuBaseColor, mSampler.get()), + QRhiShaderResourceBinding::sampledTexture(1,QRhiShaderResourceBinding::FragmentStage, uPosition, mSampler.get()), + QRhiShaderResourceBinding::uniformBuffer(2,QRhiShaderResourceBinding::FragmentStage,mUniformBuffer.get()), + }); + mBindings->create(); + + registerTextureOut_Result(mMotionBlurRT.colorAttachment.get()); + + sigUpdateParams.request(); +} + +void QMotionBlurRenderPass::compile() { + mPipeline.reset(mRhi->newGraphicsPipeline()); + QRhiGraphicsPipeline::TargetBlend blendState; + blendState.enable = false; + mPipeline->setTargetBlends({ blendState }); + mPipeline->setSampleCount(mMotionBlurRT.renderTarget->sampleCount()); + + QShader vs = mRhi->newShaderFromCode(QShader::VertexStage, R"(#version 450 + layout (location = 0) out vec2 vUV; + out gl_PerVertex{ + vec4 gl_Position; + }; + void main() { + vUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); + gl_Position = vec4(vUV * 2.0f - 1.0f, 0.0f, 1.0f); +#if Y_UP_IN_NDC + gl_Position.y = - gl_Position.y; +#endif + })" + , QShaderDefinitions() + .addDefinition("Y_UP_IN_NDC", mRhi->isYUpInNDC()) + ); + + QShader fs = mRhi->newShaderFromCode(QShader::FragmentStage, R"(#version 450 + layout (location = 0) in vec2 vUV; + layout (location = 0) out vec4 outFragColor; + + layout (binding = 0) uniform sampler2D uBaseColor; + layout (binding = 1) uniform sampler2D uPosition; + layout (binding = 2) uniform MontionBlurParams{ + mat4 previousViewToWorld; + mat4 worldToView; + mat4 projection; + int size; + float separation; + }params; + + void main(){ + vec2 texSize = textureSize(uBaseColor, 0).xy; + vec2 vUV = gl_FragCoord.xy / texSize; + + outFragColor = texture(uBaseColor, vUV); + + vec4 position1 = texture(uPosition, vUV); + + if (params.size <= 0 || params.separation <= 0.0) { return; } + + vec4 position0 = params.worldToView * params.previousViewToWorld * position1; + + position0 = params.projection * position0; + position0.xyz /= position0.w; + position0.xy = position0.xy * 0.5 + 0.5; + + position1 = params.projection * position1; + position1.xyz /= position1.w; + position1.xy = position1.xy * 0.5 + 0.5; + + vec2 direction = position1.xy - position0.xy; + + direction.xy *= params.separation; + + vec2 forward = vUV; + vec2 backward = vUV; + + float count = 1.0; + + for (int i = 0; i < params.size; ++i) { + forward += direction; + backward -= direction; + + outFragColor += + texture + ( uBaseColor + , forward + ); + outFragColor += + texture + ( uBaseColor + , backward + ); + + count += 2.0; + } + outFragColor /= count; + } + )"); + mPipeline->setShaderStages({ + { QRhiShaderStage::Vertex, vs }, + { QRhiShaderStage::Fragment, fs } + }); + QRhiVertexInputLayout inputLayout; + mPipeline->setVertexInputLayout(inputLayout); + mPipeline->setShaderResourceBindings(mBindings.get()); + mPipeline->setRenderPassDescriptor(mMotionBlurRT.renderTarget->renderPassDescriptor()); + mPipeline->create(); + + QMatrix4x4 view = mRenderer->getCamera()->getViewMatrix(); + mParams.worldToView = view.toGenericMatrix<4, 4>(); + mParams.previousViewToWorld = view.inverted().toGenericMatrix<4, 4>(); +} + +void QMotionBlurRenderPass::render(QRhiCommandBuffer* cmdBuffer) { + mParams.projection = mRenderer->getCamera()->getProjectionMatrixWithCorr(mRhi).toGenericMatrix<4, 4>(); + QMatrix4x4 view = mRenderer->getCamera()->getViewMatrix(); + mParams.worldToView = view.toGenericMatrix<4, 4>(); + + QRhiResourceUpdateBatch* batch = mRhi->nextResourceUpdateBatch(); + batch->updateDynamicBuffer(mUniformBuffer.get(), 0, sizeof(Params), &mParams); + + cmdBuffer->resourceUpdate(batch); + cmdBuffer->beginPass(mMotionBlurRT.renderTarget.get(), QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f), { 1.0f, 0 }); + cmdBuffer->setGraphicsPipeline(mPipeline.get()); + cmdBuffer->setShaderResources(mBindings.get()); + cmdBuffer->setViewport(QRhiViewport(0, 0, mMotionBlurRT.renderTarget->pixelSize().width(), mMotionBlurRT.renderTarget->pixelSize().height())); + cmdBuffer->draw(4); + cmdBuffer->endPass(); + + mParams.previousViewToWorld = view.inverted().toGenericMatrix<4, 4>(); +} diff --git a/Source/Core/Source/Private/Render/Pass/QOutliningRenderPass.cpp b/Source/Core/Source/Private/Render/Pass/QOutliningRenderPass.cpp new file mode 100644 index 00000000..9ceb76be --- /dev/null +++ b/Source/Core/Source/Private/Render/Pass/QOutliningRenderPass.cpp @@ -0,0 +1,127 @@ +#include "Render/Pass/QOutliningRenderPass.h" + +QOutliningRenderPass::QOutliningRenderPass() { +} + +void QOutliningRenderPass::resizeAndLinkNode(const QSize& size) { + auto baseColorTexture = getTextureIn_BaseColor(); + auto positionTexture = getTextureIn_Position(); + mOutliningRT.colorAttachment.reset(mRhi->newTexture(baseColorTexture->format(), baseColorTexture->pixelSize(), 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); + mOutliningRT.colorAttachment->create(); + mOutliningRT.renderTarget.reset(mRhi->newTextureRenderTarget({ mOutliningRT.colorAttachment.get() })); + renderPassDesc.reset(mOutliningRT.renderTarget->newCompatibleRenderPassDescriptor()); + + mOutliningRT.renderTarget->setRenderPassDescriptor(renderPassDesc.get()); + mOutliningRT.renderTarget->create(); + + mSampler.reset(mRhi->newSampler(QRhiSampler::Linear, + QRhiSampler::Linear, + QRhiSampler::None, + QRhiSampler::ClampToEdge, + QRhiSampler::ClampToEdge) + ); + mSampler->create(); + + mUniformBuffer.reset(mRhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, sizeof(Params))); + mUniformBuffer->create(); + + mBindings.reset(mRhi->newShaderResourceBindings()); + mBindings->setBindings({ + QRhiShaderResourceBinding::sampledTexture(0,QRhiShaderResourceBinding::FragmentStage,baseColorTexture,mSampler.get()), + QRhiShaderResourceBinding::sampledTexture(1,QRhiShaderResourceBinding::FragmentStage,positionTexture,mSampler.get()), + QRhiShaderResourceBinding::uniformBuffer(2,QRhiShaderResourceBinding::FragmentStage,mUniformBuffer.get()) + }); + mBindings->create(); + + registerTextureOut_Result(mOutliningRT.colorAttachment.get()); + + sigUpdateParams.request(); +} + +void QOutliningRenderPass::compile() { + mPipeline.reset(mRhi->newGraphicsPipeline()); + QRhiGraphicsPipeline::TargetBlend blendState; + blendState.enable = false; + mPipeline->setTargetBlends({ blendState }); + mPipeline->setSampleCount(1); + mPipeline->setDepthTest(false); + mPipeline->setDepthWrite(false); + + QShader vs = mRhi->newShaderFromCode(QShader::VertexStage, R"(#version 450 + layout (location = 0) out vec2 vUV; + out gl_PerVertex{ + vec4 gl_Position; + }; + void main() { + vUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); + gl_Position = vec4(vUV * 2.0f - 1.0f, 0.0f, 1.0f); +#if Y_UP_IN_NDC + gl_Position.y = - gl_Position.y; +#endif + })" + , QShaderDefinitions() + .addDefinition("Y_UP_IN_NDC", mRhi->isYUpInNDC()) + ); + + QShader fs = mRhi->newShaderFromCode(QShader::FragmentStage, R"(#version 450 + layout (location = 0) in vec2 vUV; + layout (location = 0) out vec4 outFragColor; + layout (binding = 0) uniform sampler2D uBaseColor; + layout (binding = 1) uniform sampler2D uPosition; + layout (binding = 2) uniform Params{ + mat4 VP; + float MinSeparation; + float MaxSeparation; + float MinDistance; + float MaxDistance; + float FarNear; + int Radius; + vec4 ColorModifier; + }params; + + void main(){ + vec2 texOffset = 1.0 / textureSize(uBaseColor, 0); + vec4 baseColor = texture(uBaseColor, vUV); + vec4 screenPosition = params.VP * texture(uPosition, vUV); + float depth = screenPosition.z/screenPosition.w; + vec2 separation = mix(params.MaxSeparation, params.MinSeparation, depth) * texOffset; + float mx = 0.0f; + for (int i = -params.Radius; i <= params.Radius; ++i) { + for (int j = -params.Radius; j <= params.Radius; ++j) { + vec2 currUV = vUV + vec2(i,j) * separation; + vec4 currScreenPosition = params.VP * texture(uPosition, currUV); + float currDepth = currScreenPosition.z/currScreenPosition.w; + mx = max(mx, abs(depth - currDepth)); + } + } + float diff = smoothstep(params.MinDistance, params.MaxDistance, mx * params.FarNear); + vec3 lineColor = baseColor.rgb * params.ColorModifier.rgb; + outFragColor = vec4(mix(baseColor.rgb, lineColor, diff ),baseColor.a); + } + )"); + mPipeline->setShaderStages({ + { QRhiShaderStage::Vertex, vs }, + { QRhiShaderStage::Fragment, fs } + }); + QRhiVertexInputLayout inputLayout; + mPipeline->setVertexInputLayout(inputLayout); + mPipeline->setShaderResourceBindings(mBindings.get()); + mPipeline->setRenderPassDescriptor(renderPassDesc.get()); + mPipeline->create(); +} + +void QOutliningRenderPass::render(QRhiCommandBuffer* cmdBuffer) { + QMatrix4x4 VP = mRenderer->getCamera()->getProjectionMatrixWithCorr(mRhi) * mRenderer->getCamera()->getViewMatrix(); + mParams.VP = VP.toGenericMatrix<4, 4>(); + mParams.FarNear = mRenderer->getCamera()->getFarPlane() / mRenderer->getCamera()->getNearPlane(); + QRhiResourceUpdateBatch* batch = mRhi->nextResourceUpdateBatch(); + batch->updateDynamicBuffer(mUniformBuffer.get(), 0, sizeof(Params), &mParams); + cmdBuffer->resourceUpdate(batch); + + cmdBuffer->beginPass(mOutliningRT.renderTarget.get(), QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f), { 1.0f, 0 }); + cmdBuffer->setGraphicsPipeline(mPipeline.get()); + cmdBuffer->setShaderResources(mBindings.get()); + cmdBuffer->setViewport(QRhiViewport(0, 0, mOutliningRT.renderTarget->pixelSize().width(), mOutliningRT.renderTarget->pixelSize().height())); + cmdBuffer->draw(4); + cmdBuffer->endPass(); +} diff --git a/Source/Core/Source/Private/Render/Pass/QSsaoRenderPass.cpp b/Source/Core/Source/Private/Render/Pass/QSsaoRenderPass.cpp index 22d2d4cb..2e9ef05b 100644 --- a/Source/Core/Source/Private/Render/Pass/QSsaoRenderPass.cpp +++ b/Source/Core/Source/Private/Render/Pass/QSsaoRenderPass.cpp @@ -54,7 +54,7 @@ QSsaoRenderPass* QSsaoRenderPass::setupBias(float var) { void QSsaoRenderPass::resizeAndLinkNode(const QSize& size) { auto positionTexture = getTextureIn_Position(); auto normalTexture = getTextureIn_Normal(); - mRT.colorAttachment.reset(mRhi->newTexture(QRhiTexture::R16F, positionTexture->pixelSize() , 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); + mRT.colorAttachment.reset(mRhi->newTexture(QRhiTexture::R16, positionTexture->pixelSize() , 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource)); mRT.colorAttachment->create(); mRT.renderTarget.reset(mRhi->newTextureRenderTarget({ mRT.colorAttachment.get() })); renderPassDesc.reset(mRT.renderTarget->newCompatibleRenderPassDescriptor()); diff --git a/Source/Core/Source/Public/Render/Pass/QMotionBlurRenderPass.h b/Source/Core/Source/Public/Render/Pass/QMotionBlurRenderPass.h new file mode 100644 index 00000000..76268713 --- /dev/null +++ b/Source/Core/Source/Public/Render/Pass/QMotionBlurRenderPass.h @@ -0,0 +1,52 @@ +#ifndef QMotionBlurRenderPass_h__ +#define QMotionBlurRenderPass_h__ + +#include "Render/IRenderPass.h" + +class QENGINECORE_API QMotionBlurRenderPass: public IRenderPass { + Q_OBJECT + Q_PROPERTY(int MotionBlurSize READ getMotionBlurSize WRITE setMotionBlurSize) + Q_PROPERTY(float MotionBlurSeparation READ getMotionBlurSeparation WRITE setMotionBlurSeparation) + + //Q_CLASSINFO("MotionBlurIterations", "Min=0,Max=10") + //Q_CLASSINFO("MotionBlurSize", "Min=1,Max=40") + //Q_CLASSINFO("DownSampleCount", "Min=1,Max=16") + + Q_BUILDER_BEGIN_RENDER_PASS(QMotionBlurRenderPass,BaseColor,Position) + Q_BUILDER_ATTRIBUTE(int, MotionBlurSize) + Q_BUILDER_ATTRIBUTE(float, MotionBlurSeparation) + Q_BUILDER_END_RENDER_PASS(Result) +public: + QMotionBlurRenderPass(); + + void setMotionBlurSize(int size); + void setMotionBlurSeparation(float val); + + int getMotionBlurSize() const { return mParams.size; } + float getMotionBlurSeparation() const { return mParams.separation; } + + void resizeAndLinkNode(const QSize& size) override; + void compile() override; + void render(QRhiCommandBuffer* cmdBuffer) override; +private: + QScopedPointer mSampler; + QScopedPointer mUniformBuffer; + struct MotionBlurRT { + QScopedPointer colorAttachment; + QScopedPointer renderTarget; + }; + MotionBlurRT mMotionBlurRT; + QScopedPointer renderPassDesc; + QScopedPointer mPipeline; + QScopedPointer mBindings; + struct Params { + QGenericMatrix<4, 4, float> previousViewToWorld; + QGenericMatrix<4, 4, float> worldToView; + QGenericMatrix<4, 4, float> projection; + uint32_t size = 0; + float separation; + }mParams; + QRhiEx::Signal sigUpdateParams; +}; + +#endif // QMotionBlurRenderPass_h__ diff --git a/Source/Core/Source/Public/Render/Pass/QOutliningRenderPass.h b/Source/Core/Source/Public/Render/Pass/QOutliningRenderPass.h new file mode 100644 index 00000000..a73c5e6e --- /dev/null +++ b/Source/Core/Source/Public/Render/Pass/QOutliningRenderPass.h @@ -0,0 +1,75 @@ +#ifndef QOutliningRenderPass_h__ +#define QOutliningRenderPass_h__ + +#include "Render/IRenderPass.h" +#include "Type/QColor4D.h" + +class QENGINECORE_API QOutliningRenderPass: public IRenderPass { + Q_OBJECT + Q_PROPERTY(float MinSeparation READ getMinSeparation WRITE setMinSeparation) + Q_PROPERTY(float MaxSeparation READ getMaxSeparation WRITE setMaxSeparation) + Q_PROPERTY(float MinDistance READ getMinDistance WRITE setMinDistance) + Q_PROPERTY(float MaxDistance READ getMaxDistance WRITE setMaxDistance) + Q_PROPERTY(int Radius READ getRadius WRITE setRadius) + Q_PROPERTY(QColor4D ColorModifier READ getColorModifier WRITE setColorModifier) + + Q_CLASSINFO("MinSeparation", "Min=0,Max=10") + Q_CLASSINFO("MaxSeparation", "Min=1,Max=10") + Q_CLASSINFO("MinDistance", "Min=0,Max=10") + Q_CLASSINFO("MaxDistance", "Min=0,Max=10") + Q_CLASSINFO("Radius", "Min=1,Max=8") + + Q_BUILDER_BEGIN_RENDER_PASS(QOutliningRenderPass,BaseColor,Position) + Q_BUILDER_ATTRIBUTE(float, MinSeparation) + Q_BUILDER_ATTRIBUTE(float, MaxSeparation) + Q_BUILDER_ATTRIBUTE(float, MinDistance) + Q_BUILDER_ATTRIBUTE(float, MaxDistance) + Q_BUILDER_ATTRIBUTE(int, Radius) + Q_BUILDER_ATTRIBUTE(QColor4D, ColorModifier) + Q_BUILDER_END_RENDER_PASS(Result) +public: + QOutliningRenderPass(); + + void setMinSeparation(float val) { mParams.MinSeparation = val; } + void setMaxSeparation(float val) { mParams.MaxSeparation = val; } + void setMinDistance(float val) { mParams.MinDistance = val; } + void setMaxDistance(float val) { mParams.MaxDistance = val; } + void setRadius(int val) { mParams.Radius = val; } + void setColorModifier(QColor4D val) { mParams.ColorModifier = val; } + + float getMinSeparation() const { return mParams.MinSeparation; } + float getMaxSeparation() const { return mParams.MaxSeparation; } + float getMinDistance() const { return mParams.MinDistance; } + float getMaxDistance() const { return mParams.MaxDistance; } + int getRadius() const { return mParams.Radius; } + QColor4D getColorModifier() const { return mParams.ColorModifier; } + + void resizeAndLinkNode(const QSize& size) override; + void compile() override; + void render(QRhiCommandBuffer* cmdBuffer) override; +private: + QScopedPointer mSampler; + QScopedPointer mUniformBuffer; + struct OutliningRT { + QScopedPointer colorAttachment; + QScopedPointer renderTarget; + }; + OutliningRT mOutliningRT; + QScopedPointer renderPassDesc; + QScopedPointer mPipeline; + QScopedPointer mBindings; + + struct Params { + QGenericMatrix<4, 4, float> VP; + float MinSeparation = 1.0f; + float MaxSeparation = 3.0f; + float MinDistance = 0.5f; + float MaxDistance = 2.0f ; + float FarNear; + int Radius = 2; + alignas(16) QColor4D ColorModifier = QColor4D(0.324f,0.063f,0.099f,1.0f); + }mParams; + QRhiEx::Signal sigUpdateParams; +}; + +#endif // QOutliningRenderPass_h__ diff --git a/Source/Core/Source/Public/Utils/QCamera.h b/Source/Core/Source/Public/Utils/QCamera.h index fe390c3d..d6848d77 100644 --- a/Source/Core/Source/Public/Utils/QCamera.h +++ b/Source/Core/Source/Public/Utils/QCamera.h @@ -72,7 +72,7 @@ class QENGINECORE_API QCamera :public QObject { float mFov = 45.0f; float mAspectRatio = 1.0; float mNearPlane = 0.1f; - float mFarPlane = 10000.0f; + float mFarPlane = 3000.0f; QVector3D mCameraDirection; QVector3D mCameraUp; diff --git a/Source/Editor/Resources.qrc b/Source/Editor/Resources.qrc index 32761299..ffc71499 100644 --- a/Source/Editor/Resources.qrc +++ b/Source/Editor/Resources.qrc @@ -31,5 +31,6 @@ Resources/replace.png Resources/text-format.png Resources/close.png + Resources/tips.png diff --git a/Source/Editor/Resources/tips.png b/Source/Editor/Resources/tips.png new file mode 100644 index 00000000..d1e747a5 Binary files /dev/null and b/Source/Editor/Resources/tips.png differ diff --git a/Source/Engine/Source/Private/Render/Painter/DebugUiPainter.cpp b/Source/Engine/Source/Private/Render/Painter/DebugUiPainter.cpp index 603a3cc5..e07f7cf9 100644 --- a/Source/Engine/Source/Private/Render/Painter/DebugUiPainter.cpp +++ b/Source/Engine/Source/Private/Render/Painter/DebugUiPainter.cpp @@ -5,7 +5,8 @@ #include "Render/RHI/QRhiWindow.h" #include "Utils/ImGuiWidgets.h" #include "QEngineEditorStyleManager.h" -#include "QFile" +#include +#include void QDebugUIPainter::setupDebugIdTexture(QRhiTexture* texture) { mDebugIdTexture = texture; @@ -125,6 +126,29 @@ QDebugUIPainter::QDebugUIPainter(QWindowRenderer* inRenderer) } ImGui::PopStyleVar(); ImGui::End(); + + static int FrameCounter = 1000; + if (FrameCounter >= 0) { + ImGui::SetNextWindowBgAlpha(0); + ImVec2 Size(700, 170); + ImVec2 Pos(viewport->WorkSize.x - Size.x, viewport->WorkSize.y - Size.y); + ImGui::SetNextWindowPos(Pos); + ImGui::SetNextWindowSize(Size); + ImGui::Begin("Tips", NULL, + ImGuiWindowFlags_NoTitleBar + | ImGuiWindowFlags_NoScrollbar + | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoResize + | ImGuiWindowFlags_NoCollapse + | ImGuiWindowFlags_NoNav + | ImGuiWindowFlags_NoBackground + | ImGuiWindowFlags_NoBringToFrontOnFocus + | ImGuiWindowFlags_UnsavedDocument); + ImGui::Image(getImageId("tips"), Size,ImVec2(0,0),ImVec2(1,1),ImVec4(1,1,1,FrameCounter/500.0f)); + ImGui::End(); + FrameCounter--; + } + if (bUseLineMode) QRhiGraphicsPipelineBuilder::setPolygonModeOverride(QRhiGraphicsPipeline::Line); else @@ -143,7 +167,6 @@ QDebugUIPainter::QDebugUIPainter(QWindowRenderer* inRenderer) ImGui::TextColored(ImColor(0, 255, 0), "GPU Time\t%.2f ms", mRenderer->getRhiWindow()->getGpuFrameTime()); ImGui::End(); } - } }); setupRhi(mRenderer->getRhi()); @@ -188,6 +211,7 @@ void QDebugUIPainter::compile() { registerImage("polygon", QImage(":/Resources/polygon.png")); registerImage("camera", QImage(":/Resources/camera.png")); registerImage("graph", QImage(":/Resources/graph.png")); + registerImage("tips", QImage(":/Resources/tips.png")); ImGuiPainter::compile(); if (mDebugIdTexture == nullptr) return; diff --git a/Source/Engine/Source/Private/Render/Painter/FrameGraphView.cpp b/Source/Engine/Source/Private/Render/Painter/FrameGraphView.cpp index 4fc9eb42..5a7b4048 100644 --- a/Source/Engine/Source/Private/Render/Painter/FrameGraphView.cpp +++ b/Source/Engine/Source/Private/Render/Painter/FrameGraphView.cpp @@ -168,6 +168,7 @@ void FrameGraphView::ShowFrameComparer(float thickness, float leftMinWidth, floa auto dpr = qApp->devicePixelRatio(); ImGui::SetNextWindowPos(ImVec2(viewport->WorkSize.x - 60 * dpr , viewport->WorkSize.y - 40 * dpr)); ImGui::SetNextWindowSize(ImVec2(100 * dpr, 40 * dpr)); + ImGui::Begin("ExitButton", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar diff --git a/Source/Engine/Source/Private/Render/Painter/FrameGraphView.h b/Source/Engine/Source/Private/Render/Painter/FrameGraphView.h index 1749bcfc..63e65127 100644 --- a/Source/Engine/Source/Private/Render/Painter/FrameGraphView.h +++ b/Source/Engine/Source/Private/Render/Painter/FrameGraphView.h @@ -6,7 +6,8 @@ #include "GraphEditor.h" #include "Render/Renderer/QWindowRenderer.h" -struct FrameGraphView : public GraphEditor::Delegate { +class FrameGraphView : public GraphEditor::Delegate { +public: FrameGraphView(); void Rebuild(QFrameGraph* frameGraph); void Show();