Implemented support for semi-live previews of materials in the material property inspector.

Changed thumbnailer bus to use const pixmap
Changed capture request call back to use const pixmap instead of image
Replaced scene and pipeline members with constructor parameters
Added material preview renderer to editor material system component with new requests and notifications
Changed material property inspector details group to persistent heading so the preview image widget would not get destroyed during refreshes. But this was also a backlog task.
Changed common preview render camera to use lookat
Moved default asset caching to thumbnail renderer

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
Guthrie Adams
2021-10-09 18:17:50 -05:00
parent 56b7ee2bd4
commit 2c6cfdd7dc
26 changed files with 365 additions and 203 deletions
@@ -24,9 +24,12 @@
#include <PreviewRenderer/PreviewRendererIdleState.h>
#include <PreviewRenderer/PreviewRendererLoadState.h>
#include <QImage>
#include <QPixmap>
namespace AtomToolsFramework
{
PreviewRenderer::PreviewRenderer()
PreviewRenderer::PreviewRenderer(const AZStd::string& sceneName, const AZStd::string& pipelineName)
{
PreviewerFeatureProcessorProviderBus::Handler::BusConnect();
@@ -46,7 +49,7 @@ namespace AtomToolsFramework
auto sceneSystem = AzFramework::SceneSystemInterface::Get();
AZ_Assert(sceneSystem, "Failed to get scene system implementation.");
AZ::Outcome<AZStd::shared_ptr<AzFramework::Scene>, AZStd::string> createSceneOutcome = sceneSystem->CreateScene(m_sceneName);
AZ::Outcome<AZStd::shared_ptr<AzFramework::Scene>, AZStd::string> createSceneOutcome = sceneSystem->CreateScene(sceneName);
AZ_Assert(createSceneOutcome, createSceneOutcome.GetError().c_str());
m_frameworkScene = createSceneOutcome.TakeValue();
@@ -56,7 +59,7 @@ namespace AtomToolsFramework
// Create a render pipeline from the specified asset for the window context and add the pipeline to the scene
AZ::RPI::RenderPipelineDescriptor pipelineDesc;
pipelineDesc.m_mainViewTagName = "MainCamera";
pipelineDesc.m_name = m_pipelineName;
pipelineDesc.m_name = pipelineName;
pipelineDesc.m_rootPassTemplate = "MainPipelineRenderToTexture";
// We have to set the samples to 4 to match the pipeline passes' setting, otherwise it may lead to device lost issue
@@ -66,7 +69,7 @@ namespace AtomToolsFramework
m_scene->AddRenderPipeline(m_renderPipeline);
m_scene->Activate();
AZ::RPI::RPISystemInterface::Get()->RegisterScene(m_scene);
m_passHierarchy.push_back(m_pipelineName);
m_passHierarchy.push_back(pipelineName);
m_passHierarchy.push_back("CopyToSwapChain");
// Connect camera to pipeline's default view after camera entity activated
@@ -97,6 +100,11 @@ namespace AtomToolsFramework
m_frameworkScene->UnsetSubsystem(m_entityContext.get());
}
void PreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest)
{
m_captureRequestQueue.push(captureRequest);
}
AZ::RPI::ScenePtr PreviewRenderer::GetScene() const
{
return m_scene;
@@ -112,11 +120,6 @@ namespace AtomToolsFramework
return m_entityContext->GetContextId();
}
void PreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest)
{
m_captureRequestQueue.push(captureRequest);
}
void PreviewRenderer::SetState(State state)
{
auto stepItr = m_states.find(m_currentState);
@@ -199,9 +202,9 @@ namespace AtomToolsFramework
{
if (result.m_dataBuffer)
{
currentCaptureRequest.m_captureCompleteCallback(QImage(
currentCaptureRequest.m_captureCompleteCallback(QPixmap::fromImage(QImage(
result.m_dataBuffer.get()->data(), result.m_imageDescriptor.m_size.m_width, result.m_imageDescriptor.m_size.m_height,
QImage::Format_RGBA8888));
QImage::Format_RGBA8888)));
}
else
{