2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# include "MaterialEditorModule.h"
2014-05-22 11:33:54 -04:00
# include "Materials/MaterialExpressionParameter.h"
# include "Materials/MaterialExpressionTextureSampleParameter.h"
# include "Materials/MaterialExpressionFontSampleParameter.h"
2014-05-21 10:00:58 -04:00
# include "EditorSupportDelegates.h"
2014-03-14 14:13:41 -04:00
# include "UnrealEd.h"
# include "PropertyEditing.h"
# include "PropertyCustomizationHelpers.h"
# include "MaterialEditor.h"
# include "MaterialEditorInstanceDetailCustomization.h"
# include "ScopedTransaction.h"
# include "DetailWidgetRow.h"
2014-11-12 04:43:54 -05:00
# include "AssetData.h"
# include "Materials/MaterialInstance.h"
# include "Materials/MaterialInstanceConstant.h"
2014-03-14 14:13:41 -04:00
2014-10-06 17:03:32 -04:00
# define LOCTEXT_NAMESPACE "MaterialInstanceEditor"
2014-03-14 14:13:41 -04:00
TSharedRef < IDetailCustomization > FMaterialInstanceParameterDetails : : MakeInstance ( UMaterialEditorInstanceConstant * MaterialInstance , FGetShowHiddenParameters InShowHiddenDelegate )
{
return MakeShareable ( new FMaterialInstanceParameterDetails ( MaterialInstance , InShowHiddenDelegate ) ) ;
}
FMaterialInstanceParameterDetails : : FMaterialInstanceParameterDetails ( UMaterialEditorInstanceConstant * MaterialInstance , FGetShowHiddenParameters InShowHiddenDelegate )
: MaterialEditorInstance ( MaterialInstance )
, ShowHiddenDelegate ( InShowHiddenDelegate )
{
}
TOptional < float > FMaterialInstanceParameterDetails : : OnGetValue ( TSharedRef < IPropertyHandle > PropertyHandle )
{
float Value = 0.0f ;
if ( PropertyHandle - > GetValue ( Value ) = = FPropertyAccess : : Success )
{
return TOptional < float > ( Value ) ;
}
// Value couldn't be accessed. Return an unset value
return TOptional < float > ( ) ;
}
void FMaterialInstanceParameterDetails : : OnValueCommitted ( float NewValue , ETextCommit : : Type CommitType , TSharedRef < IPropertyHandle > PropertyHandle )
{
// Try setting as float, if that fails then set as int
ensure ( PropertyHandle - > SetValue ( NewValue ) = = FPropertyAccess : : Success ) ;
}
2014-10-06 17:03:32 -04:00
void FMaterialInstanceParameterDetails : : CustomizeDetails ( IDetailLayoutBuilder & DetailLayout )
2014-03-14 14:13:41 -04:00
{
2015-04-20 16:30:33 -04:00
// Create a new category for a custom layout for the MIC parameters at the very top
FName GroupsCategoryName = TEXT ( " ParameterGroups " ) ;
IDetailCategoryBuilder & GroupsCategory = DetailLayout . EditCategory ( GroupsCategoryName , LOCTEXT ( " MICParamGroupsTitle " , " Parameter Groups " ) ) ;
TSharedRef < IPropertyHandle > ParameterGroupsProperty = DetailLayout . GetProperty ( " ParameterGroups " ) ;
CreateGroupsWidget ( ParameterGroupsProperty , GroupsCategory ) ;
2014-09-22 11:18:44 -04:00
// Create default category for class properties
2014-10-06 17:03:32 -04:00
const FName DefaultCategoryName = NAME_None ;
2014-03-14 14:13:41 -04:00
IDetailCategoryBuilder & DefaultCategory = DetailLayout . EditCategory ( DefaultCategoryName ) ;
2014-10-06 17:03:32 -04:00
// Add PhysMaterial property
2014-03-14 14:13:41 -04:00
DefaultCategory . AddProperty ( " PhysMaterial " ) ;
2014-10-06 17:03:32 -04:00
// Customize Parent property so we can check for recursively set parents
TSharedRef < IPropertyHandle > ParentPropertyHandle = DetailLayout . GetProperty ( " Parent " ) ;
IDetailPropertyRow & ParentPropertyRow = DefaultCategory . AddProperty ( " Parent " ) ;
TSharedPtr < SWidget > NameWidget ;
TSharedPtr < SWidget > ValueWidget ;
FDetailWidgetRow Row ;
ParentPropertyRow . GetDefaultWidgets ( NameWidget , ValueWidget , Row ) ;
const bool bShowChildren = true ;
ParentPropertyRow . CustomWidget ( bShowChildren )
. NameContent ( )
. MinDesiredWidth ( Row . NameWidget . MinWidth )
. MaxDesiredWidth ( Row . NameWidget . MaxWidth )
[
NameWidget . ToSharedRef ( )
]
. ValueContent ( )
. MinDesiredWidth ( Row . ValueWidget . MinWidth )
. MaxDesiredWidth ( Row . ValueWidget . MaxWidth )
[
SNew ( SObjectPropertyEntryBox )
. PropertyHandle ( ParentPropertyHandle )
. AllowedClass ( UMaterialInterface : : StaticClass ( ) )
. ThumbnailPool ( DetailLayout . GetThumbnailPool ( ) )
. AllowClear ( true )
. OnShouldSetAsset ( this , & FMaterialInstanceParameterDetails : : OnShouldSetAsset )
] ;
// Add/hide other properties
2014-03-14 14:13:41 -04:00
DefaultCategory . AddProperty ( " LightmassSettings " ) ;
DetailLayout . HideProperty ( " bUseOldStyleMICEditorGroups " ) ;
DetailLayout . HideProperty ( " ParameterGroups " ) ;
2014-08-22 14:15:05 -04:00
{
IDetailPropertyRow & PropertyRow = DefaultCategory . AddProperty ( " RefractionDepthBias " ) ;
PropertyRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ShouldShowMaterialRefractionSettings ) ) ) ;
}
{
IDetailPropertyRow & PropertyRow = DefaultCategory . AddProperty ( " bOverrideSubsurfaceProfile " ) ;
PropertyRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ShouldShowSubsurfaceProfile ) ) ) ;
}
{
IDetailPropertyRow & PropertyRow = DefaultCategory . AddProperty ( " SubsurfaceProfile " ) ;
PropertyRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ShouldShowSubsurfaceProfile ) ) ) ;
}
2014-03-14 14:13:41 -04:00
DetailLayout . HideProperty ( " BasePropertyOverrides " ) ;
2014-11-19 08:38:05 -05:00
CreateBasePropertyOverrideWidgets ( DetailLayout ) ;
2014-03-14 14:13:41 -04:00
}
void FMaterialInstanceParameterDetails : : CreateGroupsWidget ( TSharedRef < IPropertyHandle > ParameterGroupsProperty , IDetailCategoryBuilder & GroupsCategory )
{
check ( MaterialEditorInstance ) ;
for ( int32 GroupIdx = 0 ; GroupIdx < MaterialEditorInstance - > ParameterGroups . Num ( ) ; + + GroupIdx )
{
FEditorParameterGroup & ParameterGroup = MaterialEditorInstance - > ParameterGroups [ GroupIdx ] ;
2014-12-01 11:19:41 -05:00
IDetailGroup & DetailGroup = GroupsCategory . AddGroup ( ParameterGroup . GroupName , FText : : FromName ( ParameterGroup . GroupName ) , false , true ) ;
2014-03-14 14:13:41 -04:00
CreateSingleGroupWidget ( ParameterGroup , ParameterGroupsProperty - > GetChildHandle ( GroupIdx ) , DetailGroup ) ;
}
}
void FMaterialInstanceParameterDetails : : CreateSingleGroupWidget ( FEditorParameterGroup & ParameterGroup , TSharedPtr < IPropertyHandle > ParameterGroupProperty , IDetailGroup & DetailGroup )
{
TSharedPtr < IPropertyHandle > ParametersArrayProperty = ParameterGroupProperty - > GetChildHandle ( " Parameters " ) ;
// Create a custom widget for each parameter in the group
for ( int32 ParamIdx = 0 ; ParamIdx < ParameterGroup . Parameters . Num ( ) ; + + ParamIdx )
{
TSharedPtr < IPropertyHandle > ParameterProperty = ParametersArrayProperty - > GetChildHandle ( ParamIdx ) ;
FString ParameterName = ParameterGroup . Parameters [ ParamIdx ] - > ParameterName . ToString ( ) ;
UDEditorParameterValue * Parameter = ParameterGroup . Parameters [ ParamIdx ] ;
UDEditorFontParameterValue * FontParam = Cast < UDEditorFontParameterValue > ( Parameter ) ;
UDEditorScalarParameterValue * ScalarParam = Cast < UDEditorScalarParameterValue > ( Parameter ) ;
UDEditorStaticComponentMaskParameterValue * CompMaskParam = Cast < UDEditorStaticComponentMaskParameterValue > ( Parameter ) ;
UDEditorStaticSwitchParameterValue * SwitchParam = Cast < UDEditorStaticSwitchParameterValue > ( Parameter ) ;
UDEditorTextureParameterValue * TextureParam = Cast < UDEditorTextureParameterValue > ( Parameter ) ;
UDEditorVectorParameterValue * VectorParam = Cast < UDEditorVectorParameterValue > ( Parameter ) ;
2014-07-31 06:03:12 -04:00
if ( ScalarParam | | SwitchParam | | TextureParam | | VectorParam | | FontParam )
2014-03-14 14:13:41 -04:00
{
CreateParameterValueWidget ( Parameter , ParameterProperty , DetailGroup ) ;
}
else if ( CompMaskParam )
{
CreateMaskParameterValueWidget ( Parameter , ParameterProperty , DetailGroup ) ;
}
else
{
// Unsupported parameter type
check ( false ) ;
}
}
}
void FMaterialInstanceParameterDetails : : CreateParameterValueWidget ( UDEditorParameterValue * Parameter , TSharedPtr < IPropertyHandle > ParameterProperty , IDetailGroup & DetailGroup )
{
TSharedPtr < IPropertyHandle > ParameterValueProperty = ParameterProperty - > GetChildHandle ( " ParameterValue " ) ;
if ( ParameterValueProperty - > IsValidHandle ( ) )
{
TAttribute < bool > IsParamEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : IsOverriddenExpression , Parameter ) ) ;
IDetailPropertyRow & PropertyRow = DetailGroup . AddPropertyRow ( ParameterValueProperty . ToSharedRef ( ) ) ;
PropertyRow
2014-12-01 11:19:41 -05:00
. DisplayName ( FText : : FromName ( Parameter - > ParameterName ) )
2014-03-14 14:13:41 -04:00
. ToolTip ( GetParameterExpressionDescription ( Parameter ) )
. EditCondition ( IsParamEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideParameter , Parameter ) )
. Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ShouldShowExpression , Parameter ) ) )
// Handle reset to default manually
. OverrideResetToDefault ( true , FSimpleDelegate : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ResetToDefault , Parameter ) ) ;
}
}
void FMaterialInstanceParameterDetails : : CreateMaskParameterValueWidget ( UDEditorParameterValue * Parameter , TSharedPtr < IPropertyHandle > ParameterProperty , IDetailGroup & DetailGroup )
{
TSharedPtr < IPropertyHandle > ParameterValueProperty = ParameterProperty - > GetChildHandle ( " ParameterValue " ) ;
TSharedPtr < IPropertyHandle > RMaskProperty = ParameterValueProperty - > GetChildHandle ( " R " ) ;
TSharedPtr < IPropertyHandle > GMaskProperty = ParameterValueProperty - > GetChildHandle ( " G " ) ;
TSharedPtr < IPropertyHandle > BMaskProperty = ParameterValueProperty - > GetChildHandle ( " B " ) ;
TSharedPtr < IPropertyHandle > AMaskProperty = ParameterValueProperty - > GetChildHandle ( " A " ) ;
if ( ParameterValueProperty - > IsValidHandle ( ) )
{
TAttribute < bool > IsParamEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : IsOverriddenExpression , Parameter ) ) ;
IDetailPropertyRow & PropertyRow = DetailGroup . AddPropertyRow ( ParameterValueProperty . ToSharedRef ( ) ) ;
PropertyRow . EditCondition ( IsParamEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideParameter , Parameter ) ) ;
// Handle reset to default manually
PropertyRow . OverrideResetToDefault ( true , FSimpleDelegate : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ResetToDefault , Parameter ) ) ;
PropertyRow . Visibility ( TAttribute < EVisibility > : : Create ( TAttribute < EVisibility > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : ShouldShowExpression , Parameter ) ) ) ;
2014-12-01 11:19:41 -05:00
const FText ParameterName = FText : : FromName ( Parameter - > ParameterName ) ;
2014-03-14 14:13:41 -04:00
FDetailWidgetRow & CustomWidget = PropertyRow . CustomWidget ( ) ;
CustomWidget
. FilterString ( ParameterName )
. NameContent ( )
[
SNew ( STextBlock )
. Text ( ParameterName )
. ToolTipText ( GetParameterExpressionDescription ( Parameter ) )
. Font ( FEditorStyle : : GetFontStyle ( TEXT ( " PropertyWindow.NormalFont " ) ) )
]
. ValueContent ( )
. MaxDesiredWidth ( 200.0f )
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. FillWidth ( 1.0f )
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. AutoWidth ( )
[
2014-12-01 11:19:41 -05:00
RMaskProperty - > CreatePropertyNameWidget ( FText : : GetEmpty ( ) , FText : : GetEmpty ( ) , false )
2014-03-14 14:13:41 -04:00
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. AutoWidth ( )
[
RMaskProperty - > CreatePropertyValueWidget ( )
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. Padding ( FMargin ( 10.0f , 0.0f , 0.0f , 0.0f ) )
. AutoWidth ( )
[
2014-12-01 11:19:41 -05:00
GMaskProperty - > CreatePropertyNameWidget ( FText : : GetEmpty ( ) , FText : : GetEmpty ( ) , false )
2014-03-14 14:13:41 -04:00
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. AutoWidth ( )
[
GMaskProperty - > CreatePropertyValueWidget ( )
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. Padding ( FMargin ( 10.0f , 0.0f , 0.0f , 0.0f ) )
. AutoWidth ( )
[
2014-12-01 11:19:41 -05:00
BMaskProperty - > CreatePropertyNameWidget ( FText : : GetEmpty ( ) , FText : : GetEmpty ( ) , false )
2014-03-14 14:13:41 -04:00
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. AutoWidth ( )
[
BMaskProperty - > CreatePropertyValueWidget ( )
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. Padding ( FMargin ( 10.0f , 0.0f , 0.0f , 0.0f ) )
. AutoWidth ( )
[
2014-12-01 11:19:41 -05:00
AMaskProperty - > CreatePropertyNameWidget ( FText : : GetEmpty ( ) , FText : : GetEmpty ( ) , false )
2014-03-14 14:13:41 -04:00
]
+ SHorizontalBox : : Slot ( )
. HAlign ( HAlign_Left )
. AutoWidth ( )
[
AMaskProperty - > CreatePropertyValueWidget ( )
]
]
] ;
}
}
bool FMaterialInstanceParameterDetails : : IsVisibleExpression ( UDEditorParameterValue * Parameter )
{
return MaterialEditorInstance - > VisibleExpressions . Contains ( Parameter - > ExpressionId ) ;
}
EVisibility FMaterialInstanceParameterDetails : : ShouldShowExpression ( UDEditorParameterValue * Parameter ) const
{
bool bShowHidden = true ;
ShowHiddenDelegate . ExecuteIfBound ( bShowHidden ) ;
return ( bShowHidden | | MaterialEditorInstance - > VisibleExpressions . Contains ( Parameter - > ExpressionId ) ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
}
bool FMaterialInstanceParameterDetails : : IsOverriddenExpression ( UDEditorParameterValue * Parameter )
{
return Parameter - > bOverride ! = 0 ;
}
void FMaterialInstanceParameterDetails : : OnOverrideParameter ( bool NewValue , class UDEditorParameterValue * Parameter )
{
2014-10-06 17:03:32 -04:00
const FScopedTransaction Transaction ( LOCTEXT ( " OverrideParameter " , " Override Parameter " ) ) ;
2014-03-14 14:13:41 -04:00
Parameter - > Modify ( ) ;
Parameter - > bOverride = NewValue ;
// Fire off a dummy event to the material editor instance, so it knows to update the material, then refresh the viewports.
FPropertyChangedEvent OverrideEvent ( NULL ) ;
MaterialEditorInstance - > PostEditChangeProperty ( OverrideEvent ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
2014-10-06 17:03:32 -04:00
bool FMaterialInstanceParameterDetails : : OnShouldSetAsset ( const FAssetData & AssetData ) const
{
UMaterialInstance * MaterialInstance = Cast < UMaterialInstance > ( AssetData . GetAsset ( ) ) ;
if ( MaterialInstance ! = nullptr )
{
bool bIsChild = MaterialInstance - > IsChildOf ( MaterialEditorInstance - > SourceInstance ) ;
if ( bIsChild )
{
FMessageDialog : : Open (
EAppMsgType : : Ok ,
FText : : Format ( LOCTEXT ( " CannotSetExistingChildAsParent " , " Cannot set {0} as a parent as it is already a child of this material instance. " ) , FText : : FromName ( AssetData . AssetName ) ) ) ;
}
return ! bIsChild ;
}
return true ;
}
2014-12-01 11:19:41 -05:00
FText FMaterialInstanceParameterDetails : : GetParameterExpressionDescription ( UDEditorParameterValue * Parameter ) const
2014-03-14 14:13:41 -04:00
{
UMaterial * BaseMaterial = MaterialEditorInstance - > SourceInstance - > GetMaterial ( ) ;
if ( BaseMaterial )
{
UMaterialExpressionParameter * Expression = BaseMaterial - > FindExpressionByGUID < UMaterialExpressionParameter > ( Parameter - > ExpressionId ) ;
if ( Expression )
{
2014-12-01 11:19:41 -05:00
return FText : : FromString ( Expression - > Desc ) ;
2014-03-14 14:13:41 -04:00
}
UMaterialExpressionTextureSampleParameter * TextureExpression = BaseMaterial - > FindExpressionByGUID < UMaterialExpressionTextureSampleParameter > ( Parameter - > ExpressionId ) ;
if ( TextureExpression )
{
2014-12-01 11:19:41 -05:00
return FText : : FromString ( TextureExpression - > Desc ) ;
2014-03-14 14:13:41 -04:00
}
UMaterialExpressionFontSampleParameter * FontExpression = BaseMaterial - > FindExpressionByGUID < UMaterialExpressionFontSampleParameter > ( Parameter - > ExpressionId ) ;
if ( FontExpression )
{
2014-12-01 11:19:41 -05:00
return FText : : FromString ( FontExpression - > Desc ) ;
2014-03-14 14:13:41 -04:00
}
}
2014-12-01 11:19:41 -05:00
return FText : : GetEmpty ( ) ;
2014-03-14 14:13:41 -04:00
}
void FMaterialInstanceParameterDetails : : ResetToDefault ( class UDEditorParameterValue * Parameter )
{
2014-10-06 17:03:32 -04:00
const FScopedTransaction Transaction ( LOCTEXT ( " ResetToDefault " , " Reset To Default " ) ) ;
2014-03-14 14:13:41 -04:00
Parameter - > Modify ( ) ;
FName ParameterName = Parameter - > ParameterName ;
UDEditorFontParameterValue * FontParam = Cast < UDEditorFontParameterValue > ( Parameter ) ;
UDEditorScalarParameterValue * ScalarParam = Cast < UDEditorScalarParameterValue > ( Parameter ) ;
UDEditorStaticComponentMaskParameterValue * CompMaskParam = Cast < UDEditorStaticComponentMaskParameterValue > ( Parameter ) ;
UDEditorStaticSwitchParameterValue * SwitchParam = Cast < UDEditorStaticSwitchParameterValue > ( Parameter ) ;
UDEditorTextureParameterValue * TextureParam = Cast < UDEditorTextureParameterValue > ( Parameter ) ;
UDEditorVectorParameterValue * VectorParam = Cast < UDEditorVectorParameterValue > ( Parameter ) ;
if ( ScalarParam )
{
float OutValue ;
if ( MaterialEditorInstance - > Parent - > GetScalarParameterValue ( ParameterName , OutValue ) )
{
ScalarParam - > ParameterValue = OutValue ;
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
else if ( FontParam )
{
UFont * OutFontValue ;
int32 OutFontPage ;
if ( MaterialEditorInstance - > Parent - > GetFontParameterValue ( ParameterName , OutFontValue , OutFontPage ) )
{
2014-07-31 06:03:12 -04:00
FontParam - > ParameterValue . FontValue = OutFontValue ;
FontParam - > ParameterValue . FontPage = OutFontPage ;
2014-03-14 14:13:41 -04:00
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
else if ( TextureParam )
{
UTexture * OutValue ;
if ( MaterialEditorInstance - > Parent - > GetTextureParameterValue ( ParameterName , OutValue ) )
{
TextureParam - > ParameterValue = OutValue ;
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
else if ( VectorParam )
{
FLinearColor OutValue ;
if ( MaterialEditorInstance - > Parent - > GetVectorParameterValue ( ParameterName , OutValue ) )
{
VectorParam - > ParameterValue = OutValue ;
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
else if ( SwitchParam )
{
bool OutValue ;
FGuid TempGuid ( 0 , 0 , 0 , 0 ) ;
if ( MaterialEditorInstance - > Parent - > GetStaticSwitchParameterValue ( ParameterName , OutValue , TempGuid ) )
{
SwitchParam - > ParameterValue = OutValue ;
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
else if ( CompMaskParam )
{
bool OutValue [ 4 ] ;
FGuid TempGuid ( 0 , 0 , 0 , 0 ) ;
if ( MaterialEditorInstance - > Parent - > GetStaticComponentMaskParameterValue ( ParameterName , OutValue [ 0 ] , OutValue [ 1 ] , OutValue [ 2 ] , OutValue [ 3 ] , TempGuid ) )
{
CompMaskParam - > ParameterValue . R = OutValue [ 0 ] ;
CompMaskParam - > ParameterValue . G = OutValue [ 1 ] ;
CompMaskParam - > ParameterValue . B = OutValue [ 2 ] ;
CompMaskParam - > ParameterValue . A = OutValue [ 3 ] ;
MaterialEditorInstance - > CopyToSourceInstance ( ) ;
}
}
}
EVisibility FMaterialInstanceParameterDetails : : ShouldShowMaterialRefractionSettings ( ) const
{
return ( MaterialEditorInstance - > SourceInstance - > GetMaterial ( ) - > bUsesDistortion ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
}
2014-08-22 14:15:05 -04:00
EVisibility FMaterialInstanceParameterDetails : : ShouldShowSubsurfaceProfile ( ) const
{
2014-11-19 08:38:05 -05:00
EMaterialShadingModel Model = MaterialEditorInstance - > SourceInstance - > GetShadingModel ( ) ;
2014-08-22 14:15:05 -04:00
return ( Model = = MSM_SubsurfaceProfile ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
}
2014-10-06 17:03:32 -04:00
2014-11-19 08:38:05 -05:00
void FMaterialInstanceParameterDetails : : CreateBasePropertyOverrideWidgets ( IDetailLayoutBuilder & DetailLayout )
{
IDetailCategoryBuilder & DetailCategory = DetailLayout . EditCategory ( NAME_None ) ;
static FName GroupName ( TEXT ( " BasePropertyOverrideGroup " ) ) ;
2014-12-01 11:19:41 -05:00
IDetailGroup & BasePropertyOverrideGroup = DetailCategory . AddGroup ( GroupName , LOCTEXT ( " BasePropertyOverrideGroup " , " Material Property Overrides " ) , false , false ) ;
2014-11-19 08:38:05 -05:00
TAttribute < bool > IsOverrideOpacityClipMaskValueEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OverrideOpacityClipMaskValueEnabled ) ) ;
TAttribute < bool > IsOverrideBlendModeEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OverrideBlendModeEnabled ) ) ;
TAttribute < bool > IsOverrideShadingModelEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OverrideShadingModelEnabled ) ) ;
TAttribute < bool > IsOverrideTwoSidedEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OverrideTwoSidedEnabled ) ) ;
2015-04-24 11:20:23 -04:00
TAttribute < bool > IsOverrideDitheredLODTransitionEnabled = TAttribute < bool > : : Create ( TAttribute < bool > : : FGetter : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OverrideDitheredLODTransitionEnabled ) ) ;
2014-11-19 08:38:05 -05:00
TSharedRef < IPropertyHandle > BasePropertyOverridePropery = DetailLayout . GetProperty ( " BasePropertyOverrides " ) ;
TSharedPtr < IPropertyHandle > OpacityClipMaskValueProperty = BasePropertyOverridePropery - > GetChildHandle ( " OpacityMaskClipValue " ) ;
TSharedPtr < IPropertyHandle > BlendModeProperty = BasePropertyOverridePropery - > GetChildHandle ( " BlendMode " ) ;
TSharedPtr < IPropertyHandle > ShadingModelProperty = BasePropertyOverridePropery - > GetChildHandle ( " ShadingModel " ) ;
TSharedPtr < IPropertyHandle > TwoSidedProperty = BasePropertyOverridePropery - > GetChildHandle ( " TwoSided " ) ;
2015-04-24 11:20:23 -04:00
TSharedPtr < IPropertyHandle > DitheredLODTransitionProperty = BasePropertyOverridePropery - > GetChildHandle ( " DitheredLODTransition " ) ;
2014-11-19 08:38:05 -05:00
IDetailPropertyRow & OpacityClipMaskValuePropertyRow = BasePropertyOverrideGroup . AddPropertyRow ( OpacityClipMaskValueProperty . ToSharedRef ( ) ) ;
OpacityClipMaskValuePropertyRow
. DisplayName ( OpacityClipMaskValueProperty - > GetPropertyDisplayName ( ) )
. ToolTip ( OpacityClipMaskValueProperty - > GetToolTipText ( ) )
. EditCondition ( IsOverrideOpacityClipMaskValueEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideOpacityClipMaskValueChanged ) ) ;
IDetailPropertyRow & BlendModePropertyRow = BasePropertyOverrideGroup . AddPropertyRow ( BlendModeProperty . ToSharedRef ( ) ) ;
BlendModePropertyRow
. DisplayName ( BlendModeProperty - > GetPropertyDisplayName ( ) )
. ToolTip ( BlendModeProperty - > GetToolTipText ( ) )
. EditCondition ( IsOverrideBlendModeEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideBlendModeChanged ) ) ;
IDetailPropertyRow & ShadingModelPropertyRow = BasePropertyOverrideGroup . AddPropertyRow ( ShadingModelProperty . ToSharedRef ( ) ) ;
ShadingModelPropertyRow
. DisplayName ( ShadingModelProperty - > GetPropertyDisplayName ( ) )
. ToolTip ( ShadingModelProperty - > GetToolTipText ( ) )
. EditCondition ( IsOverrideShadingModelEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideShadingModelChanged ) ) ;
IDetailPropertyRow & TwoSidedPropertyRow = BasePropertyOverrideGroup . AddPropertyRow ( TwoSidedProperty . ToSharedRef ( ) ) ;
TwoSidedPropertyRow
. DisplayName ( TwoSidedProperty - > GetPropertyDisplayName ( ) )
. ToolTip ( TwoSidedProperty - > GetToolTipText ( ) )
. EditCondition ( IsOverrideTwoSidedEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideTwoSidedChanged ) ) ;
2015-04-24 11:20:23 -04:00
IDetailPropertyRow & DitheredLODTransitionPropertyRow = BasePropertyOverrideGroup . AddPropertyRow ( DitheredLODTransitionProperty . ToSharedRef ( ) ) ;
DitheredLODTransitionPropertyRow
. DisplayName ( DitheredLODTransitionProperty - > GetPropertyDisplayName ( ) )
. ToolTip ( DitheredLODTransitionProperty - > GetToolTipText ( ) )
. EditCondition ( IsOverrideDitheredLODTransitionEnabled , FOnBooleanValueChanged : : CreateSP ( this , & FMaterialInstanceParameterDetails : : OnOverrideDitheredLODTransitionChanged ) ) ;
2014-11-19 08:38:05 -05:00
}
bool FMaterialInstanceParameterDetails : : OverrideOpacityClipMaskValueEnabled ( ) const
{
return MaterialEditorInstance - > BasePropertyOverrides . bOverride_OpacityMaskClipValue ;
}
bool FMaterialInstanceParameterDetails : : OverrideBlendModeEnabled ( ) const
{
return MaterialEditorInstance - > BasePropertyOverrides . bOverride_BlendMode ;
}
bool FMaterialInstanceParameterDetails : : OverrideShadingModelEnabled ( ) const
{
return MaterialEditorInstance - > BasePropertyOverrides . bOverride_ShadingModel ;
}
bool FMaterialInstanceParameterDetails : : OverrideTwoSidedEnabled ( ) const
{
return MaterialEditorInstance - > BasePropertyOverrides . bOverride_TwoSided ;
}
2015-04-24 11:20:23 -04:00
bool FMaterialInstanceParameterDetails : : OverrideDitheredLODTransitionEnabled ( ) const
{
return MaterialEditorInstance - > BasePropertyOverrides . bOverride_DitheredLODTransition ;
}
2014-11-19 08:38:05 -05:00
void FMaterialInstanceParameterDetails : : OnOverrideOpacityClipMaskValueChanged ( bool NewValue )
{
MaterialEditorInstance - > BasePropertyOverrides . bOverride_OpacityMaskClipValue = NewValue ;
MaterialEditorInstance - > PostEditChange ( ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
void FMaterialInstanceParameterDetails : : OnOverrideBlendModeChanged ( bool NewValue )
{
MaterialEditorInstance - > BasePropertyOverrides . bOverride_BlendMode = NewValue ;
MaterialEditorInstance - > PostEditChange ( ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
void FMaterialInstanceParameterDetails : : OnOverrideShadingModelChanged ( bool NewValue )
{
MaterialEditorInstance - > BasePropertyOverrides . bOverride_ShadingModel = NewValue ;
MaterialEditorInstance - > PostEditChange ( ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
void FMaterialInstanceParameterDetails : : OnOverrideTwoSidedChanged ( bool NewValue )
{
MaterialEditorInstance - > BasePropertyOverrides . bOverride_TwoSided = NewValue ;
MaterialEditorInstance - > PostEditChange ( ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
2015-04-24 11:20:23 -04:00
void FMaterialInstanceParameterDetails : : OnOverrideDitheredLODTransitionChanged ( bool NewValue )
{
MaterialEditorInstance - > BasePropertyOverrides . bOverride_DitheredLODTransition = NewValue ;
MaterialEditorInstance - > PostEditChange ( ) ;
FEditorSupportDelegates : : RedrawAllViewports . Broadcast ( ) ;
}
2014-10-06 17:03:32 -04:00
# undef LOCTEXT_NAMESPACE
2014-11-12 04:43:54 -05:00