You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Preview windows and the r.PostProcessing.UserSceneTextureDebug mode were updated to handle material instances. If both a base material and an instance of it are being edited, the instance will be preferred in other preview windows over the base material, rather than including both and having their effects potentially overlap. Sorting of previewed materials was improved by ordering them in the reverse order they are encountered, so dependencies earlier in a chain are added first. Fixed cases where preview windows weren't refreshed on certain types of changes or debug mode toggling. To handle generic materials that can work at multiple resolutions, a "ScaleRelativeToInput" field was added, which generates the output resolution relative to a given User Scene Texture input. Positive divisors downsample, while negative divisors upsample (so 2 would divide resolution by 2, while -2 would multiply by 2). To handle the use of a generic material where you want the input or output to be SceneColor (say a first pass that reads SceneColor, or a last pass that writes SceneColor), you now have the option to specify "SceneColor" as a User Scene Texture input or output name. This special name doesn't create a transient User Scene Texture, but just hooks up SceneColor itself. The final feature added is a flag which suppresses PreExposure adjustments (multiply by View.OneOverPreExposure on input, multiply by View.PreExposure on output), useful if creating a material that doesn't care about the absolute value of linear colors (such as a blur where the inputs and outputs have the same scale), or where the output is not a linear color (such as a mask, modulation, or some sort of non-color data like positions, normals, offsets, IDs, etc). Especially simplifies writing custom HLSL by avoiding the need for confusing View.OneOverPreExposure.xxx boilerplate, in addition to providing a minor perf gain. #jira UE-215194 #rb eric.renaudhoude, Jason.Nadro, Ruslan.Idrisov [CL 34375539 by jason hoerner in ue5-main branch]
153 lines
6.5 KiB
C++
153 lines
6.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "MaterialEditorModule.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "IMaterialEditor.h"
|
|
#include "MaterialEditor.h"
|
|
#include "MaterialEditorUtilities.h"
|
|
#include "MaterialInstanceEditor.h"
|
|
#include "Materials/MaterialFunction.h"
|
|
#include "Materials/MaterialInstance.h"
|
|
#include "Materials/MaterialFunctionInstance.h"
|
|
#include "Settings/EditorExperimentalSettings.h"
|
|
#include "ContentBrowserModule.h"
|
|
#include "Styling/AppStyle.h"
|
|
#include "ContentBrowserDelegates.h"
|
|
#include "Interfaces/IPluginManager.h"
|
|
#include "Widgets/Docking/SDockTab.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "Widgets/Images/SImage.h"
|
|
#include "Misc/EngineBuildSettings.h"
|
|
#include "MaterialEditorSettings.h"
|
|
#include "EdGraphUtilities.h"
|
|
#include "ISettingsModule.h"
|
|
#include "Interfaces/IMainFrameModule.h"
|
|
#include "MaterialEditorGraphPanelPinFactory.h"
|
|
#include "MaterialEditorStyle.h"
|
|
|
|
const FName MaterialEditorAppIdentifier = FName(TEXT("MaterialEditorApp"));
|
|
const FName MaterialInstanceEditorAppIdentifier = FName(TEXT("MaterialInstanceEditorApp"));
|
|
|
|
namespace MaterialEditorModuleConstants
|
|
{
|
|
const static FName SettingsContainerName("Editor");
|
|
const static FName SettingsCategoryName("ContentEditors");
|
|
const static FName SettingsSectionName("Material Editor");
|
|
}
|
|
|
|
/**
|
|
* Material editor module
|
|
*/
|
|
class FMaterialEditorModule : public IMaterialEditorModule
|
|
{
|
|
public:
|
|
/** Constructor, set up console commands and variables **/
|
|
FMaterialEditorModule()
|
|
{
|
|
// Trigger a redraw of post process preview materials when this debug setting changes
|
|
IConsoleVariable* CVarPostProcessUserSceneTextureDebug = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PostProcessing.UserSceneTextureDebug"));
|
|
if (CVarPostProcessUserSceneTextureDebug)
|
|
{
|
|
CVarPostProcessUserSceneTextureDebug->SetOnChangedCallback(FConsoleVariableDelegate::CreateLambda([this](IConsoleVariable* Variable)
|
|
{
|
|
FMaterialEditorUtilities::RefreshPostProcessPreviewMaterials(nullptr, /* bRedrawOnly= */ true);
|
|
}));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called right after the module DLL has been loaded and the module object has been created
|
|
*/
|
|
virtual void StartupModule() override
|
|
{
|
|
MenuExtensibilityManager = MakeShareable(new FExtensibilityManager);
|
|
ToolBarExtensibilityManager = MakeShareable(new FExtensibilityManager);
|
|
|
|
ISettingsModule* SettingsModule = FModuleManager::LoadModulePtr<ISettingsModule>("Settings");
|
|
if (SettingsModule)
|
|
{
|
|
SettingsModule->RegisterSettings(
|
|
MaterialEditorModuleConstants::SettingsContainerName,
|
|
MaterialEditorModuleConstants::SettingsCategoryName,
|
|
MaterialEditorModuleConstants::SettingsSectionName,
|
|
NSLOCTEXT("MaterialEditorModule", "SettingsName", "Material Editor"),
|
|
NSLOCTEXT("MaterialEditorModule", "SettingsDesc", "Settings related to the material editor."),
|
|
GetMutableDefault<UMaterialEditorSettings>());
|
|
}
|
|
|
|
GraphPanelPinFactory = MakeShared<FMaterialEditorGraphPanelPinFactory>();
|
|
FEdGraphUtilities::RegisterVisualPinFactory(GraphPanelPinFactory);
|
|
|
|
FSubstrateMaterialEditorStyle::Initialize();
|
|
}
|
|
|
|
/**
|
|
* Called before the module is unloaded, right before the module object is destroyed.
|
|
*/
|
|
virtual void ShutdownModule() override
|
|
{
|
|
FEdGraphUtilities::UnregisterVisualPinFactory(GraphPanelPinFactory);
|
|
|
|
MenuExtensibilityManager.Reset();
|
|
ToolBarExtensibilityManager.Reset();
|
|
|
|
FSubstrateMaterialEditorStyle::Shutdown();
|
|
}
|
|
|
|
/**
|
|
* Creates a new material editor, either for a material or a material function
|
|
*/
|
|
virtual TSharedRef<IMaterialEditor> CreateMaterialEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMaterial* Material) override
|
|
{
|
|
TSharedRef<FMaterialEditor> NewMaterialEditor(new FMaterialEditor());
|
|
NewMaterialEditor->InitEditorForMaterial(Material);
|
|
OnMaterialEditorOpened().Broadcast(NewMaterialEditor);
|
|
NewMaterialEditor->InitMaterialEditor(Mode, InitToolkitHost, Material);
|
|
return NewMaterialEditor;
|
|
}
|
|
|
|
virtual TSharedRef<IMaterialEditor> CreateMaterialEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMaterialFunction* MaterialFunction) override
|
|
{
|
|
TSharedRef<FMaterialEditor> NewMaterialEditor(new FMaterialEditor());
|
|
NewMaterialEditor->InitEditorForMaterialFunction(MaterialFunction);
|
|
OnMaterialFunctionEditorOpened().Broadcast(NewMaterialEditor);
|
|
NewMaterialEditor->InitMaterialEditor(Mode, InitToolkitHost, MaterialFunction);
|
|
return NewMaterialEditor;
|
|
}
|
|
|
|
virtual TSharedRef<IMaterialEditor> CreateMaterialInstanceEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMaterialInstance* MaterialInstance) override
|
|
{
|
|
TSharedRef<FMaterialInstanceEditor> NewMaterialInstanceEditor(new FMaterialInstanceEditor());
|
|
NewMaterialInstanceEditor->InitEditorForMaterial(MaterialInstance);
|
|
OnMaterialInstanceEditorOpened().Broadcast(NewMaterialInstanceEditor);
|
|
NewMaterialInstanceEditor->InitMaterialInstanceEditor(Mode, InitToolkitHost, MaterialInstance);
|
|
return NewMaterialInstanceEditor;
|
|
}
|
|
|
|
virtual TSharedRef<IMaterialEditor> CreateMaterialInstanceEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UMaterialFunctionInstance* MaterialFunction) override
|
|
{
|
|
TSharedRef<FMaterialInstanceEditor> NewMaterialInstanceEditor(new FMaterialInstanceEditor());
|
|
NewMaterialInstanceEditor->InitEditorForMaterialFunction(MaterialFunction);
|
|
OnMaterialInstanceEditorOpened().Broadcast(NewMaterialInstanceEditor);
|
|
NewMaterialInstanceEditor->InitMaterialInstanceEditor(Mode, InitToolkitHost, MaterialFunction);
|
|
return NewMaterialInstanceEditor;
|
|
}
|
|
|
|
virtual void GetVisibleMaterialParameters(const class UMaterial* Material, class UMaterialInstance* MaterialInstance, TArray<FMaterialParameterInfo>& VisibleExpressions) override
|
|
{
|
|
FMaterialEditorUtilities::GetVisibleMaterialParameters(Material, MaterialInstance, VisibleExpressions);
|
|
}
|
|
|
|
/** Gets the extensibility managers for outside entities to extend material editor's menus and toolbars */
|
|
virtual TSharedPtr<FExtensibilityManager> GetMenuExtensibilityManager() override { return MenuExtensibilityManager; }
|
|
virtual TSharedPtr<FExtensibilityManager> GetToolBarExtensibilityManager() override { return ToolBarExtensibilityManager; }
|
|
|
|
private:
|
|
TSharedPtr<FExtensibilityManager> MenuExtensibilityManager;
|
|
TSharedPtr<FExtensibilityManager> ToolBarExtensibilityManager;
|
|
FDelegateHandle ContentBrowserAssetExtenderDelegateHandle;
|
|
TSharedPtr<FMaterialEditorGraphPanelPinFactory> GraphPanelPinFactory;
|
|
};
|
|
|
|
IMPLEMENT_MODULE( FMaterialEditorModule, MaterialEditor );
|