initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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.Converters
|
||||
{
|
||||
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,607 @@
|
|||
#if PPV2_EXISTS
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Rendering;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEditor.Search;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.SceneManagement;
|
||||
using BIRPRendering = UnityEngine.Rendering.PostProcessing;
|
||||
using Object = UnityEngine.Object;
|
||||
using URPRenderingEditor = UnityEditor.Rendering.Universal;
|
||||
using URPRendering = UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.Converters
|
||||
{
|
||||
internal class PPv2Converter : RenderPipelineConverter
|
||||
{
|
||||
public override string name => "Post-Processing Stack v2 Converter";
|
||||
public override string info =>
|
||||
"Converts PPv2 Volumes, Profiles, and Layers to URP Volumes, Profiles, and Cameras.";
|
||||
public override Type container => typeof(BuiltInToURPConverterContainer);
|
||||
public override bool needsIndexing => true;
|
||||
|
||||
private IEnumerable<PostProcessEffectSettingsConverter> effectConverters = null;
|
||||
|
||||
private List<Object> postConversionDestroyables = null;
|
||||
|
||||
List<string> guids = new List<string>();
|
||||
public override void OnInitialize(InitializeConverterContext context, Action callback)
|
||||
{
|
||||
// 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>();
|
||||
|
||||
// We are using separate searchContexts here and Adding them in this order:
|
||||
// - Components from Prefabs & Scenes (Volumes & Layers)
|
||||
// - ScriptableObjects (Profiles)
|
||||
//
|
||||
// This allows the old objects to be both re-referenced and deleted safely as they are converted in OnRun.
|
||||
// The process of converting Volumes will convert Profiles as-needed, and then the explicit followup Profile
|
||||
// conversion step will convert any non-referenced assets and delete all old Profiles.
|
||||
Debug.Log("Running here");
|
||||
// Components First
|
||||
using var componentContext =
|
||||
Search.SearchService.CreateContext("asset", "urp:convert-ppv2component");
|
||||
using var componentItems = Search.SearchService.Request(componentContext);
|
||||
{
|
||||
Debug.Log("First Search");
|
||||
AddSearchItemsAsConverterAssetEntries(componentItems, context);
|
||||
}
|
||||
|
||||
// Then ScriptableObjects
|
||||
using var scriptableObjectContext =
|
||||
Search.SearchService.CreateContext("asset", "urp:convert-ppv2scriptableobject");
|
||||
using var scriptableObjectItems = Search.SearchService.Request(scriptableObjectContext);
|
||||
{
|
||||
Debug.Log("Second Search");
|
||||
AddSearchItemsAsConverterAssetEntries(scriptableObjectItems, context);
|
||||
}
|
||||
|
||||
callback.Invoke();
|
||||
}
|
||||
|
||||
public override void OnRun(ref RunItemContext context)
|
||||
{
|
||||
var obj = GetContextObject(ref context);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
context.didFail = true;
|
||||
context.info = "Could not be converted because the target object was lost.";
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
var errorString = new StringBuilder();
|
||||
|
||||
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, errorString);
|
||||
}
|
||||
}
|
||||
|
||||
if (oldLayers != null)
|
||||
{
|
||||
foreach (var oldLayer in oldLayers)
|
||||
{
|
||||
ConvertLayer(oldLayer, ref succeeded, errorString);
|
||||
}
|
||||
}
|
||||
|
||||
if (obj is BIRPRendering.PostProcessProfile oldProfile)
|
||||
{
|
||||
ConvertProfile(oldProfile, ref succeeded, errorString);
|
||||
}
|
||||
|
||||
if (!succeeded)
|
||||
{
|
||||
context.didFail = true;
|
||||
context.info = errorString.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentScene = SceneManager.GetActiveScene();
|
||||
EditorSceneManager.SaveScene(currentScene);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPostRun()
|
||||
{
|
||||
for (var i = 0; i < postConversionDestroyables.Count; i++)
|
||||
{
|
||||
Object.DestroyImmediate(postConversionDestroyables[i], allowDestroyingAssets: true);
|
||||
}
|
||||
|
||||
postConversionDestroyables.Clear();
|
||||
}
|
||||
|
||||
public override void OnClicked(int index)
|
||||
{
|
||||
if (GlobalObjectId.TryParse(guids[index], out var gid))
|
||||
{
|
||||
var containerPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID);
|
||||
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<Object>(containerPath));
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSearchItemsAsConverterAssetEntries(ISearchList searchItems, InitializeConverterContext context)
|
||||
{
|
||||
foreach (var searchItem in searchItems)
|
||||
{
|
||||
if (searchItem == null || !GlobalObjectId.TryParse(searchItem.id, out var globalId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var description = searchItem.provider.fetchDescription(searchItem, searchItem.context);
|
||||
|
||||
var item = new ConverterItemDescriptor()
|
||||
{
|
||||
name = description.Split('/').Last().Split('.').First(),
|
||||
info = $"{ReturnType(globalId)}",
|
||||
};
|
||||
|
||||
guids.Add(globalId.ToString());
|
||||
context.AddAssetToConvert(item);
|
||||
}
|
||||
}
|
||||
|
||||
string ReturnType(GlobalObjectId gid)
|
||||
{
|
||||
var containerPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID);
|
||||
return AssetDatabase.LoadAssetAtPath<Object>(containerPath).GetType().ToString().Split('.').Last();
|
||||
}
|
||||
|
||||
private Object GetContextObject(ref RunItemContext ctx)
|
||||
{
|
||||
var item = ctx.item;
|
||||
var guid = guids[item.index];
|
||||
|
||||
if (GlobalObjectId.TryParse(guid, out var globalId))
|
||||
{
|
||||
// Try loading the object
|
||||
// TODO: Upcoming changes to GlobalObjectIdentifierToObjectSlow will allow it
|
||||
// to return direct references to prefabs and their children.
|
||||
// Once that change happens there are several items which should be adjusted.
|
||||
var obj = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalId);
|
||||
|
||||
// If the object was not loaded, it is probably part of an unopened scene;
|
||||
// if so, then the solution is to first load the scene here.
|
||||
var objIsInSceneOrPrefab = globalId.identifierType == 2; // 2 is IdentifierType.kSceneObject
|
||||
if (!obj &&
|
||||
objIsInSceneOrPrefab)
|
||||
{
|
||||
// Open the Containing Scene Asset in the Hierarchy so the Object can be manipulated
|
||||
var mainAssetPath = AssetDatabase.GUIDToAssetPath(globalId.assetGUID);
|
||||
var mainAsset = AssetDatabase.LoadAssetAtPath<Object>(mainAssetPath);
|
||||
AssetDatabase.OpenAsset(mainAsset);
|
||||
|
||||
// If a prefab stage was opened, then mainAsset is the root of the
|
||||
// prefab that contains the target object, so reference that for now,
|
||||
// until GlobalObjectIdentifierToObjectSlow is updated
|
||||
if (PrefabStageUtility.GetCurrentPrefabStage() != null)
|
||||
{
|
||||
obj = mainAsset;
|
||||
}
|
||||
|
||||
// Reload object if it is still null (because it's in a previously unopened scene)
|
||||
if (!obj)
|
||||
{
|
||||
obj = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalId);
|
||||
if (!obj)
|
||||
{
|
||||
ctx.didFail = true;
|
||||
ctx.info = $"Object {globalId.assetGUID} failed to load...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
ctx.didFail = true;
|
||||
ctx.info = $"Failed to parse Global ID {item.descriptor.info}...";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54019ac30a4ca724eac51bad54f48aac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "PPv2URPConverters",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:c579267770062bf448e75eb160330b7f",
|
||||
"GUID:a35efad8797223d499f8c68b1f545dbc",
|
||||
"GUID:15fc0a57446b3144c949da3e2b9737a9",
|
||||
"GUID:d60799ab2a985554ea1a39cd38695018",
|
||||
"GUID:3eae0364be2026648bf74846acb8a731",
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.postprocessing",
|
||||
"expression": "0.0.1",
|
||||
"define": "PPV2_EXISTS"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3fa284cf2189b184e8d506b83da68377
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue