Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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 @@ -17,7 +17,7 @@ RefractionModelResult RefractionModelSphere(real3 V, float3 positionWS, real3 no
// Sphere shape model:
// We approximate locally the shape of the object as sphere, that is tangent to the shape.
// The sphere has a diameter of {thickness}
// The center of the sphere is at {positionWS} - {normalWS} * {thickness}
// The center of the sphere is at {positionWS} - {normalWS} * {thickness} * 0.5
//
// So the light is refracted twice: in and out of the tangent sphere

Expand Down
7 changes: 6 additions & 1 deletion com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added
- Added a fallback for the ray traced directional shadow in case of a transmission (case 1307870).
- Added support for alpha channel in FXAA (case 1323941).
- Added an info box for micro shadow editor (case 1322830).

### Fixed
- Fixed grey screen on playstation platform when histogram exposure is enabled but the curve mapping is not used.
Expand All @@ -33,6 +33,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix potential NaN on apply distortion pass.
- Fixed the camera controller in the template with the old input system (case 1326816).
- Fixed broken Lanczos filter artifacts on ps4, caused by a very aggressive epsilon (case 1328904)
- Fixed Decal's UV edit mode with negative UV
- Fixed issue with the color space of AOVs (case 1324759)
- Fixed issue with history buffers when using multiple AOVs (case 1323684).
- Fixed camera preview with multi selection (case 1324126).

### Changed
- Reduced the maximal number of bounces for both RTGI and RTR (case 1318876).
Expand All @@ -42,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed normal used in path tracing to create a local light list from the geometric to the smooth shading one.
- Assets going through the migration system are now dirtied.
- Disable TAA sharpening on alpha channel.
- Increased path tracing max samples from 4K to 16K (case 1327729).

## [10.4.0] - 2021-03-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This means that, if screen space refraction does not return information for a pi

The first tier of the refraction hierarchy is a screen space solution. To calculate screen space refraction, the algorithm traces a ray starting from the refractive object. It then refracts the ray according to the properties of the material. To compute the refracted ray, the algorithm assumes that the refractive object can be approximated as a simple shape ([Refraction Model](#RefractionModel)) .

The refracted ray will be then intersected against the proxy volume to find the right pixel in screen space that best approximates the result of the refracted ray.
The refracted ray will be then intersected against the closest probe proxy volume to find the pixel in screen space that best approximates the result of the refracted ray. If there is no reflection probe proxy available, HDRP will fallback to a projection at infinite.

<a name="ReflectionProbes"></a>

Expand All @@ -82,15 +82,15 @@ For more information on Reflection Probes, see:
HDRP uses simple shapes to approximate the surface of GameObjects:

- **Sphere**: Approximates the surface as a sphere.
- **Box**: Approximates the surface as an hollow box. In this case think of the thickness as being the distance between two parallel faces of the box.
- **Thin**: Approximated the surface as a box with a fixed thickness of 5cm.
- **Box**: Approximates the surface as a hollow box. In this case think of the thickness as being the distance between two parallel faces of the box.
- **Thin**: Approximates the surface as a hollow box with a fixed thickness of 5cm.

### Examples

- For a filled GameObject, use a **Sphere** Refraction Model with a thickness that is approximately the size of the GameObject that the Material is for. To set the thickness, use the **Refraction Thickness**.
- For a solid GameObject, use the **Sphere** Refraction Model with a thickness that is approximately the size of the GameObject that the Material is for. To set the thickness, use the **Refraction Thickness**.

![](Images/RefractionInHDRP1.png)

- For a hollow refractive GameObject (for example, a bubble), use a **Box** refraction Mode with a small value for thickness. To set the thickness, use the **Refraction Thickness**.
- For a hollow refractive GameObject (for example, a bubble), use the **Thin** refraction Model, or **Box** with a small thickness value. To set the thickness, use the **Refraction Thickness**.

![](Images/RefractionInHDRP2.png)
![](Images/RefractionInHDRP2.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using UnityEngine.Rendering.HighDefinition;

namespace UnityEditor.Rendering.HighDefinition
{
[VolumeComponentEditor(typeof(MicroShadowing))]
sealed class MicroShadowingEditor : VolumeComponentEditor
{
static public readonly string k_DirectionnalWarning = "Micro Shadows only works with directional Lights";

public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.HelpBox(k_DirectionnalWarning, MessageType.Info);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class Styles
{
public static string refractionModelText = "Refraction Model";
public static GUIContent refractionIorText = new GUIContent("Index Of Refraction", "Controls the index of refraction for this Material.");
public static GUIContent refractionThicknessText = new GUIContent("Thickness", "Controls the thickness for rough refraction.");
public static GUIContent refractionThicknessText = new GUIContent("Thickness", "Controls the thickness for rough refraction.\nFor a Sphere model, this is the diameter of the sphere.");
public static GUIContent refractionThicknessMapText = new GUIContent("Thickness Map", "Specifies the Refraction Thickness Map (R) for this Material - This acts as a thickness multiplier map.");
public static GUIContent refractionThicknessRemappingText = new GUIContent("Thickness Remapping", "Controls the maximum thickness for rough refraction.");
public static GUIContent thicknessMapText = new GUIContent("Thickness Map", "Specifies the Thickness Map (R) for this Material - This map describes the thickness of the object. When subsurface scattering is enabled, low values allow some light to transmit through the object.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,32 @@ void OnOverlayGUI(Object target, SceneView sceneView)

Camera InitializePreviewCamera(Camera c, Vector2 previewSize)
{
m_PreviewCamera.CopyFrom(c);
EditorUtility.CopySerialized(c, m_PreviewCamera);
Camera previewCamera = null;
HDAdditionalCameraData previewAdditionalCameraData = null;
for (int i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (serializedObject.targetObjects[i] == c)
{
previewCamera = m_PreviewCameras[i];
previewAdditionalCameraData = m_PreviewAdditionalCameraDatas[i];
break;
}
}

previewCamera.CopyFrom(c);
EditorUtility.CopySerialized(c, previewCamera);
var cameraData = c.GetComponent<HDAdditionalCameraData>();
EditorUtility.CopySerialized(cameraData, m_PreviewAdditionalCameraData);
EditorUtility.CopySerialized(cameraData, previewAdditionalCameraData);
// We need to explicitly reset the camera type here
// It is probably a CameraType.Game, because we copied the source camera's properties.
m_PreviewCamera.cameraType = CameraType.Preview;
m_PreviewCamera.gameObject.SetActive(false);
previewCamera.cameraType = CameraType.Preview;
previewCamera.gameObject.SetActive(false);

var previewTexture = GetPreviewTextureWithSize((int)previewSize.x, (int)previewSize.y);
m_PreviewCamera.targetTexture = previewTexture;
m_PreviewCamera.pixelRect = new Rect(0, 0, previewSize.x, previewSize.y);
previewCamera.targetTexture = previewTexture;
previewCamera.pixelRect = new Rect(0, 0, previewSize.x, previewSize.y);

return m_PreviewCamera;
return previewCamera;
}

static Type k_SceneViewOverlay_WindowFunction = Type.GetType("UnityEditor.SceneViewOverlay+WindowFunction,UnityEditor");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ partial class HDCameraEditor : Editor
SerializedHDCamera m_SerializedCamera;

RenderTexture m_PreviewTexture;
Camera m_PreviewCamera;
HDAdditionalCameraData m_PreviewAdditionalCameraData;
Camera[] m_PreviewCameras;
HDAdditionalCameraData[] m_PreviewAdditionalCameraDatas;

void OnEnable()
{
m_SerializedCamera = new SerializedHDCamera(serializedObject);

m_PreviewCamera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent<Camera>();
m_PreviewCamera.enabled = false;
m_PreviewCamera.cameraType = CameraType.Preview; // Must be init before adding HDAdditionalCameraData
m_PreviewAdditionalCameraData = m_PreviewCamera.gameObject.AddComponent<HDAdditionalCameraData>();
// Say that we are a camera editor preview and not just a regular preview
m_PreviewAdditionalCameraData.isEditorCameraPreview = true;
var targetCount = serializedObject.targetObjects.Length;
m_PreviewCameras = new Camera[targetCount];
m_PreviewAdditionalCameraDatas = new HDAdditionalCameraData[targetCount];
for (int i = 0; i < targetCount; i++)
{
m_PreviewCameras[i] = EditorUtility.CreateGameObjectWithHideFlags("Preview " + serializedObject.targetObject.name, HideFlags.HideAndDontSave, typeof(Camera)).GetComponent<Camera>();
m_PreviewCameras[i].enabled = false;
m_PreviewCameras[i].cameraType = CameraType.Preview; // Must be init before adding HDAdditionalCameraData
m_PreviewAdditionalCameraDatas[i] = m_PreviewCameras[i].gameObject.AddComponent<HDAdditionalCameraData>();
// Say that we are a camera editor preview and not just a regular preview
m_PreviewAdditionalCameraDatas[i].isEditorCameraPreview = true;
}
}

void OnDisable()
Expand All @@ -36,8 +42,10 @@ void OnDisable()
m_PreviewTexture.Release();
m_PreviewTexture = null;
}
DestroyImmediate(m_PreviewCamera.gameObject);
m_PreviewCamera = null;
for (int i = 0; i < serializedObject.targetObjects.Length; i++)
DestroyImmediate(m_PreviewCameras[i].gameObject);
m_PreviewCameras = null;
m_PreviewAdditionalCameraDatas = null;
}

public override void OnInspectorGUI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ unsafe struct ShaderVariablesDebugDisplay
public int _DebugSingleShadowIndex;

public int _DebugProbeVolumeMode;
public Vector3 _DebugDisplayPad0;
public int _DebugAOVOutput;
public int _DebugDisplayPad0;
public int _DebugDisplayPad1;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ CBUFFER_START(ShaderVariablesDebugDisplay)
float _MatcapViewScale;
int _DebugSingleShadowIndex;
int _DebugProbeVolumeMode;
float3 _DebugDisplayPad0;
int _DebugAOVOutput;
int _DebugDisplayPad0;
int _DebugDisplayPad1;
CBUFFER_END


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,19 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
if (numColorPyramidBuffersRequired != 0)
{
AllocHistoryFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain, HistoryBufferAllocatorFunction, numColorPyramidBuffersRequired);

// Handle the AOV history buffers
var cameraHistory = GetHistoryRTHandleSystem();
foreach (var aovRequest in aovRequests)
{
var aovHistory = GetHistoryRTHandleSystem(aovRequest);
BindHistoryRTHandleSystem(aovHistory);
AllocHistoryFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain, HistoryBufferAllocatorFunction, numColorPyramidBuffersRequired);
}
BindHistoryRTHandleSystem(cameraHistory);
}


if (numVolumetricBuffersRequired != 0)
{
HDRenderPipeline.CreateVolumetricHistoryBuffers(this, numVolumetricBuffersRequired);
Expand Down Expand Up @@ -604,6 +615,12 @@ internal void SetReferenceSize()
{
RTHandles.SetReferenceSize(actualWidth, actualHeight, msaaSamples);
m_HistoryRTSystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples);

foreach (var aovHistory in m_AOVHistoryRTSystem)
{
var historySystem = aovHistory.Value;
historySystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples);
}
}

// Updating RTHandle needs to be done at the beginning of rendering (not during update of HDCamera which happens in batches)
Expand Down Expand Up @@ -691,6 +708,12 @@ internal static void ResetAllHistoryRTHandleSystems(int width, int height)
if (width < currentHistorySize.x || height < currentHistorySize.y)
{
hdCamera.m_HistoryRTSystem.ResetReferenceSize(width, height);

foreach (var aovHistory in hdCamera.m_AOVHistoryRTSystem)
{
var historySystem = aovHistory.Value;
historySystem.ResetReferenceSize(width, height);
}
}
}
}
Expand Down Expand Up @@ -977,6 +1000,10 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst
int m_NumVolumetricBuffersAllocated = 0;
float m_AmbientOcclusionResolutionScale = 0.0f; // Factor used to track if history should be reallocated for Ambient Occlusion
float m_ScreenSpaceAccumulationResolutionScale = 0.0f; // Use another scale if AO & SSR don't have the same resolution

Dictionary<AOVRequestData, BufferedRTHandleSystem> m_AOVHistoryRTSystem = new Dictionary<AOVRequestData, BufferedRTHandleSystem>(new AOVRequestDataComparer());


/// <summary>
/// Store current algorithm which help to know if we trigger to reset history SSR Buffers.
/// </summary>
Expand Down Expand Up @@ -1426,6 +1453,13 @@ void Dispose()
m_HistoryRTSystem = null;
}

