Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoC-unity authored and 0lento committed Jun 16, 2020
1 parent 6f1dd8f commit 88e41b8
Show file tree
Hide file tree
Showing 24 changed files with 1,069 additions and 166 deletions.
39 changes: 37 additions & 2 deletions com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,13 @@ void ToggleBit(inout uint data, uint offset)

TEMPLATE_3_REAL(Avg3, a, b, c, return (a + b + c) * 0.33333333)

// Important! Quad functions only valid in pixel shaders!
float2 GetQuadOffset(int2 screenPos)
{
return float2(float(screenPos.x & 1) * 2.0 - 1.0, float(screenPos.y & 1) * 2.0 - 1.0);
}

#ifndef INTRINSIC_QUAD_SHUFFLE
// Important! Only valid in pixel shaders!
float QuadReadAcrossX(float value, int2 screenPos)
{
return value - (ddx_fine(value) * (float(screenPos.x & 1) * 2.0 - 1.0));
Expand All @@ -310,12 +315,42 @@ TEMPLATE_3_REAL(Avg3, a, b, c, return (a + b + c) * 0.33333333)
{
float dX = ddx_fine(value);
float dY = ddy_fine(value);
float2 quadDir = float2(float(screenPos.x & 1) * 2.0 - 1.0, float(screenPos.y & 1) * 2.0 - 1.0);
float2 quadDir = GetQuadOffset(screenPos);
float X = value - (dX * quadDir.x);
return X - (ddy_fine(value) * quadDir.y);
}
#endif

float3 QuadReadFloat3AcrossX(float3 val, int2 positionSS)
{
return float3(QuadReadAcrossX(val.x, positionSS), QuadReadAcrossX(val.y, positionSS), QuadReadAcrossX(val.z, positionSS));
}

float4 QuadReadFloat4AcrossX(float4 val, int2 positionSS)
{
return float4(QuadReadAcrossX(val.x, positionSS), QuadReadAcrossX(val.y, positionSS), QuadReadAcrossX(val.z, positionSS), QuadReadAcrossX(val.w, positionSS));
}

float3 QuadReadFloat3AcrossY(float3 val, int2 positionSS)
{
return float3(QuadReadAcrossY(val.x, positionSS), QuadReadAcrossY(val.y, positionSS), QuadReadAcrossY(val.z, positionSS));
}

float4 QuadReadFloat4AcrossY(float4 val, int2 positionSS)
{
return float4(QuadReadAcrossY(val.x, positionSS), QuadReadAcrossY(val.y, positionSS), QuadReadAcrossY(val.z, positionSS), QuadReadAcrossY(val.w, positionSS));
}

float3 QuadReadFloat3AcrossDiagonal(float3 val, int2 positionSS)
{
return float3(QuadReadAcrossDiagonal(val.x, positionSS), QuadReadAcrossDiagonal(val.y, positionSS), QuadReadAcrossDiagonal(val.z, positionSS));
}

float4 QuadReadFloat4AcrossDiagonal(float4 val, int2 positionSS)
{
return float4(QuadReadAcrossDiagonal(val.x, positionSS), QuadReadAcrossDiagonal(val.y, positionSS), QuadReadAcrossDiagonal(val.z, positionSS), QuadReadAcrossDiagonal(val.w, positionSS));
}

TEMPLATE_SWAP(Swap) // Define a Swap(a, b) function for all types

#define CUBEMAPFACE_POSITIVE_X 0
Expand Down
8 changes: 8 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Version Updated
The version number for this package has increased due to a version update of a related graphics package.

### Fixed
- Fix erroneous central depth sampling in TAA.
- Small adjustments to TAA anti flicker (more aggressive on high values).
- Fixed taaFrameIndex
- Slightly changed the TAA anti-flicker mechanism so that it is more aggressive on almost static images (only on High preset for now).
- Temporal Anti aliasing improvements.


## [7.4.0] - 2020-05-22

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ The HDRP Camera shares many properties with the [Standard Unity Camera](https://
| **Clipping Planes** | Set the distances from the Camera at which Unity uses it to start and stop rendering GameObjects.<br />&#8226; **Near**: The distance from the Camera at which Unity begins to use it to draw GameObjects. The Camera does not render anything that is closer to it than this distance.<br />&#8226; **Far**: The distance from the Camera at which Unity ceases to use it to draw GameObjects. The Camera does not render anything that is further away from it than this distance. |
| **Anti-aliasing** | Use the drop-down to select the method that this Camera uses for post-process anti-aliasing. A Camera can still use [multisample anti-aliasing (MSAA)](Anti-Aliasing.html#MSAA), which is a hardware feature, at the same time as post-process anti-aliasing. To control post-process anti-aliasing, use the [Frame Settings](Frame-Settings.html).<br />&#8226; **No Anti-aliasing**: This Camera can process MSAA but does not process any post-process anti-aliasing. <br/>&#8226; **Fast Approximate Anti-aliasing (FXAA)**: Smooths edges on a per-pixel level. This is the least resource intensive anti-aliasing technique in HDRP.<br />&#8226; **Temporal Anti-aliasing (TAA)**: Uses frames from a history buffer to smooth edges more effectively than fast approximate anti-aliasing.<br />&#8226; **Subpixel Morphological Anti-aliasing (SMAA)**: Finds patterns in borders of the image and blends the pixels on these borders according to the pattern. |
| **SMAA Quality Preset** | Use the drop-down to select the quality of SMAA. The difference in resource intensity is fairly small between **Low** and **High**.<br />&#8226; **Low**: The lowest SMAA quality. This is the least resource-intensive option.<br />&#8226; **Medium**: A good balance between SMAA quality and resource intensity.<br />&#8226; **High**: The highest SMAA quality. This is the most resource-intensive option.This property only appears when you select **Subpixel Morphological Anti-aliasing (SMAA)** from the **Anti-aliasing** drop-down. |
| **TAA Quality Preset** | The quality level of TAA. Note that, depending on your content, the default settings for higher presets are not guaranteed to produce better results than lower presets. However, the higher the preset, the more options are available to you and thus the more able you are to adapt the anti-aliasing to your content. |
| **- TAA Sharpen Strength** | The intensity of the sharpening filter that Unity applies to the result of TAA. This helps to reduce the potentially soft look that TAA can produce. Be aware that high values can cause ringing issues (dark lines along the edges of geometry). |
| **- TAA History Sharpening** | This strength of the history sharpening effect. When the value is above 0, Unity samples the history buffer with a bicubic filter that sharpens the result of TAA. This helps to produce a sharper image during motion. Be aware that high values can cause ringing issues (dark lines along the edges of geometry).Note that if you set this value to 0, it increases the performance of TAA because Unity simplifies the history buffer sampling. <br/>This property is only visible when **TAA Quality Preset** is set to a value above **Low**. |
| **- TAA Anti-flickering** | The strength of TAA's anti-flickering effort. Increasing this value may reduce some cases of flickering. However, increasing this value also brings the risk of [ghosting](Glossary.md#Ghosting) or [disocclusion](Glossary.md#Disocclusion) artifacts. <br />This property is only visible when **TAA Quality Preset** is set to a value above **Low**. |
| **- TAA Speed rejection** | Controls the threshold at which Unity rejects history buffer contribution for TAA. Increasing this value can help to remove ghosting artifacts because Unity rejects history buffer contribution when a GameObject's current speed and reprojected speed history are very different. While this can be effective in reducing ghosting, it might also reintroduce some aliasing for fast-moving GameObject.<br/>Note that if you set this value to 0, it increases the performance of TAA because Unity does not process speed rejection.<br />This property is only visible when **TAA Quality Preset** is set to **High**. |
| **- TAA Anti-ringing** | Enable this option to reduce the ringing artifacts caused by high history sharpening values. Be aware that enabling this slightly reduces the effect of the history sharpening.<br /> This property is only visible when **TAA Quality Preset** is set to **High**. |
| **Dithering** | Enable the checkbox to apply 8-bit dithering to the final render. This can help reduce banding on wide gradients and low light areas. |
| **Stop NaNs** | Enable the checkbox to make this Camera replace values that are not a number (NaN) with a black pixel. This stops certain effects from breaking, but is a resource-intensive process. Only enable this feature if you experience NaN issues that you can not fix. |
| **Allow Dynamic Resolution** | Enable the checkbox to make this Camera support dynamic resolution for buffers linked to it. |
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,25 @@ static void Drawer_Antialiasing(SerializedHDCamera p, Editor owner)
}
else if(p.antialiasing.intValue == (int)HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing)
{
EditorGUILayout.PropertyField(p.taaQualityLevel, TAAQualityLevelContent);

EditorGUI.indentLevel++;

EditorGUILayout.PropertyField(p.taaSharpenStrength, TAASharpenContent);

if (p.taaQualityLevel.intValue > (int)HDAdditionalCameraData.TAAQualityLevel.Low)
{
EditorGUILayout.PropertyField(p.taaHistorySharpening, TAAHistorySharpening);
EditorGUILayout.PropertyField(p.taaAntiFlicker, TAAAntiFlicker);
}

if(p.taaQualityLevel.intValue == (int)HDAdditionalCameraData.TAAQualityLevel.High)
{
EditorGUILayout.PropertyField(p.taaMotionVectorRejection, TAAMotionVectorRejection);
EditorGUILayout.PropertyField(p.taaAntiRinging, TAAAntiRingingContent);
}

EditorGUI.indentLevel--;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ static partial class HDCameraUI
static readonly GUIContent antialiasingContent = EditorGUIUtility.TrTextContent("Anti-aliasing", "The anti-aliasing method to use.");
static readonly GUIContent SMAAQualityPresetContent = EditorGUIUtility.TrTextContent("SMAA Quality Preset", "The quality preset for SMAA, low has the best performance but worst quality, High has the highest quality but worst performance.");
static readonly GUIContent TAASharpenContent = EditorGUIUtility.TrTextContent("TAA Sharpen Strength", "The intensity of the sharpen filter used to counterbalance the blur introduced by TAA. A high value might create artifacts such as dark lines depending on the frame content.");
static readonly GUIContent TAAHistorySharpening = EditorGUIUtility.TrTextContent("TAA History Sharpening", "Values closer to 0 lead to softer look when movement is detected, but can further reduce aliasing. Values closer to 1 lead to sharper results, with the risk of reintroducing a bit of aliasing.");
static readonly GUIContent TAAAntiFlicker = EditorGUIUtility.TrTextContent("TAA Anti-flickering", "With high values flickering might be reduced, but it can lead to more ghosting or disocclusion artifacts.");
static readonly GUIContent TAAMotionVectorRejection = EditorGUIUtility.TrTextContent("TAA Speed Rejection", "Higher this value, more likely history will be rejected when current and reprojected history motion vector differ by a substantial amount. High values can decrease ghosting but will also reintroduce aliasing on the aforementioned cases.");
static readonly GUIContent TAAQualityLevelContent = EditorGUIUtility.TrTextContent("TAA Quality Preset", "Low quality is fast, but can lead to more ghosting and blurrier output when moving, Medium quality has better ghosting handling and sharper results upon movement, High allows for velocity rejection policy, has better antialiasing and has mechanism to combat ringing for over sharpening the history.");
static readonly GUIContent TAAAntiRingingContent = EditorGUIUtility.TrTextContent("TAA Anti-ringing", "When enabled, ringing artifacts (dark or strangely saturated edges) caused by history sharpening will be improved. This comes at a potential loss of sharpness upon motion.");

static readonly GUIContent ditheringContent = EditorGUIUtility.TrTextContent("Dithering", "Should we apply 8-bit dithering to the final render?");
static readonly GUIContent stopNaNsContent = EditorGUIUtility.TrTextContent("Stop NaNs", "Automatically replaces NaN/Inf in shaders by a black pixel to avoid breaking some effects. This will slightly affect performances and should only be used if you experience NaN issues that you can't fix.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class SerializedHDCamera
public SerializedProperty antialiasing;
public SerializedProperty SMAAQuality;
public SerializedProperty taaSharpenStrength;
public SerializedProperty taaHistorySharpening;
public SerializedProperty taaAntiFlicker;
public SerializedProperty taaMotionVectorRejection;
public SerializedProperty taaAntiRinging;
public SerializedProperty taaQualityLevel;

public SerializedProperty dithering;
public SerializedProperty stopNaNs;
public SerializedProperty clearColorMode;
Expand Down Expand Up @@ -67,6 +73,13 @@ public SerializedHDCamera(SerializedObject serializedObject)
antialiasing = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.antialiasing);
SMAAQuality = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.SMAAQuality);
taaSharpenStrength = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.taaSharpenStrength);
taaQualityLevel = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.TAAQuality);
taaHistorySharpening = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.taaHistorySharpening);
taaAntiFlicker = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.taaAntiFlicker);
taaMotionVectorRejection = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.taaMotionVectorRejection);
taaAntiRinging = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.taaAntiHistoryRinging);
taaQualityLevel = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.TAAQuality);

dithering = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.dithering);
stopNaNs = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.stopNaNs);
clearColorMode = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.clearColorMode);
Expand Down

0 comments on commit 88e41b8

Please sign in to comment.