Skip to content

Commit a57eb79

Browse files
committed
plunger: Use lerp shader when material needs it.
1 parent 780d9b9 commit a57eb79

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Runtime/MaterialConverter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Text;
2323
using UnityEngine;
2424
using VisualPinball.Engine.VPT;
25+
using Mesh = VisualPinball.Engine.VPT.Mesh;
2526

2627
namespace VisualPinball.Unity.Urp
2728
{
@@ -34,6 +35,8 @@ public class MaterialConverter : IMaterialConverter
3435
private static readonly int Smoothness = Shader.PropertyToID("_Smoothness");
3536
private static readonly int BaseMap = Shader.PropertyToID("_BaseMap");
3637
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");
3740

3841
#endregion
3942

@@ -42,6 +45,13 @@ public Shader GetShader()
4245
return Shader.Find("Universal Render Pipeline/Lit");
4346
}
4447

48+
private Shader GetShader(PbrMaterial vpxMaterial)
49+
{
50+
return vpxMaterial.VertexLerpWithUvEnabled
51+
? Shader.Find("Visual Pinball/Srp/LerpVertex")
52+
: GetShader();
53+
}
54+
4555
public static UnityEngine.Material GetDefaultMaterial(BlendMode blendMode)
4656
{
4757
switch (blendMode)
@@ -62,10 +72,15 @@ public UnityEngine.Material CreateMaterial(PbrMaterial vpxMaterial, TableAuthori
6272
{
6373
UnityEngine.Material defaultMaterial = GetDefaultMaterial(vpxMaterial.MapBlendMode);
6474

65-
var unityMaterial = new UnityEngine.Material(GetShader());
75+
var unityMaterial = new UnityEngine.Material(GetShader(vpxMaterial));
6676
unityMaterial.CopyPropertiesFromMaterial(defaultMaterial);
6777
unityMaterial.name = vpxMaterial.Id;
6878

79+
if (vpxMaterial.VertexLerpWithUvEnabled) {
80+
unityMaterial.SetFloat(UVChannelVertices, Mesh.AnimationUVChannelVertices);
81+
unityMaterial.SetFloat(UVChannelNormals, Mesh.AnimationUVChannelNormals);
82+
}
83+
6984
// apply some basic manipulations to the color. this just makes very
7085
// very white colors be clipped to 0.8204 aka 204/255 is 0.8
7186
// this is to give room to lighting values. so there is more modulation

0 commit comments

Comments
 (0)