This commit is contained in:
StarBeats 2024-12-24 09:48:22 +08:00
parent 656145eb07
commit 3c9b8e3517
6 changed files with 118 additions and 7 deletions

View File

@ -114,5 +114,5 @@ MonoBehaviour:
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0
superResolution: 4
superResolution: 0
vrsRate: 0

View File

@ -35,6 +35,20 @@ MonoBehaviour:
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
--- !u!114 &-1133205096357012623
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4eb2cc831c604d74bbc6c526ff11163f, type: 3}
m_Name: DLSS
m_EditorClassIdentifier:
m_Active: 0
quality: 0
--- !u!114 &-194876054633339434
MonoBehaviour:
m_ObjectHideFlags: 0
@ -82,7 +96,8 @@ MonoBehaviour:
- {fileID: 6334271670068977784}
- {fileID: 1342351342872651138}
- {fileID: 6446168921458335383}
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222f0f17d10860a28157820480586dae7578265b12b6ffda01297deaf157b647559
- {fileID: -1133205096357012623}
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222f0f17d10860a28157820480586dae7578265b12b6ffda01297deaf157b647559715bfa05f80b46f0
m_UseNativeRenderPass: 1
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
shaders:
@ -177,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a6b8ba513f1b1fe499924f362fdde22d, type: 3}
m_Name: GSR
m_EditorClassIdentifier:
m_Active: 1
m_Active: 0
quality: 3
v1settings:
EnableEdgeDirection: 1

View File

@ -497,10 +497,7 @@ namespace UnityEngine.Rendering.Universal
}
var asset = UniversalRenderPipeline.asset;
// SuperResolution
if (asset.SuperResolution == ESuperResolution.GSR1
|| asset.SuperResolution == ESuperResolution.GSR2
|| asset.SuperResolution == ESuperResolution.METAL_FX_SPATIAL_SR
|| asset.SuperResolution == ESuperResolution.XESS13)
if (asset.SuperResolution != ESuperResolution.None)
{
ref var colorDescriptor = ref cameraData.cameraTargetDescriptor;
colorDescriptor.width = cameraData.camera.pixelWidth;

View File

@ -0,0 +1,87 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace X.Rendering.Feature
{
public class DLSS : ScriptableRendererFeature, ISuperResolutionFeature
{
[SerializeField]
public UnityEngine.NVIDIA.DLSSQuality quality;
private ProfilingSampler profiler;
private static uint expectedDeviceVersion = 0x04;
private static bool supportDLSS;
public static bool SupportDLSS { get => supportDLSS;}
private UnityEngine.NVIDIA.GraphicsDevice gfxDevice = null;
public static bool InitFeature()
{
if (!UnityEngine.NVIDIA.NVUnityPlugin.IsLoaded())
{
return false;
}
if (expectedDeviceVersion != UnityEngine.NVIDIA.GraphicsDevice.version)
{
Debug.LogWarning("Cannot instantiate NVIDIA device because the version expects does not match the backend version.");
return false;
}
if (!SystemInfo.graphicsDeviceVendor.ToLowerInvariant().Contains("nvidia"))
{
return false;
}
var device = UnityEngine.NVIDIA.GraphicsDevice.CreateGraphicsDevice();
return device != null && device.IsFeatureAvailable(UnityEngine.NVIDIA.GraphicsDeviceFeature.DLSS);
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
}
public override void Create()
{
supportDLSS = InitFeature();
profiler = new ProfilingSampler("NV.DLSS");
gfxDevice = UnityEngine.NVIDIA.GraphicsDevice.device;
}
public void DoSR(CommandBuffer cmd, RTHandle source, RTHandle destination, RTHandle motionVector, ref RenderingData renderingData)
{
using var scp = new ProfilingScope(cmd, profiler);
}
public float GetRenderScale()
{
return 0;
}
public void SetSR(ESuperResolution resolution)
{
switch (resolution)
{
case ESuperResolution.DLSS1:
case ESuperResolution.DLSS2:
case ESuperResolution.DLSS3:
{
if (SupportDLSS)
{
SetActive(true);
}
break;
}
default:
{
SetActive(false);
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: Cy9Nt3n+W3hDJG+ZFGXRsiMRG5HzmWs7zQeWLxDvXMtBHl5sJI455Ak=
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -24,6 +24,7 @@ namespace X.Rendering.Feature
DLSS1,
DLSS2,
DLSS3,
STP,// Unity 6 空间-时间后处理中的 upscaling
/// <summary>
/// Intel XeSS 1.3.1
/// <see cref="https://github.com/intel/xess.git"/>