foreach (var aovHistory in m_AOVHistoryRTSystem)
{
var historySystem = aovHistory.Value;
historySystem.Dispose();
}
m_AOVHistoryRTSystem.Clear();

if (lightingSky != null && lightingSky != visualSky)
lightingSky.Cleanup();

Expand All @@ -1447,6 +1481,12 @@ static RTHandle HistoryBufferAllocatorFunction(string viewName, int frameIndex,
void ReleaseHistoryBuffer()
{
m_HistoryRTSystem.ReleaseAll();

foreach (var aovHistory in m_AOVHistoryRTSystem)
{
var historySystem = aovHistory.Value;
historySystem.ReleaseAll();
}
}

Rect GetPixelRect()
Expand All @@ -1456,6 +1496,30 @@ Rect GetPixelRect()
else
return new Rect(camera.pixelRect.x, camera.pixelRect.y, camera.pixelWidth, camera.pixelHeight);
}
internal BufferedRTHandleSystem GetHistoryRTHandleSystem()
{
return m_HistoryRTSystem;
}

internal void BindHistoryRTHandleSystem(BufferedRTHandleSystem historyRTSystem)
{
m_HistoryRTSystem = historyRTSystem;
}

internal BufferedRTHandleSystem GetHistoryRTHandleSystem(AOVRequestData aovRequest)
{
if (m_AOVHistoryRTSystem.TryGetValue(aovRequest, out var aovHistory))
{
return aovHistory;
}
else
{
var newHistory = new BufferedRTHandleSystem();
m_AOVHistoryRTSystem.Add(aovRequest, newHistory);
return newHistory;
}
}

#endregion
}
}
Loading