Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 036db18d0922d53419a5d769fe345bec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEditor;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class BloomConverter : PostProcessEffectSettingsConverter
{
#if PPV2_EXISTS
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.Bloom);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings, VolumeProfile targetProfile)
{
var oldBloom = oldSettings as BIRPRendering.Bloom;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.Bloom>(targetProfile);
newVolumeComponent.active = oldBloom.active;
oldBloom.clamp.Convert(newVolumeComponent.clamp);
oldBloom.diffusion.Convert(newVolumeComponent.scatter, scale: 0.05f);
oldBloom.intensity.Convert(newVolumeComponent.intensity, enabledState: oldBloom.enabled);
oldBloom.threshold.Convert(newVolumeComponent.threshold);
oldBloom.color.Convert(newVolumeComponent.tint);
oldBloom.dirtIntensity.Convert(newVolumeComponent.dirtIntensity);
oldBloom.dirtTexture.Convert(newVolumeComponent.dirtTexture);
oldBloom.fastMode.Convert(newVolumeComponent.highQualityFiltering, invertValue: true);
// TODO: No clear conversions for these?
// newVolumeComponent.skipIterations = oldBloom.???;
// newVolumeComponent.??? = oldBloom.anamorphicRatio;
// newVolumeComponent.??? = oldBloom.softKnee;
}
#endif
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65de241854404d343a0937eb1adbb6f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,34 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEditor;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class ChromaticAberrationConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.ChromaticAberration);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldChromaticAberration = oldSettings as BIRPRendering.ChromaticAberration;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.ChromaticAberration>(targetProfile);
newVolumeComponent.active = oldChromaticAberration.active;
// TODO: Verify that these are 1:1 conversions for visual parity
oldChromaticAberration.intensity.Convert(newVolumeComponent.intensity,
enabledState: oldChromaticAberration.enabled);
// TODO: No clear conversions for these?
// oldChromaticAberration.spectralLut
// oldChromaticAberration.fastMode
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef31d99f657209a468edc1f49b350cb5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,130 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEngine;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class ColorGradingConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.ColorGrading);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldColorGrading = oldSettings as BIRPRendering.ColorGrading;
var newTonemapping = AddVolumeComponentToAsset<URPRendering.Tonemapping>(targetProfile); // was: Tonemapping
var newWhiteBalance =
AddVolumeComponentToAsset<URPRendering.WhiteBalance>(targetProfile); // was: White Balance
var newColorAdjustments =
AddVolumeComponentToAsset<URPRendering.ColorAdjustments>(targetProfile); // was: Tone
var newTargetProfile =
AddVolumeComponentToAsset<URPRendering.ChannelMixer>(targetProfile); // was: Channel Mixer
var newLiftGammaGain =
AddVolumeComponentToAsset<URPRendering.LiftGammaGain>(targetProfile); // was: Trackballs
var newColorCurves =
AddVolumeComponentToAsset<URPRendering.ColorCurves>(targetProfile); // was: Grading Curves
// Tonemapping
newTonemapping.active = oldColorGrading.active;
ConvertTonemapper(oldColorGrading.tonemapper, newTonemapping.mode, oldColorGrading.enabled);
// White Balance
newWhiteBalance.active = oldColorGrading.active;
oldColorGrading.temperature.Convert(newWhiteBalance.temperature, enabledState: oldColorGrading.enabled);
oldColorGrading.tint.Convert(newWhiteBalance.tint, enabledState: oldColorGrading.enabled);
// Tone -> ColorAdjustments
newColorAdjustments.active = oldColorGrading.active;
oldColorGrading.postExposure.Convert(newColorAdjustments.postExposure,
enabledState: oldColorGrading.enabled);
oldColorGrading.colorFilter.Convert(newColorAdjustments.colorFilter, oldColorGrading.enabled,
disabledColor: Color.white);
oldColorGrading.hueShift.Convert(newColorAdjustments.hueShift, enabledState: oldColorGrading.enabled);
oldColorGrading.saturation.Convert(newColorAdjustments.saturation, enabledState: oldColorGrading.enabled);
oldColorGrading.contrast.Convert(newColorAdjustments.contrast, enabledState: oldColorGrading.enabled);
// Channel Mixer
newTargetProfile.active = oldColorGrading.active;
oldColorGrading.mixerRedOutRedIn.Convert(newTargetProfile.redOutRedIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerRedOutGreenIn.Convert(newTargetProfile.redOutGreenIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerRedOutBlueIn.Convert(newTargetProfile.redOutBlueIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerGreenOutRedIn.Convert(newTargetProfile.greenOutRedIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerGreenOutGreenIn.Convert(newTargetProfile.greenOutGreenIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerGreenOutBlueIn.Convert(newTargetProfile.greenOutBlueIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerBlueOutRedIn.Convert(newTargetProfile.blueOutRedIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerBlueOutGreenIn.Convert(newTargetProfile.blueOutGreenIn,
enabledState: oldColorGrading.enabled);
oldColorGrading.mixerBlueOutBlueIn.Convert(newTargetProfile.blueOutBlueIn,
enabledState: oldColorGrading.enabled);
// Trackballs -> LiftGammaGain
newLiftGammaGain.active = oldColorGrading.active;
// Note: URP always does color grading in HDR values (as it should),
// which means the non-HDR modes no longer have valid conversion targets.
// So, these values are left at defaults (neutral) when not previously using HDR.
if (oldColorGrading.gradingMode.value == BIRPRendering.GradingMode.HighDefinitionRange)
{
oldColorGrading.lift.Convert(newLiftGammaGain.lift, oldColorGrading.enabled);
oldColorGrading.gamma.Convert(newLiftGammaGain.gamma, oldColorGrading.enabled);
oldColorGrading.gain.Convert(newLiftGammaGain.gain, oldColorGrading.enabled);
}
// Grading Curves -> ColorCurves
newColorCurves.active = oldColorGrading.active;
oldColorGrading.masterCurve.Convert(newColorCurves.master, oldColorGrading.enabled);
oldColorGrading.redCurve.Convert(newColorCurves.red, oldColorGrading.enabled);
oldColorGrading.greenCurve.Convert(newColorCurves.green, oldColorGrading.enabled);
oldColorGrading.blueCurve.Convert(newColorCurves.blue, oldColorGrading.enabled);
oldColorGrading.hueVsHueCurve.Convert(newColorCurves.hueVsHue, oldColorGrading.enabled);
oldColorGrading.hueVsSatCurve.Convert(newColorCurves.hueVsSat, oldColorGrading.enabled);
oldColorGrading.satVsSatCurve.Convert(newColorCurves.satVsSat, oldColorGrading.enabled);
oldColorGrading.lumVsSatCurve.Convert(newColorCurves.lumVsSat, oldColorGrading.enabled);
}
private void ConvertTonemapper(BIRPRendering.TonemapperParameter birpSource,
URPRendering.TonemappingModeParameter target, bool enabledState)
{
if (target == null) return;
switch (birpSource.value)
{
case BIRPRendering.Tonemapper.Neutral:
target.value = URPRendering.TonemappingMode.Neutral;
break;
case BIRPRendering.Tonemapper.ACES:
target.value = URPRendering.TonemappingMode.ACES;
break;
default:
target.value = URPRendering.TonemappingMode.None;
break;
}
if (!enabledState)
{
target.value = URPRendering.TonemappingMode.None;
}
target.overrideState = birpSource.overrideState;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c93687e52abd628448c8f7666b1dbd23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,38 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class DepthOfFieldConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.DepthOfField);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldDepthOfField = oldSettings as BIRPRendering.DepthOfField;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.DepthOfField>(targetProfile);
newVolumeComponent.active = oldDepthOfField.active;
// Always use Bokeh mode, because it has parity with the PPv2 approach
newVolumeComponent.mode.value = oldDepthOfField.enabled
? URPRendering.DepthOfFieldMode.Bokeh
: URPRendering.DepthOfFieldMode.Off;
newVolumeComponent.mode.overrideState = true;
oldDepthOfField.focusDistance.Convert(newVolumeComponent.focusDistance, enabledState: oldSettings.enabled);
oldDepthOfField.focalLength.Convert(newVolumeComponent.focalLength, enabledState: oldSettings.enabled);
oldDepthOfField.aperture.Convert(newVolumeComponent.aperture, enabledState: oldSettings.enabled);
// TODO: No clear conversions for these?
// oldDepthOfField.kernelSize
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aa79bbd82ff697846b2723bb624f5b5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEditor;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class GrainConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.Grain);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldGrain = oldSettings as BIRPRendering.Grain;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.FilmGrain>(targetProfile);
newVolumeComponent.active = oldGrain.active;
oldGrain.intensity.Convert(newVolumeComponent.intensity, enabledState: oldGrain.enabled);
oldGrain.lumContrib.Convert(newVolumeComponent.response);
newVolumeComponent.type.overrideState = oldGrain.size.overrideState;
if (oldGrain.size.value > 1.5f)
newVolumeComponent.type.value = URPRendering.FilmGrainLookup.Medium3;
else if (oldGrain.size.value > 1.25f)
newVolumeComponent.type.value = URPRendering.FilmGrainLookup.Medium2;
else if (oldGrain.size.value > 0.7f)
newVolumeComponent.type.value = URPRendering.FilmGrainLookup.Thin2;
else
newVolumeComponent.type.value = URPRendering.FilmGrainLookup.Thin1;
// TODO: No clear conversions for these?
// oldGrain.colored
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df39fb04691e914469d4b4ae2a027fb4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class LensDistortionConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.LensDistortion);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldLensDistortion = oldSettings as BIRPRendering.LensDistortion;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.LensDistortion>(targetProfile);
newVolumeComponent.active = oldLensDistortion.active;
oldLensDistortion.intensity.Convert(newVolumeComponent.intensity,
scale: 0.01f,
enabledState: oldLensDistortion.enabled);
oldLensDistortion.intensityX.Convert(newVolumeComponent.xMultiplier);
oldLensDistortion.intensityY.Convert(newVolumeComponent.yMultiplier);
oldLensDistortion.scale.Convert(newVolumeComponent.scale);
newVolumeComponent.center.overrideState =
oldLensDistortion.centerX.overrideState || oldLensDistortion.centerY.overrideState;
newVolumeComponent.center.value =
new Vector2(oldLensDistortion.centerX.value, oldLensDistortion.centerY.value);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef0ef98463379a649ba68d026c95ea4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEditor;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class MotionBlurConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.MotionBlur);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings, VolumeProfile targetProfile)
{
var oldMotionBlur = oldSettings as BIRPRendering.MotionBlur;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.MotionBlur>(targetProfile);
newVolumeComponent.active = oldMotionBlur.active;
// Note: These settings cannot provide visual parity,
// but this scale factor provides a good starting point.
oldMotionBlur.shutterAngle.Convert(newVolumeComponent.intensity, scale: 1f / 360f, oldMotionBlur.enabled);
newVolumeComponent.quality.overrideState = oldMotionBlur.sampleCount.overrideState;
if (oldMotionBlur.sampleCount >= 24)
newVolumeComponent.quality.value = URPRendering.MotionBlurQuality.High;
else if (oldMotionBlur.sampleCount > 12)
newVolumeComponent.quality.value = URPRendering.MotionBlurQuality.Medium;
else
newVolumeComponent.quality.value = URPRendering.MotionBlurQuality.Low;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5d1c67b3de6d65a44b641566a9d529b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
#if PPV2_EXISTS
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public abstract class PostProcessEffectSettingsConverter : ScriptableObject
{
protected abstract Type OldSettingsType { get; }
public void AddConvertedProfileSettingsToProfile(
BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
if (oldSettings == null || oldSettings.GetType() != OldSettingsType) return;
if (targetProfile == null || targetProfile.Has(OldSettingsType)) return;
ConvertToTarget(oldSettings, targetProfile);
}
protected abstract void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldBloom,
VolumeProfile targetProfile);
protected T AddVolumeComponentToAsset<T>(VolumeProfile targetProfileAsset) where T : VolumeComponent
{
if (!targetProfileAsset) return null;
var profilePath = AssetDatabase.GetAssetPath(targetProfileAsset);
if (string.IsNullOrEmpty(profilePath)) return null;
var newVolumeComponent = targetProfileAsset.Add<T>();
AssetDatabase.AddObjectToAsset(newVolumeComponent, targetProfileAsset);
return newVolumeComponent;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fce1ffd6e78acfd4aa944af71b8a07d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,93 @@
#if PPV2_EXISTS
using System.Data;
using UnityEngine;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
namespace BIRPToURPConversionExtensions
{
public static class PropertyConversions
{
public static void Convert(this BIRPRendering.FloatParameter birpSource, FloatParameter target, float scale = 1f, bool enabledState = true)
{
if (target == null) return;
target.value = enabledState ? birpSource.value * scale : 0f;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.FloatParameter birpSource, MinFloatParameter target, float scale = 1f, bool enabledState = true)
{
if (target == null) return;
target.value = enabledState ? birpSource.value * scale : 0f;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.FloatParameter birpSource, ClampedFloatParameter target, float scale = 1f, bool enabledState = true)
{
if (target == null) return;
target.value = enabledState ? birpSource.value * scale : 0f;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.Vector2Parameter birpSource, Vector2Parameter target)
{
if (target == null) return;
target.value = birpSource.value;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.Vector4Parameter birpSource, Vector4Parameter target, bool enabledState = true)
{
if (target == null) return;
target.value = enabledState ? birpSource.value : new Vector4(1f, 1f, 1f, 0f);
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.ColorParameter birpSource, ColorParameter target, bool enabledState, Color disabledColor)
{
if (target == null) return;
target.value = enabledState ? birpSource.value : disabledColor;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.ColorParameter birpSource, ColorParameter target)
{
if (target == null) return;
target.value = birpSource.value;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.TextureParameter birpSource, TextureParameter target)
{
if (target == null) return;
target.value = birpSource.value;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.BoolParameter birpSource, BoolParameter target, bool invertValue = false)
{
if (target == null) return;
target.value = invertValue ? !birpSource.value : birpSource.value;
target.overrideState = birpSource.overrideState;
}
public static void Convert(this BIRPRendering.SplineParameter birpSource, TextureCurveParameter target, bool enabledState = true)
{
if (target == null) return;
target.value = new TextureCurve(birpSource.value.curve, zeroValue: 0f, loop: false, Vector2.up);
target.overrideState = birpSource.overrideState;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55392cd2a34cb21499958e42eba26b2d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
#if PPV2_EXISTS
using System;
using BIRPToURPConversionExtensions;
using UnityEngine.Rendering;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using URPRendering = UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
public class VignetteConverter : PostProcessEffectSettingsConverter
{
protected override Type OldSettingsType { get; } = typeof(BIRPRendering.Vignette);
protected override void ConvertToTarget(BIRPRendering.PostProcessEffectSettings oldSettings,
VolumeProfile targetProfile)
{
var oldVignette = oldSettings as BIRPRendering.Vignette;
var newVolumeComponent = AddVolumeComponentToAsset<URPRendering.Vignette>(targetProfile);
newVolumeComponent.active = oldVignette.active;
oldVignette.color.Convert(newVolumeComponent.color);
if (oldVignette.mode.value == BIRPRendering.VignetteMode.Masked)
{
// There's not much we can do with the Masked mode at present,
// so we just assume the old opacity should be used as intensity,
// and leave all other settings at default values.
oldVignette.opacity.Convert(newVolumeComponent.intensity, enabledState: oldSettings.enabled);
}
else
{
oldVignette.intensity.Convert(newVolumeComponent.intensity, enabledState: oldSettings.enabled);
oldVignette.center.Convert(newVolumeComponent.center);
oldVignette.rounded.Convert(newVolumeComponent.rounded);
oldVignette.smoothness.Convert(newVolumeComponent.smoothness);
}
// TODO: No clear conversions for these?
// oldVignette.mask
// oldVignette.roundness
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de573be7419f3b84295377f64cf664c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
#if PPV2_EXISTS
using UnityEditor.Search;
using UnityEngine;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
namespace UnityEditor.Rendering.Universal
{
static class PPv2ConversionIndexers
{
// Note: Iterating this version number does not force an index rebuild.
// If modifying this code, you will need to either delete the Library directory,
// or open "Window > Search > Index Manager" and right-click each indexer to do a Force Rebuild.
private const int Version = 10;
[CustomObjectIndexer(typeof(Object), version = Version)]
internal static void ConversionIndexer(CustomObjectIndexerTarget context, ObjectIndexer indexer)
{
// Note: Volumes and Layers on the same object would still produce only a
// single result in the "urp:convert-ppv2component" search, thus we only
// explicitly add one or the other here, instead of both.
if (context.targetType == typeof(BIRPRendering.PostProcessVolume))
{
indexer.AddProperty("urp", "convert-ppv2component", context.documentIndex);
}
else if (context.targetType == typeof(BIRPRendering.PostProcessLayer))
{
indexer.AddProperty("urp", "convert-ppv2component", context.documentIndex);
}
if (context.targetType == typeof(BIRPRendering.PostProcessProfile))
{
indexer.AddProperty("urp", "convert-ppv2scriptableobject", context.documentIndex);
}
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89952a5e365cbf54699031f6ee002f48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,498 @@
using System;
using System.Collections.Generic;
using System.Text;
using UnityEditor.Rendering.Converter;
using UnityEngine.Categorization;
using UnityEngine.Rendering.Universal;
#if PPV2_EXISTS
using UnityEngine;
using UnityEngine.Rendering;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor.SceneManagement;
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
using URPRendering = UnityEngine.Rendering.Universal;
#endif
namespace UnityEditor.Rendering.Universal
{
[URPHelpURL("urp/features/rp-converter")]
[Serializable]
[PipelineConverter("Built-in", "Universal Render Pipeline (Universal Renderer)")]
[BatchModeConverterClassInfo("BuiltInToURP", "PPv2")]
[ElementInfo(Name = "Post-Processing Stack v2",
Order = int.MaxValue,
Description = "This converter creates Universal Render Pipeline (URP) assets and corresponding Renderer assets, configuring their settings to match the equivalent settings from the Built-in Render Pipeline.")]
internal class PPv2Converter : AssetsConverter
{
#if PPV2_EXISTS
public override bool isEnabled => s_PostProcessTypesToSearch?.Count() > 0;
public override string isDisabledMessage => "Missing types to search";
private IEnumerable<PostProcessEffectSettingsConverter> effectConverters = null;
private List<Object> postConversionDestroyables = null;
protected override List<(string query, string description)> contextSearchQueriesAndIds
=> s_PostProcessTypesToSearch;
static List<(string, string)> s_PostProcessTypesToSearch = new()
{
("p: t:PostProcessVolume", "Contains Post Process Volume Component"),
("p: t:PostProcessLayer", "Contains Post Process Layer Component"),
("p: t:PostProcessProfile", "Contains Instance of Post Process Profile")
};
public override void BeforeConvert()
{
// Converters should already be set to null on domain reload,
// but we're doing it here just in case anything somehow lingers.
effectConverters = null;
postConversionDestroyables = new List<Object>();
}
protected override Status ConvertObject(UnityEngine.Object obj, StringBuilder message)
{
BIRPRendering.PostProcessVolume[] oldVolumes = null;
BIRPRendering.PostProcessLayer[] oldLayers = null;
// TODO: Upcoming changes to GlobalObjectIdentifierToObjectSlow will allow
// this to be inverted, and the else to be deleted.
#if false
if (obj is GameObject go)
{
oldVolumes = go.GetComponents<BIRPRendering.PostProcessVolume>();
oldLayers = go.GetComponents<BIRPRendering.PostProcessLayer>();
}
else if (obj is MonoBehaviour mb)
{
oldVolumes = mb.GetComponents<BIRPRendering.PostProcessVolume>();
oldLayers = mb.GetComponents<BIRPRendering.PostProcessLayer>();
}
#else
if (obj is GameObject go)
{
oldVolumes = go.GetComponentsInChildren<BIRPRendering.PostProcessVolume>();
oldLayers = go.GetComponentsInChildren<BIRPRendering.PostProcessLayer>();
}
else if (obj is MonoBehaviour mb)
{
oldVolumes = mb.GetComponentsInChildren<BIRPRendering.PostProcessVolume>();
oldLayers = mb.GetComponentsInChildren<BIRPRendering.PostProcessLayer>();
}
#endif
// Note: even if nothing needs to be converted, that should still count as success,
// though it shouldn't ever actually occur.
var succeeded = true;
if (effectConverters == null ||
effectConverters.Count() == 0 ||
effectConverters.Any(converter => converter == null))
{
effectConverters = GetAllBIRPConverters();
}
if (oldVolumes != null)
{
foreach (var oldVolume in oldVolumes)
{
ConvertVolume(oldVolume, ref succeeded, message);
}
}
if (oldLayers != null)
{
foreach (var oldLayer in oldLayers)
{
ConvertLayer(oldLayer, ref succeeded, message);
}
}
if (obj is BIRPRendering.PostProcessProfile oldProfile)
{
ConvertProfile(oldProfile, ref succeeded, message);
}
if (!succeeded)
{
return Status.Error;
}
else
{
var currentScene = SceneManager.GetActiveScene();
EditorSceneManager.SaveScene(currentScene);
return Status.Success;
}
}
public override void AfterConvert()
{
for (var i = 0; i < postConversionDestroyables.Count; i++)
{
Object.DestroyImmediate(postConversionDestroyables[i], allowDestroyingAssets: true);
}
postConversionDestroyables.Clear();
}
#region Conversion_Entry_Points
private void ConvertVolume(BIRPRendering.PostProcessVolume oldVolume, ref bool succeeded,
StringBuilder errorString)
{
if (!succeeded)
{
return;
}
if (!oldVolume)
{
// TODO: unless there's good way to tell the if the object is just missing because it was already
// converted as part of an earlier conversion object, then these two lines should be commented
// out or removed. It should still return though.
// succeeded = false;
// errorString.AppendLine("PPv2 PostProcessVolume failed to be converted because the original asset reference was lost during conversion.");
return;
}
if (PrefabUtility.IsPartOfPrefabInstance(oldVolume) &&
!PrefabUtility.IsAddedComponentOverride(oldVolume))
{
// This is a property override on an instance of the component,
// so override the component instance with the modifications.
succeeded = ConvertVolumeInstance(oldVolume, errorString);
}
else
{
// The entire component is unique, so just convert it
succeeded = ConvertVolumeComponent(oldVolume, errorString);
}
}
private void ConvertLayer(BIRPRendering.PostProcessLayer oldLayer, ref bool succeeded,
StringBuilder errorString)
{
if (!succeeded)
{
return;
}
if (!oldLayer)
{
// TODO: unless there's good way to tell the if the object is just missing because it was already
// converted as part of an earlier conversion object, then these two lines should be commented
// out or removed. It should still return though.
// succeeded = false;
// errorString.AppendLine("PPv2 PostProcessLayer failed to be converted because the original asset reference was lost during conversion.");
return;
}
if (PrefabUtility.IsPartOfPrefabInstance(oldLayer) &&
!PrefabUtility.IsAddedComponentOverride(oldLayer))
{
// This is a property override on an instance of the component,
// so override the component instance with the modifications.
succeeded = ConvertLayerInstance(oldLayer, errorString);
}
else
{
// The entire component is unique, so just convert it
succeeded = ConvertLayerComponent(oldLayer, errorString);
}
}
private void ConvertProfile(BIRPRendering.PostProcessProfile oldProfile, ref bool succeeded,
StringBuilder errorString)
{
if (!succeeded)
{
return;
}
if (!oldProfile)
{
errorString.AppendLine(
"PPv2 PostProcessProfile failed to be converted because the original asset reference was lost during conversion.");
return;
}
ConvertVolumeProfileAsset(oldProfile, errorString, ref succeeded);
// TODO:
// - Perhaps old Profiles should only be deleted if they actually no longer have references,
// just in case some some Volume conversions are skipped and still need references for future conversion.
// - Alternatively, leave deletion of Profiles entirely to the user. (I think this is preferred)
}
#endregion Conversion_Entry_Points
private bool ConvertVolumeComponent(BIRPRendering.PostProcessVolume oldVolume, StringBuilder errorString)
{
// Don't convert if it appears to already have been converted.
if (oldVolume.GetComponent<Volume>()) return true;
var gameObject = oldVolume.gameObject;
var newVolume = gameObject.AddComponent<Volume>();
newVolume.priority = oldVolume.priority;
newVolume.weight = oldVolume.weight;
newVolume.blendDistance = oldVolume.blendDistance;
newVolume.isGlobal = oldVolume.isGlobal;
newVolume.enabled = oldVolume.enabled;
var success = true;
newVolume.sharedProfile = ConvertVolumeProfileAsset(oldVolume.sharedProfile, errorString, ref success);
if (PrefabUtility.IsPartOfPrefabAsset(oldVolume))
{
postConversionDestroyables.Add(oldVolume);
}
else
{
Object.DestroyImmediate(oldVolume, allowDestroyingAssets: true);
}
EditorUtility.SetDirty(gameObject);
return success;
}
private bool ConvertVolumeInstance(BIRPRendering.PostProcessVolume oldVolume, StringBuilder errorString)
{
// First get a reference to the local instance of the converted component
// which may require immediately converting it at its origin location first.
var newVolumeInstance = oldVolume.GetComponent<Volume>();
if (!newVolumeInstance)
{
var oldVolumeOrigin = PrefabUtility.GetCorrespondingObjectFromSource(oldVolume);
if (!ConvertVolumeComponent(oldVolumeOrigin, errorString))
{
return false;
}
PrefabUtility.SavePrefabAsset(oldVolumeOrigin.gameObject);
newVolumeInstance = oldVolume.GetComponent<Volume>();
if (!newVolumeInstance)
{
errorString.AppendLine(
"PPv2 PostProcessVolume failed to be converted because the instance object did not inherit the converted Prefab source.");
return false;
}
}
bool success = true;
var oldModifications = PrefabUtility.GetPropertyModifications(oldVolume);
foreach (var oldModification in oldModifications)
{
if (oldModification.target is BIRPRendering.PostProcessVolume)
{
if (oldModification.propertyPath.EndsWith("priority", StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.priority = oldVolume.priority;
else if (oldModification.propertyPath.EndsWith("weight",
StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.weight = oldVolume.weight;
else if (oldModification.propertyPath.EndsWith("blendDistance",
StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.blendDistance = oldVolume.blendDistance;
else if (oldModification.propertyPath.EndsWith("isGlobal",
StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.isGlobal = oldVolume.isGlobal;
else if (oldModification.propertyPath.EndsWith("enabled",
StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.enabled = oldVolume.enabled;
else if (oldModification.propertyPath.EndsWith("sharedProfile",
StringComparison.InvariantCultureIgnoreCase))
newVolumeInstance.sharedProfile =
ConvertVolumeProfileAsset(oldVolume.sharedProfile, errorString, ref success);
EditorUtility.SetDirty(newVolumeInstance);
}
}
return success;
}
private bool ConvertLayerComponent(BIRPRendering.PostProcessLayer oldLayer, StringBuilder errorString)
{
var siblingCamera = oldLayer.GetComponent<Camera>().GetUniversalAdditionalCameraData();
// PostProcessLayer requires a sibling Camera component, but
// we check it here just in case something weird went happened.
if (!siblingCamera)
{
errorString.AppendLine(
"PPv2 PostProcessLayer failed to be converted because the instance object was missing a required sibling Camera component.");
return false;
}
// The presence of a PostProcessLayer implies the Camera should render post-processes
siblingCamera.renderPostProcessing = true;
siblingCamera.volumeLayerMask = oldLayer.volumeLayer;
siblingCamera.volumeTrigger = oldLayer.volumeTrigger;
siblingCamera.stopNaN = oldLayer.stopNaNPropagation;
siblingCamera.antialiasingQuality =
(URPRendering.AntialiasingQuality)oldLayer.subpixelMorphologicalAntialiasing.quality;
switch (oldLayer.antialiasingMode)
{
case BIRPRendering.PostProcessLayer.Antialiasing.None:
siblingCamera.antialiasing = URPRendering.AntialiasingMode.None;
break;
case BIRPRendering.PostProcessLayer.Antialiasing.FastApproximateAntialiasing:
siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
break;
case BIRPRendering.PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing:
siblingCamera.antialiasing = URPRendering.AntialiasingMode.SubpixelMorphologicalAntiAliasing;
break;
default:
// Default to the the most performant mode, since "None" is an explicit option.
siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
break;
}
if (PrefabUtility.IsPartOfPrefabAsset(oldLayer))
{
postConversionDestroyables.Add(oldLayer);
}
else
{
Object.DestroyImmediate(oldLayer, allowDestroyingAssets: true);
}
EditorUtility.SetDirty(siblingCamera.gameObject);
return true;
}
private bool ConvertLayerInstance(BIRPRendering.PostProcessLayer oldLayer, StringBuilder errorString)
{
// First get a reference to the local instance of the camera (which is required by PostProcessingLayer)
var siblingCamera = oldLayer.GetComponent<Camera>().GetUniversalAdditionalCameraData();
if (!siblingCamera)
{
errorString.AppendLine(
"PPv2 PostProcessLayer failed to be converted because the instance object was missing a required sibling Camera component.");
return false;
}
var oldModifications = PrefabUtility.GetPropertyModifications(oldLayer);
foreach (var oldModification in oldModifications)
{
if (oldModification.target is BIRPRendering.PostProcessLayer)
{
if (oldModification.propertyPath.EndsWith("volumeLayer",
StringComparison.InvariantCultureIgnoreCase))
siblingCamera.volumeLayerMask = oldLayer.volumeLayer;
else if (oldModification.propertyPath.EndsWith("volumeTrigger",
StringComparison.InvariantCultureIgnoreCase))
siblingCamera.volumeTrigger = oldLayer.volumeTrigger;
else if (oldModification.propertyPath.EndsWith("stopNaNPropagation",
StringComparison.InvariantCultureIgnoreCase))
siblingCamera.stopNaN = oldLayer.stopNaNPropagation;
else if (oldModification.propertyPath.EndsWith("quality",
StringComparison.InvariantCultureIgnoreCase))
siblingCamera.antialiasingQuality =
(URPRendering.AntialiasingQuality)oldLayer.subpixelMorphologicalAntialiasing.quality;
else if (oldModification.propertyPath.EndsWith("antialiasingMode",
StringComparison.InvariantCultureIgnoreCase))
{
switch (oldLayer.antialiasingMode)
{
case BIRPRendering.PostProcessLayer.Antialiasing.None:
siblingCamera.antialiasing = URPRendering.AntialiasingMode.None;
break;
case BIRPRendering.PostProcessLayer.Antialiasing.FastApproximateAntialiasing:
siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
break;
case BIRPRendering.PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing:
siblingCamera.antialiasing =
URPRendering.AntialiasingMode.SubpixelMorphologicalAntiAliasing;
break;
default:
// Default to the the most performant mode, since "None" is an explicit option.
siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
break;
}
}
EditorUtility.SetDirty(siblingCamera);
}
}
return true;
}
private VolumeProfile ConvertVolumeProfileAsset(BIRPRendering.PostProcessProfile oldProfile,
StringBuilder errorString, ref bool success)
{
// Don't convert if it appears to already have been converted.
if (!oldProfile) return null;
var oldPath = AssetDatabase.GetAssetPath(oldProfile);
var oldDirectory = Path.GetDirectoryName(oldPath);
var oldName = Path.GetFileNameWithoutExtension(oldPath);
var newPath = Path.Combine(oldDirectory, $"{oldName}(URP).asset");
if (File.Exists(newPath))
{
return AssetDatabase.LoadAssetAtPath<VolumeProfile>(newPath);
}
var newProfile = ScriptableObject.CreateInstance<VolumeProfile>();
try
{
AssetDatabase.CreateAsset(newProfile, newPath);
}
catch (Exception e)
{
errorString.AppendLine($"PPv2 PostProcessLayer failed to be converted with exception:\n{e}");
success = false;
if (!newProfile) return null;
}
foreach (var oldSettings in oldProfile.settings)
{
foreach (var effectConverter in effectConverters)
{
effectConverter.AddConvertedProfileSettingsToProfile(oldSettings, newProfile);
}
}
EditorUtility.SetDirty(newProfile);
return newProfile;
}
public IEnumerable<PostProcessEffectSettingsConverter> GetAllBIRPConverters()
{
var baseType = typeof(PostProcessEffectSettingsConverter);
var assembly = Assembly.GetAssembly(baseType);
var derivedTypes = assembly
.GetTypes()
.Where(t =>
t.BaseType != null &&
t.BaseType == baseType)
.Select(t => ScriptableObject.CreateInstance(t) as PostProcessEffectSettingsConverter);
return derivedTypes;
}
#else
public override bool isEnabled => false;
public override string isDisabledMessage => "Post Processing package is not installed. Please install the Post Processing package to enable this converter.";
protected override List<(string query, string description)> contextSearchQueriesAndIds
=> null;
protected override Status ConvertObject(UnityEngine.Object obj, StringBuilder message) { return Status.Error; }
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 54019ac30a4ca724eac51bad54f48aac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: