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
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fixed potentially conflicting runtime Rendering Debugger UI command by adding an option to disable runtime UI altogether (1345783).
- Fixed issue when changing volume profiles at runtime with a script (case 1364256).
- Fixed XR support in CoreUtils.DrawFullscreen function.
- Fixed an issue causing Render Graph execution errors after a random amount of time.

## [10.7.0] - 2021-07-02

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ void OnGUI()
//GUILayout.Button(k_LoadButtonContent, EditorStyles.toolbarButton);
//GUILayout.Button(k_SaveButtonContent, EditorStyles.toolbarButton);
if (GUILayout.Button(k_ResetButtonContent, EditorStyles.toolbarButton))
{
DebugManager.instance.Reset();
DestroyWidgetStates();
UpdateWidgetStates();
}

GUILayout.EndHorizontal();

using (new EditorGUILayout.HorizontalScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void RefreshEffectListEditor(VolumeProfile asset)
{
m_ComponentList.Clear();

asset.Sanitize();
asset?.Sanitize();

if (asset != null)
m_ComponentList.Init(asset, new SerializedObject(asset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ public bool IsValid()

static public void NewFrame(int executionIndex)
{
uint previousValidBit = s_CurrentValidBit;
// Scramble frame count to avoid collision when wrapping around.
s_CurrentValidBit = (uint)(((executionIndex >> 16) ^ (executionIndex & 0xffff) * 58546883) << 16);
// In case the current valid bit is 0, even though perfectly valid, 0 represents an invalid handle, hence we'll
// trigger an invalid state incorrectly. To account for this, we actually skip 0 as a viable s_CurrentValidBit and
// start from 1 again.
if (s_CurrentValidBit == 0)
{
s_CurrentValidBit = 1 << 16;
// We need to make sure we don't pick the same value twice.
uint value = 1;
while (previousValidBit == (value << 16))
value++;
s_CurrentValidBit = (value << 16);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static bool enabled
/// <returns>Enumeration of actions</returns>
public static IEnumerator<Action<RenderTargetIdentifier, CommandBuffer>> GetCaptureActions(Camera camera)
{
if (!actionDict.TryGetValue(camera, out var actions))
if (!actionDict.TryGetValue(camera, out var actions) || actions.Count == 0)
return null;

return actions.GetEnumerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ public static void DrawFullScreen(CommandBuffer commandBuffer, Material material
RenderTargetIdentifier colorBuffer,
MaterialPropertyBlock properties = null, int shaderPassId = 0)
{
commandBuffer.SetRenderTarget(colorBuffer);
commandBuffer.SetRenderTarget(colorBuffer, 0, CubemapFace.Unknown, -1);
commandBuffer.DrawProcedural(Matrix4x4.identity, material, shaderPassId, MeshTopology.Triangles, 3, 1, properties);
}

Expand Down
13 changes: 13 additions & 0 deletions com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,19 @@ public override int GetHashCode()
}
}

/// <summary>
/// Returns true if any of the volume properites has been overridden.
/// </summary>
/// <returns>True if any of the volume properites has been overridden.</returns>
public bool AnyPropertiesIsOverridden()
{
for (int i = 0; i < parameters.Count; ++i)
{
if (parameters[i].overrideState) return true;
}
return false;
}

/// <summary>
/// Unity calls this method before the object is destroyed.
/// </summary>
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 @@ -20,6 +20,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed light unit conversion after changing mid gray value.
- Fixed stencil buffer resolve when MSAA is enabled so that OR operator is used instead of picking the last sample.
- Fixed MaterialReimporter.ReimportAllMaterials and MaterialReimporter.ReimportAllHDShaderGraphs now batch the asset database changes.
- Fixed light mode not available after switching a light to area "Disc" or "Tube" (case 1372588).
- Fixed CoC size computation when dynamic resolution is enabled
- Fixed shadow cascade transition not working properly with bias.
- Fixed screen space shadow debug view not showing when no shadows is available.
- Fixed debug window reset.
- Fixed camera bridge action in release build (case 1367866).
- Fixed contact shadow disappearing when shadowmask is used and no non-static object is available.
- Fixed atmospheric scattering being incorrectly enabled when scene lighting is disabled.

## [10.7.0] - 2021-07-02

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ The default values in either mode make it so the planet's surface is at **0** on

* If not in **Spherical Mode**, decrease the **Sea Level**.

## Warmup cost

This sky type requires heavy precomputation to be rendered. Because of this, the first few frames (depending on the *Number of bounces* parameter) are going to take much longer. This needs to be taken into consideration when switching from another sky type to the Physically Based Sky for example as it might produce a noticeable drop in framerate.

### Reference list

* Bruneton, Eric, and Fabrice Neyret. 2008. “Precomputed Atmospheric Scattering.” *Computer Graphics Forum* 27, no. 4 (2008): 1079–86. https://doi.org/10.1111/j.1467-8659.2008.01245.x.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static void DrawGeneralContent(SerializedHDLight serialized, Editor owner)
EditorGUI.showMixedValue = false;

// Draw the mode, for Tube and Disc lights, there is only one choice, so we can disable the enum.
using (new EditorGUI.DisabledScope(serialized.areaLightShape == AreaLightShape.Tube || serialized.areaLightShape == AreaLightShape.Disc))
using (new EditorGUI.DisabledScope(updatedLightType == HDLightType.Area && (serialized.areaLightShape == AreaLightShape.Tube || serialized.areaLightShape == AreaLightShape.Disc)))
serialized.settings.DrawLightmapping();

if (updatedLightType == HDLightType.Area)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void EvaluateAtmosphericScattering(PositionInputs posInput, float3 V, out float3

#ifdef DEBUG_DISPLAY
// Don't sample atmospheric scattering when lighting debug more are enabled so fog is not visible
if (_DebugLightingMode >= DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING && _DebugLightingMode <= DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING)
if (_DebugLightingMode == DEBUGLIGHTINGMODE_MATCAP_VIEW || (_DebugLightingMode >= DEBUGLIGHTINGMODE_DIFFUSE_LIGHTING && _DebugLightingMode <= DEBUGLIGHTINGMODE_EMISSIVE_LIGHTING))
return;

if (_DebugShadowMapMode == SHADOWMAPDEBUGMODE_SINGLE_SHADOW || _DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER || _DebugLightingMode == DEBUGLIGHTINGMODE_LUMINANCE_METER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ struct DirectionalLightData
public float distanceFromCamera; // -1 -> no sky interaction
public float angularDiameter; // Units: radians
public float flareFalloff;
public float __unused__;

public float flareCosInner;
public float flareCosOuter;
public float __unused__;

public Vector3 flareTint;
public float flareSize; // Units: radians
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ struct DirectionalLightData
float distanceFromCamera;
float angularDiameter;
float flareFalloff;
float flareCosInner;
float flareCosOuter;
float __unused__;
float3 flareTint;
float flareSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ float4 EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInpu
// Height fog attenuation.
{
// TODO: should probably unify height attenuation somehow...
float cosZenithAngle = L.y;
float cosZenithAngle = max(L.y, 0.001f);
float fragmentHeight = posInput.positionWS.y;
float3 oDepth = OpticalDepthHeightFog(_HeightFogBaseExtinction, _HeightFogBaseHeight,
_HeightFogExponents, cosZenithAngle, fragmentHeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,12 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi
lightData.angularDiameter = additionalLightData.angularDiameter * Mathf.Deg2Rad;
lightData.flareSize = Mathf.Max(additionalLightData.flareSize * Mathf.Deg2Rad, 5.960464478e-8f);
lightData.flareFalloff = additionalLightData.flareFalloff;

// On some vendors trigonometry has very bad precision, so we precompute what we can on CPU to avoid precision issues (case 1369376).
float radInner = 0.5f * lightData.angularDiameter;
lightData.flareCosInner = Mathf.Cos(radInner);
lightData.flareCosOuter = Mathf.Cos(radInner + lightData.flareSize);

lightData.flareTint = (Vector3)(Vector4)additionalLightData.flareTint;
lightData.surfaceTint = (Vector3)(Vector4)additionalLightData.surfaceTint;

Expand Down Expand Up @@ -3793,7 +3799,8 @@ void GetContactShadowMask(HDAdditionalLightData hdAdditionalLightData, BoolScala
return;

// Evaluate the contact shadow index of this light
contactShadowMask = 1 << m_ContactShadowIndex++;
contactShadowMask = 1 << m_ContactShadowIndex;
m_ContactShadowIndex++; // Update the index for next light that will need to cast contact shadows.

// If this light has ray traced contact shadow
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && hdAdditionalLightData.rayTraceContactShadow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId
// Do the contact shadow for the directional light
if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
{
if (_DirectionalShadowIndex >= 0)
for (uint i = 0; i < _DirectionalLightCount; ++i)
{
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
DirectionalLightData light = _DirectionalLightDatas[i];

if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 0.0)
{
Expand All @@ -214,6 +214,7 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId
// we take full bits at one multiplied by contact shadow and filter the bit at the contact shadow index.
contactShadowMask |= light.contactShadowMask * occluded;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,16 @@ float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, T
float shadow = 1.0;
shadowSplitIndex = EvalShadow_GetSplitIndex(shadowContext, index, positionWS, alpha, cascadeCount);

float3 basePositionWS = positionWS;

if (shadowSplitIndex >= 0.0)
{
HDShadowData sd = shadowContext.shadowDatas[index];
LoadDirectionalShadowDatas(sd, shadowContext, index + shadowSplitIndex);
positionWS = positionWS + sd.cacheTranslationDelta.xyz;
positionWS = basePositionWS + sd.cacheTranslationDelta.xyz;

/* normal based bias */
float worldTexelSize = sd.worldTexelSize;
float3 orig_pos = positionWS;
float3 normalBias = EvalShadow_NormalBias(sd.worldTexelSize, sd.normalBias, normalWS);
positionWS += normalBias;
Expand All @@ -262,8 +265,14 @@ float EvalShadow_CascadedDepth_Blend_SplitIndex(HDShadowContext shadowContext, T
if (alpha > 0.0)
{
LoadDirectionalShadowDatas(sd, shadowContext, index + shadowSplitIndex);

// We need to modify the bias as the world texel size changes between splits and an update is needed.
float biasModifier = (sd.worldTexelSize / worldTexelSize);
normalBias *= biasModifier;

float3 evaluationPosWS = basePositionWS + sd.cacheTranslationDelta.xyz + normalBias;
float3 posNDC;
posTC = EvalShadow_GetTexcoordsAtlas(sd, _CascadeShadowAtlasSize.zw, positionWS, posNDC, false);
posTC = EvalShadow_GetTexcoordsAtlas(sd, _CascadeShadowAtlasSize.zw, evaluationPosWS, posNDC, false);
/* sample the texture */
UNITY_BRANCH
if (all(abs(posNDC.xy) <= (1.0 - sd.shadowMapSize.zw * 0.5)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@ bool RequestedScreenSpaceShadows()
TextureHandle RenderScreenSpaceShadows(RenderGraph renderGraph, HDCamera hdCamera, PrepassOutput prepassOutput, TextureHandle depthBuffer, TextureHandle normalBuffer, TextureHandle motionVectorsBuffer, TextureHandle rayCountTexture)
{
// If screen space shadows are not supported for this camera, we are done
if (!hdCamera.frameSettings.IsEnabled(FrameSettingsField.ScreenSpaceShadows) || !RequestedScreenSpaceShadows())
bool validConditions = hdCamera.frameSettings.IsEnabled(FrameSettingsField.ScreenSpaceShadows) && RequestedScreenSpaceShadows();

if (!validConditions)
{
// We push the debug texture anyway if we are not evaluating any screen space shadows.
PushFullScreenDebugTexture(m_RenderGraph, m_RenderGraph.defaultResources.whiteTextureXR, FullScreenDebugMode.ScreenSpaceShadows);
return m_RenderGraph.defaultResources.blackTextureArrayXR;
}

using (new RenderGraphProfilingScope(renderGraph, ProfilingSampler.Get(HDProfileId.ScreenSpaceShadows)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2600,9 +2600,9 @@ static void DoPhysicallyBasedDepthOfField(in DepthOfFieldParameters dofParameter
// The sensor scale is used to convert the CoC size from mm to screen pixels
float sensorScale;
if (dofParameters.camera.camera.gateFit == Camera.GateFitMode.Horizontal )
sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.x) * dofParameters.camera.camera.pixelWidth;
sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.x) * dofParameters.camera.actualWidth;
else
sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.y) * dofParameters.camera.camera.pixelHeight;
sensorScale = (0.5f / dofParameters.camera.camera.sensorSize.y) * dofParameters.camera.actualHeight;

// "A Lens and Aperture Camera Model for Synthetic Image Generation" [Potmesil81]
// Note: Focus distance is in meters, but focalLength and sensor size are in mm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ public ScreenSpaceReflectionAlgorithm
int m_RecorderTempRT = Shader.PropertyToID("TempRecorder");
MaterialPropertyBlock m_RecorderPropertyBlock = new MaterialPropertyBlock();
Rect? m_OverridePixelRect = null;

internal bool hasCaptureActions => m_RecorderCaptureActions != null;

void SetupCurrentMaterialQuality(CommandBuffer cmd)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,6 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
PushFullScreenDebugTexture(m_RenderGraph, colorBuffer, FullScreenDebugMode.NanTracker);
PushFullScreenLightingDebugTexture(m_RenderGraph, colorBuffer);

if (m_SubFrameManager.isRecording && m_SubFrameManager.subFrameCount > 1)
{
RenderAccumulation(m_RenderGraph, hdCamera, colorBuffer, colorBuffer, false);
}

// Render gizmos that should be affected by post processes
RenderGizmos(m_RenderGraph, hdCamera, colorBuffer, GizmoSubset.PreImageEffects);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ static class HDShaderIDs
public static readonly int _SpaceEmissionMultiplier = Shader.PropertyToID("_SpaceEmissionMultiplier");

public static readonly int _RenderSunDisk = Shader.PropertyToID("_RenderSunDisk");
public static readonly int _SunDiskCosines = Shader.PropertyToID("_SunDiskCosines");

public static readonly int _ColorSaturation = Shader.PropertyToID("_ColorSaturation");
public static readonly int _AlphaSaturation = Shader.PropertyToID("_AlphaSaturation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ void RayGenContactShadows()
uint contactShadowMask = 0;
UnpackContactShadowData(_ContactShadowTextureUAV[COORD_TEXTURE2D_X(pixelCoord)], fade, contactShadowMask);

// Let's first process the directional shadow
if (_DirectionalShadowIndex >= 0)
for (int i = 0; i < _DirectionalLightCount; ++i)
{
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
DirectionalLightData light = _DirectionalLightDatas[i];

if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 1.0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ internal static bool PostProcessIsFinalPass(HDCamera hdCamera)
// Post process pass is the final blit only when not in developer mode.
// In developer mode, we support a range of debug rendering that needs to occur after post processes.
// In order to simplify writing them, we don't Y-flip in the post process pass but add a final blit at the end of the frame.
return !Debug.isDebugBuild && !WillCustomPassBeExecuted(hdCamera, CustomPassInjectionPoint.AfterPostProcess);
return !Debug.isDebugBuild && !WillCustomPassBeExecuted(hdCamera, CustomPassInjectionPoint.AfterPostProcess) && !hdCamera.hasCaptureActions;
}

// These two convertion functions are used to store GUID assets inside materials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Shader "Hidden/HDRP/Sky/PbrSky"

#pragma vertex Vert

// #pragma enable_d3d11_debug_symbols
#pragma editor_sync_compilation
#pragma target 4.5
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
Expand All @@ -25,13 +26,6 @@ Shader "Hidden/HDRP/Sky/PbrSky"
float _GroundEmissionMultiplier;
float _SpaceEmissionMultiplier;

// Inner and outer cosine computed as:
// float radInner = 0.5 * light.angularDiameter
// float cosInner = cos(radInner); // (In _SunDiskCosines.x)
// float cosOuter = cos(radInner + light.flareSize); // (In _SunDiskCosines.y)
// We need to pass it over instead of computing it here because on some vendors trigonometry has very bad precision, so we precompute what we can on CPU to have better precision.
float4 _SunDiskCosines;

// Sky framework does not set up global shader variables (even per-view ones),
// so they can contain garbage. It's very difficult to not include them, however,
// since the sky framework includes them internally in many header files.
Expand Down Expand Up @@ -118,19 +112,16 @@ Shader "Hidden/HDRP/Sky/PbrSky"
float rad = acos(LdotV);
float radInner = 0.5 * light.angularDiameter;

float cosInner = _SunDiskCosines.x;
float cosOuter = _SunDiskCosines.y;

float solidAngle = TWO_PI * (1 - cosInner);
float solidAngle = TWO_PI * (1 - light.flareCosInner);

if (LdotV >= cosOuter)
if (LdotV >= light.flareCosOuter)
{
// Sun flare is visible. Sun disk may or may not be visible.
// Assume uniform emission.
float3 color = light.color.rgb;
float scale = rcp(solidAngle);

if (LdotV >= cosInner) // Sun disk.
if (LdotV >= light.flareCosInner) // Sun disk.
{
tFrag = lightDist;

Expand Down
Loading