Adding support for blending the terain detail material with the macro material. (#7557)

* Adding support for blending the terain detail material with the macro material. Also includes several bug fixes
- The detail materail manager wasn't querying for default terrain region materials when it initializes, so it was missing some creation events that it would later get destruction events for and explode.
- Change the way the default material weights against other surface weights to avoid some discontinuities
- Fixed an issue where a default material id wouldn't initialize as invalid.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Several improvements and bug fixes
- Adding explicit creation / destruction events for material regions.
- Material regions will no longer try to "hide" when they don't have any materials
- Default detail materials will now only be used in areas where there are no other material assignments
- Fixed a bug where materials might not show up on surfaces when they were assigned to multiple regions or surface tags.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Simplified loop that assigns materials based on surface tags. Slightly simplified shader code regarding detail material id coordinates.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixes from PR review

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Making sure region changed doesn't get announced in the case where the old and new regions are both invalid.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
This commit is contained in:
Ken Pruiksma
2022-02-17 11:06:24 -06:00
committed by GitHub
parent 846e2736a5
commit e8b7bba0f2
8 changed files with 320 additions and 200 deletions
@@ -22,6 +22,8 @@
#include <AzFramework/StringFunc/StringFunc.h>
#include <Atom/RHI.Reflect/Format.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
// for texture splitting
@@ -352,7 +354,8 @@ namespace ImageProcessingAtom
// output conversion log
if (m_isSucceed && m_isFinished)
{
[[maybe_unused]] const uint32 sizeTotal = m_image->Get()->GetTextureMemory();
[[maybe_unused]] IImageObjectPtr imageObj = m_image->Get();
[[maybe_unused]] const uint32 sizeTotal = imageObj->GetTextureMemory();
if (m_input->m_isPreview)
{
AZ_TracePrintf("Image Processing", "Image (%d bytes) converted in %f seconds\n", sizeTotal, m_processTime);
@@ -363,11 +366,10 @@ namespace ImageProcessingAtom
}
else
{
[[maybe_unused]] const PixelFormatInfo* formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(m_image->Get()->GetPixelFormat());
[[maybe_unused]] const PixelFormatInfo* formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(imageObj->GetPixelFormat());
[[maybe_unused]] const AZ::RHI::Format rhiFormat = Utils::PixelFormatToRHIFormat(imageObj->GetPixelFormat(), imageObj->HasImageFlags(EIF_SRGBRead));
AZ_TracePrintf("Image Processing", "Image [%dx%d] [%s] converted with preset [%s] [%s] and saved to [%s] (%d bytes) taking %f seconds\n",
m_image->Get()->GetWidth(0), m_image->Get()->GetHeight(0),
formatInfo->szName,
imageObj->GetWidth(0), imageObj->GetHeight(0), AZ::RHI::ToString(rhiFormat),
m_input->m_presetSetting.m_name.GetCStr(),
m_input->m_filePath.c_str(),
m_input->m_outputFolder.c_str(), sizeTotal, m_processTime);