Skip to content

Commit 2b2c574

Browse files
committed
rp: Add light converter.
1 parent 3316359 commit 2b2c574

File tree

5 files changed

+75
-3
lines changed

5 files changed

+75
-3
lines changed

Runtime/HDRenderPipeline.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
using VisualPinball.Unity;
1+
// Visual Pinball Engine
2+
// Copyright (C) 2020 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
216

317
namespace VisualPinball.Unity.Hdrp
418
{
519
public class HDRenderPipeline : IRenderPipeline
620
{
721
public string Name { get; } = "High Definition Render Pipeline";
22+
23+
public RenderPipelineType Type { get; } = RenderPipelineType.Hdrp;
824
public IMaterialConverter MaterialConverter { get; }
25+
public ILightConverter LightConverter { get; }
926

1027
public HDRenderPipeline()
1128
{
12-
MaterialConverter = new HdrpMaterialConverter();
29+
MaterialConverter = new MaterialConverter();
30+
LightConverter = new LightConverter();
1331
}
1432
}
1533
}

Runtime/LightConverter.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Visual Pinball Engine
2+
// Copyright (C) 2020 freezy and VPE Team
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
// ReSharper disable UnusedType.Global
18+
// ReSharper disable CheckNamespace
19+
20+
using UnityEngine;
21+
using UnityEngine.Rendering.HighDefinition;
22+
using VisualPinball.Engine.VPT.Light;
23+
using Light = UnityEngine.Light;
24+
25+
namespace VisualPinball.Unity.Hdrp
26+
{
27+
public class LightConverter : ILightConverter
28+
{
29+
public void UpdateLight(Light light, LightData data)
30+
{
31+
// Set color and position
32+
var hdLight = light.GetComponent<HDAdditionalLightData>();
33+
if (hdLight == null) {
34+
hdLight = light.gameObject.AddComponent<HDAdditionalLightData>();
35+
HDAdditionalLightData.InitDefaultHDAdditionalLightData(hdLight);
36+
}
37+
hdLight.color = data.Color2.ToUnityColor();
38+
hdLight.intensity = data.Intensity / 4f;
39+
hdLight.range = data.Falloff * 0.001f;
40+
41+
// TODO: vpe specific data for height
42+
light.transform.localPosition = new Vector3(0f, 0f, 25f);
43+
44+
hdLight.EnableShadows(false);
45+
46+
}
47+
}
48+
}

Runtime/LightConverter.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Materials/MaterialConverter.cs renamed to Runtime/MaterialConverter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17+
// ReSharper disable UnusedType.Global
18+
// ReSharper disable CheckNamespace
19+
1720
using System;
1821
using System.Text;
1922
using UnityEngine;
2023
using VisualPinball.Engine.VPT;
2124

2225
namespace VisualPinball.Unity.Hdrp
2326
{
24-
public class HdrpMaterialConverter : IMaterialConverter
27+
public class MaterialConverter : IMaterialConverter
2528
{
2629
#region Shader Properties
2730

File renamed without changes.

0 commit comments

Comments
 (0)