22
22
using System . Text ;
23
23
using UnityEngine ;
24
24
using VisualPinball . Engine . VPT ;
25
+ using Mesh = VisualPinball . Engine . VPT . Mesh ;
25
26
26
27
namespace VisualPinball . Unity . Urp
27
28
{
@@ -34,6 +35,8 @@ public class MaterialConverter : IMaterialConverter
34
35
private static readonly int Smoothness = Shader . PropertyToID ( "_Smoothness" ) ;
35
36
private static readonly int BaseMap = Shader . PropertyToID ( "_BaseMap" ) ;
36
37
private static readonly int NormalMap = Shader . PropertyToID ( "_BumpMap" ) ;
38
+ private static readonly int UVChannelVertices = Shader . PropertyToID ( "_UVChannelVertices" ) ;
39
+ private static readonly int UVChannelNormals = Shader . PropertyToID ( "_UVChannelNormals" ) ;
37
40
38
41
#endregion
39
42
@@ -42,6 +45,13 @@ public Shader GetShader()
42
45
return Shader . Find ( "Universal Render Pipeline/Lit" ) ;
43
46
}
44
47
48
+ private Shader GetShader ( PbrMaterial vpxMaterial )
49
+ {
50
+ return vpxMaterial . VertexLerpWithUvEnabled
51
+ ? Shader . Find ( "Visual Pinball/Srp/LerpVertex" )
52
+ : GetShader ( ) ;
53
+ }
54
+
45
55
public static UnityEngine . Material GetDefaultMaterial ( BlendMode blendMode )
46
56
{
47
57
switch ( blendMode )
@@ -62,10 +72,15 @@ public UnityEngine.Material CreateMaterial(PbrMaterial vpxMaterial, TableAuthori
62
72
{
63
73
UnityEngine . Material defaultMaterial = GetDefaultMaterial ( vpxMaterial . MapBlendMode ) ;
64
74
65
- var unityMaterial = new UnityEngine . Material ( GetShader ( ) ) ;
75
+ var unityMaterial = new UnityEngine . Material ( GetShader ( vpxMaterial ) ) ;
66
76
unityMaterial . CopyPropertiesFromMaterial ( defaultMaterial ) ;
67
77
unityMaterial . name = vpxMaterial . Id ;
68
78
79
+ if ( vpxMaterial . VertexLerpWithUvEnabled ) {
80
+ unityMaterial . SetFloat ( UVChannelVertices , Mesh . AnimationUVChannelVertices ) ;
81
+ unityMaterial . SetFloat ( UVChannelNormals , Mesh . AnimationUVChannelNormals ) ;
82
+ }
83
+
69
84
// apply some basic manipulations to the color. this just makes very
70
85
// very white colors be clipped to 0.8204 aka 204/255 is 0.8
71
86
// this is to give room to lighting values. so there is more modulation
0 commit comments