xess add antighost

This commit is contained in:
StarBeats 2024-12-26 15:09:43 +08:00
parent f8df0f0005
commit cc3a42a7a1
30 changed files with 135 additions and 134 deletions

View File

@ -25,7 +25,7 @@ public class Test : MonoBehaviour
private void Update()
{
transform?.Rotate(new Vector3(0, 0.5f, 0));
transform?.Rotate(new Vector3(0, 0.1f, 0));
}
private void OnGUI()

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: Xnwd4ymoVn5T21JNkRdz/wbaTps3w3Z40N+XT4ognLZgPi/O+54tq4M=
guid: a8f562490b8d41b47a6b21e2f514d782
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -28,7 +28,7 @@ MonoBehaviour:
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 0.75
m_RenderScale: 0.3335938
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 1
m_FsrSharpness: 1
@ -114,5 +114,5 @@ MonoBehaviour:
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0
superResolution: 12
superResolution: 16
vrsRate: 0

View File

@ -102,7 +102,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f5759a0bb27e83b4ab2925ac09c35710, type: 3}
m_Name: DLSS
m_EditorClassIdentifier:
m_Active: 1
m_Active: 0
quality: 1
useOptimalSetting: 1
sharpness: 0.126
@ -318,25 +318,26 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b1643a5e9ea49724e8a7bc2c6f3713e1, type: 3}
m_Name: XESS
m_EditorClassIdentifier:
m_Active: 0
m_Active: 1
xess1ConfigParam:
OutputWidth: 0
OutputHeight: 0
Quality: 0
OutputWidth: 2560
OutputHeight: 1440
Quality: 103
UseHiResMotionVectors: 0
UseJitteredMotionVectors: 0
UseMotionVectorsInNDC: 0
UseMotionVectorsInNDC: 1
UseExposureTexture: 0
UseResponsiveMask: 0
UseAutoExposure: 0
EnableProfiling: 0
InvertedDepth: 0
VelocityScaleX: 0
VelocityScaleY: 0
JitterScaleX: 0
JitterScaleY: 0
ExposureScale: 0
MipMapBias: 0
InvertedDepth: 1
VelocityScaleX: 1
VelocityScaleY: 1
JitterScaleX: 1
JitterScaleY: 1
ExposureScale: 1
MipMapBias: -2.13
antiGhosting: 0.385
--- !u!114 &6334271670068977784
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -1,27 +0,0 @@
fileFormatVersion: 2
guid: aa3cdfd7567ede4499cc98b29a53314c
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -1,62 +1,62 @@
// Unity Native Plugin API copyright © 2015 Unity Technologies ApS
//
// Licensed under the Unity Companion License for Unity - dependent projects--see[Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
//
// Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.Please review the license for details on these and other terms and conditions.
#pragma once
#include "IUnityInterface.h"
// Has to match the GfxDeviceRenderer enum
typedef enum UnityGfxRenderer
{
//kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed
//kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
kUnityGfxRendererD3D11 = 2, // Direct3D 11
kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
//kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0, removed
kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
//kUnityGfxRendererGXM = 12, // PlayStation Vita, removed
kUnityGfxRendererPS4 = 13, // PlayStation 4
kUnityGfxRendererXboxOne = 14, // Xbox One
kUnityGfxRendererMetal = 16, // iOS Metal
kUnityGfxRendererOpenGLCore = 17, // OpenGL core
kUnityGfxRendererD3D12 = 18, // Direct3D 12
kUnityGfxRendererVulkan = 21, // Vulkan
kUnityGfxRendererNvn = 22, // Nintendo Switch NVN API
kUnityGfxRendererXboxOneD3D12 = 23, // MS XboxOne Direct3D 12
kUnityGfxRendererGameCoreXboxOne = 24, // GameCore Xbox One
kUnityGfxRendererGameCoreXboxSeries = 25, // GameCore XboxSeries
kUnityGfxRendererPS5 = 26, // PS5
kUnityGfxRendererPS5NGGC = 27 // PS5 NGGC
} UnityGfxRenderer;
typedef enum UnityGfxDeviceEventType
{
kUnityGfxDeviceEventInitialize = 0,
kUnityGfxDeviceEventShutdown = 1,
kUnityGfxDeviceEventBeforeReset = 2,
kUnityGfxDeviceEventAfterReset = 3,
} UnityGfxDeviceEventType;
typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType);
// Should only be used on the rendering thread unless noted otherwise.
UNITY_DECLARE_INTERFACE(IUnityGraphics)
{
UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe
// This callback will be called when graphics device is created, destroyed, reset, etc.
// It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time,
// when the graphics device is already created.
void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
int(UNITY_INTERFACE_API * ReserveEventIDRange)(int count); // reserves 'count' event IDs. Plugins should use the result as a base index when issuing events back and forth to avoid event id clashes.
};
UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics)
// Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins.
// Provide them with an address to a function of this signature.
typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId);
typedef void (UNITY_INTERFACE_API * UnityRenderingEventAndData)(int eventId, void* data);
// Unity Native Plugin API copyright © 2015 Unity Technologies ApS
//
// Licensed under the Unity Companion License for Unity - dependent projects--see[Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
//
// Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.Please review the license for details on these and other terms and conditions.
#pragma once
#include "IUnityInterface.h"
// Has to match the GfxDeviceRenderer enum
typedef enum UnityGfxRenderer
{
//kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed
//kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
kUnityGfxRendererD3D11 = 2, // Direct3D 11
kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
//kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0, removed
kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
//kUnityGfxRendererGXM = 12, // PlayStation Vita, removed
kUnityGfxRendererPS4 = 13, // PlayStation 4
kUnityGfxRendererXboxOne = 14, // Xbox One
kUnityGfxRendererMetal = 16, // iOS Metal
kUnityGfxRendererOpenGLCore = 17, // OpenGL core
kUnityGfxRendererD3D12 = 18, // Direct3D 12
kUnityGfxRendererVulkan = 21, // Vulkan
kUnityGfxRendererNvn = 22, // Nintendo Switch NVN API
kUnityGfxRendererXboxOneD3D12 = 23, // MS XboxOne Direct3D 12
kUnityGfxRendererGameCoreXboxOne = 24, // GameCore Xbox One
kUnityGfxRendererGameCoreXboxSeries = 25, // GameCore XboxSeries
kUnityGfxRendererPS5 = 26, // PS5
kUnityGfxRendererPS5NGGC = 27 // PS5 NGGC
} UnityGfxRenderer;
typedef enum UnityGfxDeviceEventType
{
kUnityGfxDeviceEventInitialize = 0,
kUnityGfxDeviceEventShutdown = 1,
kUnityGfxDeviceEventBeforeReset = 2,
kUnityGfxDeviceEventAfterReset = 3,
} UnityGfxDeviceEventType;
typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType);
// Should only be used on the rendering thread unless noted otherwise.
UNITY_DECLARE_INTERFACE(IUnityGraphics)
{
UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe
// This callback will be called when graphics device is created, destroyed, reset, etc.
// It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time,
// when the graphics device is already created.
void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
int(UNITY_INTERFACE_API * ReserveEventIDRange)(int count); // reserves 'count' event IDs. Plugins should use the result as a base index when issuing events back and forth to avoid event id clashes.
};
UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics)
// Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins.
// Provide them with an address to a function of this signature.
typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId);
typedef void (UNITY_INTERFACE_API * UnityRenderingEventAndData)(int eventId, void* data);

