Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Assets/Resources/Prefabs/Trough.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ MonoBehaviour:
PlayfieldExitKickerItem:
Ball: {fileID: 0}
BallCount: 6
BallPrefabs:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
SwitchCount: 6
JamSwitch: 0
RollTime: 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 8928362396421481961}
- component: {fileID: 1782985097271273431}
m_Layer: 0
m_Name: DefaultBall
m_Name: UrpBall
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -92,7 +92,7 @@ MeshFilter:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8440806518127559228}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
m_Mesh: {fileID: 4983844940297228651, guid: d78bc7cfea69c684c8c631e82dd9e206, type: 3}
--- !u!23 &7632225475359270604
MeshRenderer:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Runtime/MaterialAdapter.cs → Editor/MaterialAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using NLog;
using UnityEngine;
using VisualPinball.Unity.Editor;
using Logger = NLog.Logger;

namespace VisualPinball.Unity.Urp
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Runtime/PrefabProvider.cs → Editor/PrefabProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using UnityEngine;
using VisualPinball.Engine.VPT;
using VisualPinball.Unity.Editor;

namespace VisualPinball.Unity.Urp
{
Expand Down
File renamed without changes.
35 changes: 35 additions & 0 deletions Editor/UniversalRenderPipelineConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Visual Pinball Engine
// Copyright (C) 2020 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// ReSharper disable UnusedType.Global
// ReSharper disable CheckNamespace

using VisualPinball.Unity;
using VisualPinball.Unity.Editor;

namespace VisualPinball.Unity.Urp
{
public class UniversalRenderPipelineConverter : IRenderPipelineConverter
{
public const string PrefabPath = "Packages/org.visualpinball.engine.unity.urp/Prefabs";

public string Name => "Universal Render Pipeline";

public RenderPipelineType Type => RenderPipelineType.Urp;
public IMaterialAdapter MaterialAdapter { get; } = new MaterialAdapter();
public IPrefabProvider PrefabProvider { get; } = new PrefabProvider();
}
}
2 changes: 2 additions & 0 deletions Editor/UniversalRenderPipelineConverter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions Editor/VisualPinball.Engine.Unity.Urp.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "VisualPinball.Engine.Unity.Urp.Editor",
"rootNamespace": "VisualPinball.Unity.Urp",
"references": [
"VisualPinball.Engine",
"VisualPinball.Engine.Editor",
"VisualPinball.Unity",
"VisualPinball.Unity.Patcher",
"VisualPinball.Unity.Editor",
"VisualPinball.Engine.Unity.Urp",
"Unity.RenderPipelines.Core.Runtime",
"Unity.RenderPipelines.Universal.Runtime"
],
"includePlatforms": [ "Editor" ],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/VisualPinball.Engine.Unity.Urp.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Runtime/BallConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class BallConverter : IBallConverter
{
public GameObject CreateDefaultBall()
{
return UnityEngine.Resources.Load<GameObject>("Prefabs/DefaultBall");
return UnityEngine.Resources.Load<GameObject>("Prefabs/UrpBall");
}
}
}
33 changes: 25 additions & 8 deletions Runtime/MaterialConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,45 @@ public void SetMaterialType(Material material, MaterialType materialType)
// todo
}

// URP/Lit has a single HDR _EmissionColor instead of HDRP's LDR-color + intensity split.
// The equivalent semantics used here: intensity = max component of the material's emission
// color, chroma = emission color normalized by that maximum. GetEmissiveIntensity therefore
// returns the authored full-on intensity (the baseline LightComponent remembers), and
// SetEmissiveIntensity rebuilds chroma × intensity into the property block.

private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");

public void SetEmissiveColor(MaterialPropertyBlock propBlock, Color color)
{
// urp has no emissive color
propBlock.SetColor(EmissionColor, color);
}

public Color? GetEmissiveColor(Material material)
{
// urp has no emissive color

return null;
if (!material || !material.HasProperty(EmissionColor)) {
return null;
}
return material.GetColor(EmissionColor);
}

public void SetEmissiveIntensity(Material material, MaterialPropertyBlock propBlock, float intensity)
{
// urp has no emissive intensity
if (!material || !material.HasProperty(EmissionColor)) {
return;
}
var baseline = material.GetColor(EmissionColor);
var max = baseline.maxColorComponent;
var chroma = max > 0f ? baseline / max : Color.white;
chroma.a = 1f;
propBlock.SetColor(EmissionColor, chroma * intensity);
}

public float GetEmissiveIntensity(Material material)
{
// urp has no emissive intensity
//
return 0;
if (!material || !material.HasProperty(EmissionColor) || !material.IsKeywordEnabled("_EMISSION")) {
return 0;
}
return material.GetColor(EmissionColor).maxColorComponent;
}
}
}
2 changes: 0 additions & 2 deletions Runtime/UniversalRenderPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public class UniversalRenderPipeline : IRenderPipeline

public RenderPipelineType Type { get; } = RenderPipelineType.Urp;
public IMaterialConverter MaterialConverter { get; } = new MaterialConverter();
public IMaterialAdapter MaterialAdapter { get; } = new MaterialAdapter();
public ILightConverter LightConverter { get; } = new LightConverter();
public IBallConverter BallConverter { get; } = new BallConverter();
public IPrefabProvider PrefabProvider { get; } = new PrefabProvider();
}
}
Loading