|
|
|
@ -71,6 +71,8 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
} |
|
|
|
|
|
|
|
public Vector2 jitter { get; private set; } |
|
|
|
public Vector2Int renderSize => _renderSize; |
|
|
|
public Vector2Int displaySize => _displaySize; |
|
|
|
|
|
|
|
private Fsr2Context _fsrContext; |
|
|
|
private Vector2Int _renderSize; |
|
|
|
@ -83,6 +85,8 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
private Fsr2.QualityMode _prevQualityMode; |
|
|
|
private Vector2Int _prevDisplaySize; |
|
|
|
|
|
|
|
private Rect _originalRect; |
|
|
|
|
|
|
|
public bool IsSupported() |
|
|
|
{ |
|
|
|
return SystemInfo.supportsComputeShaders && SystemInfo.supportsMotionVectors; |
|
|
|
@ -93,6 +97,11 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
return DepthTextureMode.Depth | DepthTextureMode.MotionVectors; |
|
|
|
} |
|
|
|
|
|
|
|
public void Release() |
|
|
|
{ |
|
|
|
DestroyFsrContext(); |
|
|
|
} |
|
|
|
|
|
|
|
public void ResetHistory() |
|
|
|
{ |
|
|
|
_reset = true; |
|
|
|
@ -103,6 +112,21 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
ApplyJitter(context.camera); |
|
|
|
} |
|
|
|
|
|
|
|
public void ConfigureCameraViewport(PostProcessRenderContext context) |
|
|
|
{ |
|
|
|
var cam = context.camera; |
|
|
|
_displaySize = new Vector2Int(cam.pixelWidth, cam.pixelHeight); // TODO: also support render texture targets properly
|
|
|
|
_originalRect = cam.rect; |
|
|
|
|
|
|
|
cam.aspect = (_displaySize.x * _originalRect.width) / (_displaySize.y * _originalRect.height); |
|
|
|
cam.rect = new Rect(0, 0, _originalRect.width * _renderSize.x / cam.pixelWidth, _originalRect.height * _renderSize.y / cam.pixelHeight); |
|
|
|
} |
|
|
|
|
|
|
|
public void ResetCameraViewport(PostProcessRenderContext context) |
|
|
|
{ |
|
|
|
context.camera.rect = _originalRect; |
|
|
|
} |
|
|
|
|
|
|
|
public void Render(PostProcessRenderContext context) |
|
|
|
{ |
|
|
|
var cmd = context.command; |
|
|
|
@ -143,7 +167,7 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
private void CreateFsrContext(PostProcessRenderContext context) |
|
|
|
{ |
|
|
|
_displaySize = new Vector2Int(context.width, context.height); |
|
|
|
_displaySize = new Vector2Int(context.width, context.height); // TODO: get rid of this
|
|
|
|
|
|
|
|
_prevDisplaySize = _displaySize; |
|
|
|
|
|
|
|
@ -234,11 +258,6 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Release() |
|
|
|
{ |
|
|
|
DestroyFsrContext(); |
|
|
|
} |
|
|
|
|
|
|
|
private class Callbacks : Fsr2CallbacksBase |
|
|
|
{ |
|
|
|
private readonly PostProcessResources _resources; |
|
|
|
|