Files
santorac 57989c35db Changed material builder to not fail on warnings.
The main reason for this is to give consistent results between the AP and Material Editor, where a placholder texture can be used if a texture is missing. Otherwise, you could get a placeholder texture in Material Editor and stale data in the runtime; this inconsistency would be confusing.
As a consequence, it is possible for example that the user could mess up the name of a property in a .material file and not notice the problem because it is now a warning instead of an error. If warnings-as-errors is desirable, you can enable the new "/O3DE/Atom/RPI/MaterialBuilder/WarningsAsErrors" registry setting.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
2021-11-11 12:50:17 -08:00

50 lines
1.6 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AssetBuilderSDK/AssetBuilderBusses.h>
#include <Atom/RPI.Reflect/Material/MaterialAsset.h>
#include <AzCore/JSON/document.h>
namespace AZ
{
namespace RPI
{
class MaterialBuilder final
: public AssetBuilderSDK::AssetBuilderCommandBus::Handler
{
public:
AZ_TYPE_INFO(MaterialBuilder, "{861C0937-7671-40DC-8E44-6D432ABB9932}");
static const char* JobKey;
MaterialBuilder() = default;
~MaterialBuilder();
// Asset Builder Callback Functions
void CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response) const;
void ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const;
// AssetBuilderSDK::AssetBuilderCommandBus interface
void ShutDown() override;
/// Register to builder and listen to builder command
void RegisterBuilder();
private:
AZ::Data::Asset<MaterialAsset> CreateMaterialAsset(AZStd::string_view materialSourceFilePath, const rapidjson::Value& json) const;
bool ReportMaterialAssetWarningsAsErrors() const;
bool m_isShuttingDown = false;
};
} // namespace RPI
} // namespace AZ