DatasmithMaterialsUtils.h
1 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
2 
3 #pragma once
4 
5 #include "CoreMinimal.h"
6 #include "DatasmithDefinitions.h"
7 
11 
12 namespace DatasmithMaterialsUtils
13 {
14  struct DATASMITHCORE_API FUVEditParameters
15  {
17  : UVOffset( FVector2D::ZeroVector )
18  , UVTiling( FVector2D::UnitVector )
19  , RotationPivot( 0.f, 1.f, 0.f )
20  , RotationAngle( 0.f )
21  , ChannelIndex( 0 )
22  , bIsUsingRealWorldScale( false )
23  , bMirrorU( false )
24  , bMirrorV( false )
25  {
26  }
27 
28  // UV space has its origin at top-left, with U going left-to-right, V top-to-bottom
29  FVector2D UVOffset;
30  FVector2D UVTiling;
31 
32  // W rotation center
33  FVector RotationPivot;
34 
35  // W rotation in degrees (rotation is counterclockwise)
36  float RotationAngle;
37 
38  // UV channel to use
39  uint8 ChannelIndex;
40 
41  // Enable "Real-World Scale" behavior as in 3ds max
42  bool bIsUsingRealWorldScale;
43 
44  // Enable mirroring of texture in U and V
45  bool bMirrorU;
46  bool bMirrorV;
47  };
48 
49  /**
50  * Generate material expressions on a given DatasmithUEPbrMaterialElement to output a texture with UV settings applied to it
51  * @param MaterialElement The UEPbrMaterialElement on which to create the material expressions
52  * @param ParameterName The display name for the Texture expression
53  * @param TextureMapPath The texture to use for the Texture expression
54  * @param UVParameters The UVEditParameters to apply
55  * @return Texture expression with UVEdit applied to it; nullptr if no TextureMapPath is specified
56  */
57  DATASMITHCORE_API IDatasmithMaterialExpressionTexture* CreateTextureExpression( const TSharedRef< IDatasmithUEPbrMaterialElement >& MaterialElement, const TCHAR* ParameterName, const TCHAR* TextureMapPath, const FUVEditParameters& UVParameters );
58 
59  /**
60  * Generate material expressions on a given DatasmithUEPbrMaterialElement that output a color or scalar interpolated with a MaterialExpression
61  * @param MaterialElement The UEPbrMaterialElement on which to create the material expressions
62  * @param ParameterName The display name for the Color or Scalar input
63  * @param Color The color to interpolate the Expression with. If no color is given, use the scalar
64  * @param Scalar The scalar to interpolate the Expression with. If no color or scalar are given, use the Expression only
65  * @param Expression The MaterialExpression to interpolate the Color or Scalar with
66  * @param Weight The weight of the Expression in the interpolation
67  * @param TextureMode The TextureMode of the Expression to determine if it requires normal flattening (bump and normal mode) or interpolation
68  * @return Material expression that outputs a Color or Scalar interpolated with Expression; nullptr if no Color, Scalar or Expression are given
69  */
70  DATASMITHCORE_API IDatasmithMaterialExpression* CreateWeightedMaterialExpression( const TSharedRef< IDatasmithUEPbrMaterialElement >& MaterialElement, const TCHAR* ParameterName, TOptional< FLinearColor > Color, TOptional< float > Scalar, IDatasmithMaterialExpression* Expression, float Weight, EDatasmithTextureMode TextureMode = EDatasmithTextureMode::Diffuse );
71 }
IDatasmithMaterialExpression
Definition: DatasmithMaterialElements.h:51
DatasmithMaterialsUtils::FUVEditParameters
Definition: DatasmithMaterialsUtils.h:14
IDatasmithUEPbrMaterialElement
Definition: DatasmithMaterialElements.h:184
IDatasmithMaterialExpressionTexture
Definition: DatasmithMaterialElements.h:102