xess add sharp pass
This commit is contained in:
parent
e3216e3cd6
commit
19aec25a3d
@ -1,5 +1,5 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:yousandi.cn,2023:
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -28,7 +28,7 @@ MonoBehaviour:
|
||||
m_SupportsHDR: 1
|
||||
m_HDRColorBufferPrecision: 0
|
||||
m_MSAA: 1
|
||||
m_RenderScale: 0.58823526
|
||||
m_RenderScale: 0.5
|
||||
m_UpscalingFilter: 0
|
||||
m_FsrOverrideSharpness: 1
|
||||
m_FsrSharpness: 1
|
||||
@ -114,5 +114,5 @@ MonoBehaviour:
|
||||
m_PrefilterNativeRenderPass: 1
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
superResolution: 0
|
||||
superResolution: 16
|
||||
vrsRate: 0
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:yousandi.cn,2023:
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-8576419846133267094
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -103,7 +103,7 @@ MonoBehaviour:
|
||||
m_Name: DLSS
|
||||
m_EditorClassIdentifier:
|
||||
m_Active: 0
|
||||
quality: 1
|
||||
quality: 3
|
||||
useOptimalSetting: 1
|
||||
sharpness: 0.126
|
||||
preExposure: 0.214
|
||||
@ -318,7 +318,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: b1643a5e9ea49724e8a7bc2c6f3713e1, type: 3}
|
||||
m_Name: XESS
|
||||
m_EditorClassIdentifier:
|
||||
m_Active: 0
|
||||
m_Active: 1
|
||||
xess1ConfigParam:
|
||||
OutputWidth: 2560
|
||||
OutputHeight: 1440
|
||||
@ -338,6 +338,9 @@ MonoBehaviour:
|
||||
ExposureScale: 1
|
||||
MipMapBias: 0
|
||||
antiGhosting: 0.1
|
||||
sharpMaterial: {fileID: 2100000, guid: b356b97c3a610794582dd87ab85f4e98, type: 2}
|
||||
sharpness: 0.493
|
||||
sharpMipLevel: 0
|
||||
--- !u!114 &6334271670068977784
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -164,8 +164,8 @@ namespace X.Rendering.Feature
|
||||
dlssContext.executeData.subrectOffsetY = 0;
|
||||
dlssContext.executeData.subrectWidth = inputWidth;
|
||||
dlssContext.executeData.subrectHeight = inputHeight;
|
||||
dlssContext.executeData.jitterOffsetX = -jitter.x;
|
||||
dlssContext.executeData.jitterOffsetY = -jitter.y;
|
||||
dlssContext.executeData.jitterOffsetX = jitter.x;
|
||||
dlssContext.executeData.jitterOffsetY = jitter.y;
|
||||
dlssContext.executeData.preExposure = preExposure;
|
||||
dlssContext.executeData.invertYAxis = 1u;
|
||||
dlssContext.executeData.invertXAxis = 0u;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
@ -79,6 +78,13 @@ namespace X.Rendering.Feature
|
||||
[Range(0, 1)]
|
||||
public float antiGhosting;
|
||||
|
||||
[SerializeField]
|
||||
private Material sharpMaterial;
|
||||
[SerializeField, Range(0, 2)]
|
||||
private float sharpness;
|
||||
[SerializeField,Range(0, 4)]
|
||||
private int sharpMipLevel;
|
||||
|
||||
private bool needTurnOnXess = false;
|
||||
private bool needTurnOffXess = false;
|
||||
IntPtr xess1ExecParamPtr;
|
||||
@ -86,6 +92,8 @@ namespace X.Rendering.Feature
|
||||
private ProfilingSampler profiler;
|
||||
XessQuality lastQuality;
|
||||
|
||||
private RTHandle tempRT;
|
||||
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
}
|
||||
@ -173,10 +181,29 @@ namespace X.Rendering.Feature
|
||||
return;
|
||||
}
|
||||
|
||||
bool sharpPass = false;
|
||||
if (sharpness > 0)
|
||||
{
|
||||
sharpPass = true;
|
||||
var desc = renderingData.cameraData.cameraTargetDescriptor;
|
||||
desc.width = destination.referenceSize.x;
|
||||
desc.height = destination.referenceSize.y;
|
||||
desc.enableRandomWrite = true;
|
||||
desc.depthBufferBits = 0;
|
||||
desc.graphicsFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.B10G11R11_UFloatPack32;
|
||||
RenderingUtils.ReAllocateIfNeeded(ref tempRT, desc);
|
||||
}
|
||||
|
||||
xessexecPtr->ColorTexture = source.rt.GetNativeTexturePtr();
|
||||
xessexecPtr->VelocityTexture = motionVector.rt.GetNativeTexturePtr();
|
||||
|
||||
xessexecPtr->OutputTexture = destination.rt.GetNativeTexturePtr();
|
||||
if (sharpPass)
|
||||
{
|
||||
xessexecPtr->OutputTexture = tempRT.rt.GetNativeTexturePtr();
|
||||
}
|
||||
else
|
||||
{
|
||||
xessexecPtr->OutputTexture = destination.rt.GetNativeTexturePtr();
|
||||
}
|
||||
xessexecPtr->DepthTexture = renderingData.cameraData.renderer.cameraDepthTargetHandle.rt.GetNativeTexturePtr();
|
||||
xessexecPtr->Jitterx = jitter.x;
|
||||
xessexecPtr->Jittery = -jitter.y;
|
||||
@ -188,6 +215,15 @@ namespace X.Rendering.Feature
|
||||
needTurnOffXess = false;
|
||||
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.DisableXESS1, IntPtr.Zero);
|
||||
}
|
||||
|
||||
if (sharpPass)
|
||||
{
|
||||
sharpMaterial.SetInt("_BlitMipLevel", sharpMipLevel);
|
||||
sharpMaterial.SetFloat("_Sharpness", sharpness);
|
||||
sharpMaterial.SetTexture("_InputTexture", tempRT);
|
||||
cmd.SetRenderTarget(destination, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, sharpMaterial, 0, MeshTopology.Triangles, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSR(ESuperResolution resolution)
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Unlit_XessRcas
|
||||
m_Shader: {fileID: 4800000, guid: 54220985e7800454393f9c15af20fdc6, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Ints: []
|
||||
m_Floats: []
|
||||
m_Colors: []
|
||||
m_BuildTextureStacks: []
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b356b97c3a610794582dd87ab85f4e98
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,112 @@
|
||||
Shader "Unlit/XessRcas"
|
||||
{
|
||||
|
||||
SubShader
|
||||
{
|
||||
LOD 100
|
||||
ZWrite Off ZTest Always Blend Off Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
SamplerState sampler_LinearClamp;
|
||||
Texture2D<float4> _InputTexture;
|
||||
|
||||
float _BlitMipLevel;
|
||||
float _Sharpness;
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
precise float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
float2 GetFullScreenTriangleTexCoord(uint vertexID)
|
||||
{
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
return float2((vertexID << 1) & 2, 1.0 - (vertexID & 2));
|
||||
#else
|
||||
return float2((vertexID << 1) & 2, vertexID & 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
float4 GetFullScreenTriangleVertexPosition(uint vertexID, float z = UNITY_NEAR_CLIP_VALUE)
|
||||
{
|
||||
// note: the triangle vertex position coordinates are x2 so the returned UV coordinates are in range -1, 1 on the screen.
|
||||
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
|
||||
float4 pos = float4(uv * 2.0 - 1.0, z, 1.0);
|
||||
return pos;
|
||||
}
|
||||
|
||||
Varyings vert(uint vertexID: SV_VertexID)
|
||||
{
|
||||
Varyings o;
|
||||
o.vertex = GetFullScreenTriangleVertexPosition(vertexID);
|
||||
o.uv = GetFullScreenTriangleTexCoord(vertexID);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static const float RCAS_LIMIT = (0.25-(1.0/16.0));
|
||||
|
||||
fixed4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
|
||||
float con = exp2(-_Sharpness);
|
||||
// Perform RCAS pass
|
||||
// Algorithm uses minimal 3x3 pixel neighborhood.
|
||||
// b
|
||||
// d e f
|
||||
// h
|
||||
float2 uv = i.uv;
|
||||
float3 b = _InputTexture.SampleLevel( sampler_LinearClamp, uv + float2(0, -1) , _BlitMipLevel).rgb;
|
||||
float3 d = _InputTexture.SampleLevel( sampler_LinearClamp, uv + float2(-1, 0) , _BlitMipLevel).rgb;
|
||||
float3 e = _InputTexture.SampleLevel( sampler_LinearClamp, uv, _BlitMipLevel).rgb;
|
||||
float3 f = _InputTexture.SampleLevel( sampler_LinearClamp, uv + float2(1, 0) , _BlitMipLevel).rgb;
|
||||
float3 h = _InputTexture.SampleLevel( sampler_LinearClamp, uv + float2(0, 1), _BlitMipLevel).rgb;
|
||||
// Luma times 2.
|
||||
float bL = b.g + 0.5 * (b.b + b.r);
|
||||
float dL = d.g + 0.5 * (d.b + d.r);
|
||||
float eL = e.g + 0.5 * (e.b + e.r);
|
||||
float fL = f.g + 0.5 * (f.b + f.r);
|
||||
float hL = h.g + 0.5 * (h.b + h.r);
|
||||
// Noise detection.
|
||||
float nz = 0.25 * (bL + dL + fL + hL) - eL;
|
||||
nz = clamp(
|
||||
abs(nz)
|
||||
/(
|
||||
max(max(bL,dL),max(eL,max(fL,hL)))
|
||||
-min(min(bL,dL),min(eL,min(fL,hL)))
|
||||
),
|
||||
0.0, 1.0
|
||||
);
|
||||
nz= 1.0 - 0.5 * nz;
|
||||
// Min and max of ring.
|
||||
float3 mn4 = min(b, min(d, min(f, h)));
|
||||
float3 mx4 = max(b, max(d, max(f, h)));
|
||||
// Immediate constants for peak range.
|
||||
float2 peakC = float2(1.0, -4.0);
|
||||
// Limiters, these need to be high precision RCPs.
|
||||
float3 hitMin = min(mn4,e) / (4.0 * mx4);
|
||||
float3 hitMax = (peakC.x - max(mx4,e)) / (4.0 * mn4 + peakC.y);
|
||||
float3 lobeRGB = max(-hitMin, hitMax);
|
||||
float lobe = max(-RCAS_LIMIT,min(max(lobeRGB.r, max(lobeRGB.g, lobeRGB.b)), 0.0)) * con;
|
||||
// Apply noise removal.
|
||||
|
||||
#ifdef FSR_RCAS_DENOISE
|
||||
lobe *+ nz;
|
||||
#endif
|
||||
|
||||
// Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes.
|
||||
float3 col = (lobe * (b + d + h + f) + e) / (4.0 * lobe + 1.0);
|
||||
return half4(col, 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54220985e7800454393f9c15af20fdc6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,14 +1,14 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.burst": {
|
||||
"version": "1.8.17",
|
||||
"version": "1.8.18",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.mathematics": "1.2.1",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.cinemachine": {
|
||||
"version": "2.10.1",
|
||||
@ -17,28 +17,28 @@
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.31"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "2.5.2",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.editorcoroutines": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.31",
|
||||
@ -47,7 +47,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.22",
|
||||
@ -56,14 +56,14 @@
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.inputsystem": {
|
||||
"version": "1.11.0",
|
||||
@ -72,7 +72,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.modules.uielements": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.learn.iet-framework": {
|
||||
"version": "3.1.3",
|
||||
@ -82,14 +82,14 @@
|
||||
"com.unity.editorcoroutines": "1.0.0",
|
||||
"com.unity.settings-manager": "1.0.3"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.mathematics": {
|
||||
"version": "1.2.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.memoryprofiler": {
|
||||
"version": "1.1.1",
|
||||
@ -98,7 +98,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.editorcoroutines": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.recorder": {
|
||||
"version": "4.0.3",
|
||||
@ -107,7 +107,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.timeline": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.render-pipelines.core": {
|
||||
"version": "14.0.11",
|
||||
@ -145,14 +145,14 @@
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.settings-manager": {
|
||||
"version": "2.0.1",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.shadergraph": {
|
||||
"version": "14.0.11",
|
||||
@ -172,7 +172,7 @@
|
||||
"com.unity.mathematics": "1.2.1",
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.33",
|
||||
@ -183,7 +183,7 @@
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.textmeshpro": {
|
||||
"version": "3.0.7",
|
||||
@ -192,7 +192,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.7.6",
|
||||
@ -204,7 +204,7 @@
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.tuanjie.cn"
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
@ -237,10 +237,7 @@
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0"
|
||||
}
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.audio": {
|
||||
"version": "1.0.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user