View File

@ -1,21 +1,21 @@
#import "UnityAppController.h"
#include "IUnityGraphics.h"
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces);
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginUnload();
@interface MyAppController : UnityAppController
{
}
- (void)shouldAttachRenderDelegate;
@end
@implementation MyAppController
- (void)shouldAttachRenderDelegate
{
// unlike desktops where plugin dynamic library is automatically loaded and registered
// we need to do that manually on iOS
UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
@end
IMPL_APP_CONTROLLER_SUBCLASS(MyAppController);
#import "UnityAppController.h"
#include "IUnityGraphics.h"
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces);
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginUnload();
@interface MyAppController : UnityAppController
{
}
- (void)shouldAttachRenderDelegate;
@end
@implementation MyAppController
- (void)shouldAttachRenderDelegate
{
// unlike desktops where plugin dynamic library is automatically loaded and registered
// we need to do that manually on iOS
UnityRegisterRenderingPluginV5(&UnityPluginLoad, &UnityPluginUnload);
}
@end
IMPL_APP_CONTROLLER_SUBCLASS(MyAppController);

View File

@ -48,11 +48,11 @@ namespace X.Rendering.Feature
public float JitterScaleY;
public float ExposureScale;
[Range(-5,5)]
public float MipMapBias;
};
[StructLayout(LayoutKind.Sequential)]
unsafe struct Xess1ExecParam
{
@ -73,7 +73,12 @@ namespace X.Rendering.Feature
[SerializeField]
Xess1ConfigParam xess1ConfigParam;
[Range(-5, 5)]
public float MipMapBias;
[Range(0, 1)]
public float antiGhosting;
private bool needTurnOnXess = false;
private bool needTurnOffXess = false;
IntPtr xess1ExecParamPtr;
@ -153,8 +158,9 @@ namespace X.Rendering.Feature
}
SuperResolutionParamSets.Instance.Set<bool>("NeedJitter", true);
SuperResolutionParamSets.Instance.Set<float>("MipmapBias", xess1ConfigParam.MipMapBias);
SuperResolutionParamSets.Instance.Set<float>("MipmapBias", MipMapBias);
SuperResolutionParamSets.Instance.Set<float>("JitterScale", xess1ConfigParam.JitterScaleX);
SuperResolutionParamSets.Instance.Set<float>("AntiGhosting", antiGhosting);
var jitter = TemporalAA.CurrentJitter;

View File

@ -341,7 +341,17 @@ namespace UnityEngine.Rendering.Universal
// instability in Unity's shadow maps, so we avoid index 0.
float jitterX = HaltonSequence.Get((frameIndex & 1023) + 1, 2) - 0.5f;
float jitterY = HaltonSequence.Get((frameIndex & 1023) + 1, 3) - 0.5f;
float antiGhosting = 0;
SuperResolutionParamSets.Instance.Get<float>("AntiGhosting", ref antiGhosting);
if (antiGhosting > 0.0f)
{
jitterX += Random.Range(-0.1f * antiGhosting, 0.1f * antiGhosting);
jitterY += Random.Range(-0.1f * antiGhosting, 0.1f * antiGhosting);
jitterX = Mathf.Clamp(jitterX, -0.5f, 0.5f);
jitterY = Mathf.Clamp(jitterY, -0.5f, 0.5f);
}
return new Vector2(jitterX, jitterY);
}

View File

@ -15,10 +15,10 @@ EditorUserSettings:
value: 5b00515154055e035459547042705a44154f1e2c2e2e7f677e7d4567e1b9376d
flags: 0
RecentlyUsedSceneGuid-3:
value: 57050d5004060d590f56087046700f4445164c7e7a7824312e7c4e6bb0e1376d
value: 5a57555407545f0b5e0f5f764277594914161e2b787977692b714e64e4b2363b
flags: 0
RecentlyUsedSceneGuid-4:
value: 5a57555407545f0b5e0f5f764277594914161e2b787977692b714e64e4b2363b
value: 57050d5004060d590f56087046700f4445164c7e7a7824312e7c4e6bb0e1376d
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650