23
23
using UnityEngine ;
24
24
using VisualPinball . Engine . VPT ;
25
25
using VisualPinball . Unity ;
26
+ using Material = UnityEngine . Material ;
26
27
27
28
namespace VisualPinball . Engine . Unity . Hdrp
28
29
{
@@ -35,35 +36,49 @@ public class MaterialConverter : IMaterialConverter
35
36
private static readonly int Smoothness = Shader . PropertyToID ( "_Smoothness" ) ;
36
37
private static readonly int BaseColorMap = Shader . PropertyToID ( "_BaseColorMap" ) ;
37
38
private static readonly int NormalMap = Shader . PropertyToID ( "_NormalMap" ) ;
39
+ private static readonly int UVChannelSelect = Shader . PropertyToID ( "_UVChannelSelect" ) ;
38
40
39
41
#endregion
40
42
41
- private static Shader GetShader ( )
43
+ public Shader GetShader ( )
42
44
{
43
45
return Shader . Find ( "HDRP/Lit" ) ;
44
46
}
45
47
46
- public static UnityEngine . Material GetDefaultMaterial ( BlendMode blendMode )
48
+ private Shader GetShader ( PbrMaterial vpxMaterial )
49
+ {
50
+ return vpxMaterial . VertexLerpWithUvEnabled
51
+ ? Shader . Find ( "Visual Pinball/Hdrp/LerpVertex" )
52
+ : GetShader ( ) ;
53
+ }
54
+
55
+ public static Material GetDefaultMaterial ( BlendMode blendMode )
47
56
{
48
57
switch ( blendMode )
49
58
{
50
59
case BlendMode . Opaque :
51
- return UnityEngine . Resources . Load < UnityEngine . Material > ( "Materials/TableOpaque" ) ;
60
+ return UnityEngine . Resources . Load < Material > ( "Materials/TableOpaque" ) ;
52
61
case BlendMode . Cutout :
53
- return UnityEngine . Resources . Load < UnityEngine . Material > ( "Materials/TableCutout" ) ;
62
+ return UnityEngine . Resources . Load < Material > ( "Materials/TableCutout" ) ;
54
63
case BlendMode . Translucent :
55
- return UnityEngine . Resources . Load < UnityEngine . Material > ( "Materials/TableTranslucent" ) ;
64
+ return UnityEngine . Resources . Load < Material > ( "Materials/TableTranslucent" ) ;
56
65
default :
57
66
throw new ArgumentOutOfRangeException ( "Undefined blend mode " + blendMode ) ;
58
67
}
59
-
60
68
}
61
69
62
- public UnityEngine . Material CreateMaterial ( PbrMaterial vpxMaterial , TableAuthoring table , Type objectType , StringBuilder debug = null )
70
+ public Material CreateMaterial ( PbrMaterial vpxMaterial , TableAuthoring table , Type objectType , StringBuilder debug = null )
63
71
{
64
- UnityEngine . Material defaultMaterial = GetDefaultMaterial ( vpxMaterial . MapBlendMode ) ;
72
+ Material defaultMaterial = GetDefaultMaterial ( vpxMaterial . MapBlendMode ) ;
65
73
66
- var unityMaterial = new UnityEngine . Material ( GetShader ( ) ) ;
74
+ var unityMaterial = new Material ( GetShader ( vpxMaterial ) )
75
+ {
76
+ name = vpxMaterial . Id
77
+ } ;
78
+
79
+ if ( vpxMaterial . VertexLerpWithUvEnabled ) {
80
+ unityMaterial . SetFloat ( UVChannelSelect , 2 ) ;
81
+ }
67
82
unityMaterial . CopyPropertiesFromMaterial ( defaultMaterial ) ;
68
83
unityMaterial . name = vpxMaterial . Id ;
69
84
0 commit comments