Graphics: Rework RenderTargets
- RenderTarget have been moved to the Graphics module and are now lightweight objects between the target of rendering (swapchain or texture) - RenderTexture no longer require a blit between the framegraph texture and the target texture (the target texture is now directly rendered onto using a new feature of the framegraph) - ForwardFramePipeline viewers are now properly ordered by render order
This commit is contained in:
@@ -1037,7 +1037,7 @@ int main(int argc, char* argv[])
|
||||
builder.Draw(3);
|
||||
});
|
||||
|
||||
graph.MarkAsFinalOutput(toneMappingOutput);
|
||||
graph.AddBackbufferOutput(toneMappingOutput);
|
||||
|
||||
return graph.Bake();
|
||||
}();
|
||||
|
||||
@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
Nz::Vector2ui windowSize = window.GetSize();
|
||||
|
||||
Nz::Camera camera(&windowSwapchain);
|
||||
Nz::Camera camera(std::make_shared<Nz::RenderWindow>(windowSwapchain));
|
||||
//camera.UpdateClearColor(Nz::Color::Gray);
|
||||
|
||||
Nz::ViewerInstance& viewerInstance = camera.GetViewerInstance();
|
||||
|
||||
@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
|
||||
entt::handle viewer = world.CreateEntity();
|
||||
{
|
||||
viewer.emplace<Nz::NodeComponent>();
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic);
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain), Nz::ProjectionType::Orthographic);
|
||||
cameraComponent.UpdateRenderMask(1);
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.5f, 0.5f, 0.5f));
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ int main(int argc, char* argv[])
|
||||
entt::handle viewer = world.CreateEntity();
|
||||
{
|
||||
viewer.emplace<Nz::NodeComponent>();
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(&windowSwapchain);
|
||||
auto& cameraComponent = viewer.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain));
|
||||
cameraComponent.UpdateRenderMask(1);
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.5f, 0.5f, 0.5f));
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Perspective);
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain), Nz::ProjectionType::Perspective);
|
||||
cameraComponent.UpdateFOV(70.f);
|
||||
cameraComponent.UpdateClearColor(Nz::Color::sRGBToLinear(Nz::Color(0.46f, 0.48f, 0.84f, 1.f)));
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char* argv[])
|
||||
cameraNode.SetPosition(Nz::Vector3f::Up() * 2.f + Nz::Vector3f::Backward());
|
||||
//cameraNode.SetParent(playerRotNode);
|
||||
|
||||
auto& cameraComponent = playerCamera.emplace<Nz::CameraComponent>(&windowSwapchain);
|
||||
auto& cameraComponent = playerCamera.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain));
|
||||
cameraComponent.UpdateZNear(0.2f);
|
||||
cameraComponent.UpdateZFar(10000.f);
|
||||
cameraComponent.UpdateRenderMask(1);
|
||||
@@ -412,26 +412,31 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Nz::TextureInfo screenTextureInfo = {
|
||||
.pixelFormat = Nz::PixelFormat::RGBA8,
|
||||
.type = Nz::ImageType::E2D,
|
||||
.levelCount = 1,
|
||||
.height = 360,
|
||||
.width = 480
|
||||
};
|
||||
std::shared_ptr<Nz::Texture> screenTexture;
|
||||
{
|
||||
Nz::TextureInfo screenTextureInfo = {
|
||||
.pixelFormat = Nz::PixelFormat::RGBA8,
|
||||
.type = Nz::ImageType::E2D,
|
||||
.usageFlags = Nz::TextureUsage::ColorAttachment | Nz::TextureUsage::ShaderSampling | Nz::TextureUsage::TransferDestination,
|
||||
.levelCount = 1,
|
||||
.height = 360,
|
||||
.width = 480
|
||||
};
|
||||
|
||||
std::shared_ptr<Nz::Texture> screenTexture = device->InstantiateTexture(screenTextureInfo);
|
||||
std::size_t size = Nz::PixelFormatInfo::ComputeSize(screenTextureInfo.pixelFormat, screenTextureInfo.width, screenTextureInfo.height, screenTextureInfo.depth);
|
||||
|
||||
Nz::RenderTexture renderTexture(screenTexture);
|
||||
std::vector<std::uint8_t> defaultScreen(size, 0xFF);
|
||||
screenTexture = device->InstantiateTexture(screenTextureInfo, defaultScreen.data(), false);
|
||||
}
|
||||
|
||||
entt::handle tvCameraEntity = world.CreateEntity();
|
||||
{
|
||||
auto& cameraNode = tvCameraEntity.emplace<Nz::NodeComponent>();
|
||||
cameraNode.SetParentJoint(bobEntity, "Head");
|
||||
cameraNode.SetRotation(Nz::EulerAnglesf(-30.f, 180.f, 0.f));
|
||||
//cameraNode.SetParent(playerCamera);
|
||||
//cameraNode.SetParentJoint(bobEntity, "Head");
|
||||
//cameraNode.SetRotation(Nz::EulerAnglesf(-30.f, 180.f, 0.f));
|
||||
cameraNode.SetParent(playerCamera);
|
||||
|
||||
auto& cameraComponent = tvCameraEntity.emplace<Nz::CameraComponent>(&renderTexture);
|
||||
auto& cameraComponent = tvCameraEntity.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderTexture>(screenTexture));
|
||||
cameraComponent.UpdateZNear(0.2f);
|
||||
cameraComponent.UpdateZFar(1000.f);
|
||||
cameraComponent.UpdateRenderMask(1);
|
||||
|
||||
@@ -26,7 +26,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic);
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain), Nz::ProjectionType::Orthographic);
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.46f, 0.48f, 0.84f, 1.f));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
cameraEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic);
|
||||
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain), Nz::ProjectionType::Orthographic);
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.46f, 0.48f, 0.84f, 1.f));
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
viewer2D.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto& cameraComponent = viewer2D.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic);
|
||||
auto& cameraComponent = viewer2D.emplace<Nz::CameraComponent>(std::make_shared<Nz::RenderWindow>(windowSwapchain), Nz::ProjectionType::Orthographic);
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.46f, 0.48f, 0.84f, 1.f));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user