Skip to content

Commit

Permalink
Merge pull request #8115 from Unity-Technologies/internal/2022.3/staging
Browse files Browse the repository at this point in the history
Internal/2022.3/staging
  • Loading branch information
UnityAljosha authored Dec 18, 2024
2 parents 40a072c + 22ca795 commit c757aae
Show file tree
Hide file tree
Showing 24 changed files with 699 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Custom Material Inspectors enable you to define how Unity displays properties in

The implementation for custom Material Inspectors differs between URP and HDRP. For example, for compatibility purposes, every custom Material Inspector in HDRP must inherit from `HDShaderGUI` which does not exist in URP. For information on how to create custom Material Inspectors for the respective render pipelines, see:

- **HDRP**: [HDRP custom Material Inspectors](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/hdrp-custom-material-inspector.html).
- **HDRP**: [HDRP custom Material Inspectors](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/custom-material-inspectors.html).
- **URP**: [Unity Custom Shader GUI](https://docs.unity3d.com/Manual/SL-CustomShaderGUI.html).

## Assigning a custom Material Inspector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MyRenderPipeline : RenderPipeline

void InitializeRenderGraph()
{
m_RenderGraph = new RenderGraph(MyRenderGraph);
m_RenderGraph = new RenderGraph("MyRenderGraph");
}

void CleanupRenderGraph()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ static private void DrawTriangle(CommandBuffer cmd, Material material, int shade
cmd.DrawMesh(s_TriangleMesh, Matrix4x4.identity, material, 0, shaderPass, s_PropertyBlock);
else
cmd.DrawProcedural(Matrix4x4.identity, material, shaderPass, MeshTopology.Triangles, 3, 1, s_PropertyBlock);
s_PropertyBlock.Clear();
}

static internal void DrawQuad(CommandBuffer cmd, Material material, int shaderPass)
Expand All @@ -199,7 +198,6 @@ static internal void DrawQuad(CommandBuffer cmd, Material material, int shaderPa
cmd.DrawMesh(s_QuadMesh, Matrix4x4.identity, material, 0, shaderPass, s_PropertyBlock);
else
cmd.DrawProcedural(Matrix4x4.identity, material, shaderPass, MeshTopology.Quads, 4, 1, s_PropertyBlock);
s_PropertyBlock.Clear();
}

/// <summary>
Expand Down Expand Up @@ -274,6 +272,7 @@ public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scale
/// <param name="pass">Pass idx within the material to invoke.</param>
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, Vector4 scaleBias, Material material, int pass)
{
s_PropertyBlock.Clear();
s_PropertyBlock.SetVector(BlitShaderIDs._BlitScaleBias, scaleBias);
// Unfortunately there is no function bind a RenderTargetIdentifier with a property block so we have to bind it globally.
cmd.SetGlobalTexture(BlitShaderIDs._BlitTexture, source);
Expand All @@ -290,6 +289,8 @@ public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source,
/// <param name="pass">Pass idx within the material to invoke.</param>
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material, int pass)
{
s_PropertyBlock.Clear();
s_PropertyBlock.SetVector(BlitShaderIDs._BlitScaleBias, Vector2.one);
// Unfortunately there is no function bind a RenderTargetIdentifier with a property block so we have to bind it globally.
cmd.SetGlobalTexture(BlitShaderIDs._BlitTexture, source);
cmd.SetRenderTarget(destination);
Expand All @@ -308,6 +309,8 @@ public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source,
/// <param name="pass">Pass idx within the material to invoke.</param>
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, Material material, int pass)
{
s_PropertyBlock.Clear();
s_PropertyBlock.SetVector(BlitShaderIDs._BlitScaleBias, Vector2.one);
// Unfortunately there is no function bind a RenderTargetIdentifier with a property block so we have to bind it globally.
cmd.SetGlobalTexture(BlitShaderIDs._BlitTexture, source);
cmd.SetRenderTarget(destination, loadAction, storeAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Finally, access the Frame Settings structure itself. This controls the actual va
- **Camera**: `HDAdditionalCameraData.renderingPathCustomFrameSettings`
- **Reflection Probe**: `HDAdditionalReflectionData.frameSettings`

For information on the API available for `FrameSettings`, including how to edit the value of a Frame Setting, see [FrameSettings Scripting API](framesettings-scripting-api).
For information on the API available for `FrameSettings`, including how to edit the value of a Frame Setting, see [FrameSettings Scripting API](#framesettings-scripting-api).

## Frame Setting enumerations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
<td><strong>Shadow Matte</strong></td>
<td></td>
<td></td>
<td>Indicates whether or not the Shader receives shadows. Shadow matte only supports shadow maps. It does not support Screen Space Shadows, <a href="Ray-Traced-Shadows.md">Ray-Traced Shadows</a>, or <a href="Override-Contact-Shadows.md">Contact Shadows</a>.</td>
<td>Indicates whether the shader receives shadows. Shadow matte only supports shadow maps.
It doesn't support screen-space shadows, <a href="Ray-Traced-Shadows.md">ray-traced Shadows</a>, or <a href="Override-Contact-Shadows.md">contact shadows</a>.<br>
Enable **Shadow Matte** if you add a custom Node that samples shadow maps, otherwise shadows might not render correctly.
</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@ TextureHandle RenderTransparentUI(RenderGraph renderGraph, HDCamera hdCamera)
context.cmd.ClearRenderTarget(false, true, Color.clear);
context.renderContext.ExecuteCommandBuffer(context.cmd);
context.cmd.Clear();
context.renderContext.DrawUIOverlay(data.camera);
if (data.camera.targetTexture == null)
context.renderContext.DrawUIOverlay(data.camera);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ When you upgrade a project from the Built-in Render Pipeline (BiRP) to the Unive
* [Render Pipeline Converter](features/rp-converter.md)
* [Upgrade custom shaders for URP compatibility](urp-shaders/birp-urp-custom-shader-upgrade-guide.md)
* [Find graphics quality settings in URP](birp-onboarding/quality-settings-location.md)
* [Update graphics quality levels for URP](quality-presets.md)
* [Update graphics quality levels for URP](birp-onboarding/quality-presets.md)

Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ This section contains information related to the impact of Rendering Layers on p

* When using Rendering Layers only for Lights in the Forward Rendering Path, the performance impact is insignificant.

* Performance impact grows more significantly when the Rendering Layer count exceeds a multiple of 8. For example: increasing the layer count from 8 to 9 layers has a bigger relative impact than increasing the layer count from 9 to 10 layers.
* Performance impact grows more significantly when the Rendering Layer count exceeds a multiple of 8. For example: increasing the layer count from 8 to 9 layers has a bigger relative impact than increasing the layer count from 9 to 10 layers. The same consideration applies to increasing the count from 16 to 17, from 24 to 25 and so on.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To configure post-processing in a new Scene:
Now you can use the Volume Override to enable and adjust the settings for the post-processing effect.

> [!NOTE]
> The GameObject which contains the volume and the camera you wish to apply post-processing to must be on the same Layer.
> Post-processing effects from a volume apply to a camera only if a value in the **Volume Mask** property of the camera contains the layer that the volume belongs to.
Refer to [Understand Volumes](Volumes.md) for more information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ The maximum distance from the Camera at which Unity renders decals.

Select this check box to enable the [Rendering Layers](features/rendering-layers.md) functionality.

For more information, refer to [How to use Rendering Layers with Decals](features/rendering-layers#how-to-rendering-layers-decals).

If you enable **Use Rendering Layers**, URP creates a DepthNormal prepass. This makes decals less efficient on GPUs that implement tile-based rendering.

## Decal Projector component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ This section uses the example `RedTintRenderPass` Scriptable Render Pass from th
material = CoreUtils.CreateEngineMaterial(shader);
redTintRenderPass = new RedTintRenderPass(material);

renderPassEvent = RenderPassEvent.AfterRenderingSkybox;
redTintRenderPass.renderPassEvent = RenderPassEvent.AfterRenderingSkybox;
}
```

Expand Down Expand Up @@ -136,6 +136,7 @@ public class MyRendererFeature : ScriptableRendererFeature
{
if (shader == null)
{
Debug.LogError("Ensure that you've set a shader in the Scriptable Renderer Feature.");
return;
}
material = CoreUtils.CreateEngineMaterial(shader);
Expand All @@ -147,12 +148,13 @@ public class MyRendererFeature : ScriptableRendererFeature
public override void AddRenderPasses(ScriptableRenderer renderer,
ref RenderingData renderingData)
{
if (renderingData.cameraData.cameraType == CameraType.Game)
if (redTintRenderPass != null &&
renderingData.cameraData.cameraType == CameraType.Game)
{
renderer.EnqueuePass(redTintRenderPass);
}
}
public override void Dispose(bool disposing)
protected override void Dispose(bool disposing)
{
CoreUtils.Destroy(material);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine.Profiling;
using UnityEngine.Experimental.Rendering.Universal;

namespace UnityEngine.Rendering.Universal
{
Expand Down Expand Up @@ -368,6 +369,15 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData
LayerUtility.InitializeBudget(m_Renderer2DData.lightRenderTextureMemoryBudget);
ShadowRendering.InitializeBudget(m_Renderer2DData.shadowRenderTextureMemoryBudget);

// Set screenParams when pixel perfect camera is used with the reference resolution
camera.TryGetComponent(out PixelPerfectCamera pixelPerfectCamera);
if (pixelPerfectCamera != null && pixelPerfectCamera.enabled && pixelPerfectCamera.offscreenRTSize != Vector2Int.zero)
{
var cameraWidth = pixelPerfectCamera.offscreenRTSize.x;
var cameraHeight = pixelPerfectCamera.offscreenRTSize.y;
renderingData.commandBuffer.SetGlobalVector(ShaderPropertyId.screenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
}

var isSceneLit = m_Renderer2DData.lightCullResult.IsSceneLit();
if (isSceneLit)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,7 @@ bool SetupForEmptyRendering(ref RenderingData renderingData)
/// <inheritdoc/>
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
// UUM-63146 - glClientWaitSync: Expected application to have kicked everything until job: 96089 (possibly by calling glFlush)" are thrown in the Android Player on some devices with PowerVR Rogue GE8320
// Resetting of target would clean up the color attachment buffers and depth attachment buffers, which inturn is preventing the leak in the said platform. This is likely a symptomatic fix, but is solving the problem for now.
if (Application.platform == RuntimePlatform.Android && PlatformAutoDetect.isRunningOnPowerVRGPU)
ResetTarget();

if (m_CreateEmptyShadowmap)
{
// Reset pass RTs to null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ bool SetupForEmptyRendering(ref RenderingData renderingData)
/// <inheritdoc />
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
// UUM-63146 - glClientWaitSync: Expected application to have kicked everything until job: 96089 (possibly by calling glFlush)" are thrown in the Android Player on some devices with PowerVR Rogue GE8320
// Resetting of target would clean up the color attachment buffers and depth attachment buffers, which inturn is preventing the leak in the said platform. This is likely a symptomatic fix, but is solving the problem for now.
if (Application.platform == RuntimePlatform.Android && PlatformAutoDetect.isRunningOnPowerVRGPU)
ResetTarget();

if (m_CreateEmptyShadowmap)
{
// Reset pass RTs to null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public override int SupportedCameraStackingTypes()
internal RTHandle m_ActiveCameraDepthAttachment;
internal RTHandle m_CameraDepthAttachment;
RTHandle m_XRTargetHandleAlias;
internal RTHandle m_CameraDepthAttachment_D3d_11;
internal RTHandle m_DepthTexture;
RTHandle m_NormalsTexture;
RTHandle m_DecalLayersTexture;
Expand Down Expand Up @@ -392,6 +393,7 @@ internal override void ReleaseRenderTargets()
m_AdditionalLightsShadowCasterPass?.Dispose();

m_CameraDepthAttachment?.Release();
m_CameraDepthAttachment_D3d_11?.Release();
m_DepthTexture?.Release();
m_NormalsTexture?.Release();
m_DecalLayersTexture?.Release();
Expand Down Expand Up @@ -806,7 +808,11 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re

// Doesn't create texture for Overlay cameras as they are already overlaying on top of created textures.
if (intermediateRenderTexture)
{
CreateCameraRenderTarget(context, ref cameraTargetDescriptor, useDepthPriming, cmd, ref cameraData);
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11)
cmd.CopyTexture(m_CameraDepthAttachment, m_CameraDepthAttachment_D3d_11);
}

m_RenderOpaqueForwardPass.m_IsActiveTargetBackBuffer = !intermediateRenderTexture;
m_RenderTransparentForwardPass.m_IsActiveTargetBackBuffer = !intermediateRenderTexture;
Expand Down Expand Up @@ -1532,7 +1538,14 @@ void CreateCameraRenderTarget(ScriptableRenderContext context, ref RenderTexture
depthDescriptor.graphicsFormat = GraphicsFormat.None;
depthDescriptor.depthStencilFormat = k_DepthStencilFormat;
RenderingUtils.ReAllocateIfNeeded(ref m_CameraDepthAttachment, depthDescriptor, FilterMode.Point, TextureWrapMode.Clamp, name: "_CameraDepthAttachment");
cmd.SetGlobalTexture(m_CameraDepthAttachment.name, m_CameraDepthAttachment.nameID);

if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11)
{
RenderingUtils.ReAllocateIfNeeded(ref m_CameraDepthAttachment_D3d_11, depthDescriptor, FilterMode.Point, TextureWrapMode.Clamp, name: "_CameraDepthAttachment_Temp");
cmd.SetGlobalTexture(m_CameraDepthAttachment.name, m_CameraDepthAttachment_D3d_11.nameID);
}
else
cmd.SetGlobalTexture(m_CameraDepthAttachment.name, m_CameraDepthAttachment.nameID);

// update the descriptor to match the depth attachment
descriptor.depthStencilFormat = depthDescriptor.depthStencilFormat;
Expand Down
13 changes: 12 additions & 1 deletion Packages/com.unity.shadergraph/Editor/Data/Graphs/GroupData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace UnityEditor.ShaderGraph
{
[Serializable]
public class GroupData : JsonObject
public class GroupData : JsonObject, IRectInterface
{
[SerializeField]
string m_Title;
Expand All @@ -16,6 +16,7 @@ public string title
set { m_Title = value; }
}


[SerializeField]
Vector2 m_Position;

Expand All @@ -25,6 +26,16 @@ public Vector2 position
set { m_Position = value; }
}

Rect IRectInterface.rect
{
get => new Rect(position, Vector2.one);
set
{
position = value.position;
}
}


public GroupData() : base() { }

public GroupData(string title, Vector2 position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,12 @@ internal static void InsertCopyPasteGraph(this MaterialGraphView graphView, Copy
{
var nodeList = copyGraph.GetNodes<AbstractMaterialNode>();

ClampNodesWithinView(graphView, new List<IRectInterface>().Union(nodeList).Union(copyGraph.stickyNotes));
ClampNodesWithinView(graphView,
new List<IRectInterface>()
.Union(nodeList)
.Union(copyGraph.stickyNotes)
.Union(copyGraph.groups)
);

graphView.graph.PasteGraph(copyGraph, remappedNodes, remappedEdges);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,13 @@ public override bool AcceptsElement(GraphElement element, ref string reasonWhyNo

return true;
}

protected override void SetScopePositionOnly(Rect newPos)
{
base.SetScopePositionOnly(newPos);

userData.position = newPos.position;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ If you want to manage multiple Visual Effect instances in the same Scene and wan
VisualEffect visualEffect;
VFXEventAttribute eventAttribute;

static readonly ExposedProperty positionAttribute = "Position"
static readonly ExposedProperty positionAttribute = "position"
static readonly ExposedProperty enteredTriggerEvent = "EnteredTrigger"

void Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ MonoBehaviour:
decalNormalBufferHP: 0
msaaSampleCount: 1
supportMotionVectors: 1
supportDataDrivenLensFlare: 1
supportRuntimeAOVAPI: 0
supportDitheringCrossFade: 1
supportTerrainHole: 0
Expand All @@ -72,7 +73,7 @@ MonoBehaviour:
maxEnvLightsOnScreen: 64
reflectionCacheCompressed: 0
reflectionProbeFormat: 74
reflectionProbeTexCacheSize: 1073750016
reflectionProbeTexCacheSize: 2048
reflectionProbeTexLastValidCubeMip: 3
reflectionProbeTexLastValidPlanarMip: 0
reflectionProbeDecreaseResToFit: 1
Expand Down Expand Up @@ -151,6 +152,8 @@ MonoBehaviour:
forcedPercentage: 100
lowResTransparencyMinimumThreshold: 0
rayTracingHalfResThreshold: 50
lowResSSGIMinimumThreshold: 0
lowResVolumetricCloudsMinimumThreshold: 50
lowresTransparentSettings:
enabled: 1
checkerboardDepthBuffer: 1
Expand Down Expand Up @@ -182,7 +185,7 @@ MonoBehaviour:
ChromaticAberrationMaxSamples: 03000000060000000c000000
lightSettings:
useContactShadow:
m_Values:
m_Values: 000000
m_SchemaId:
m_Id:
maximumLODLevel:
Expand Down Expand Up @@ -293,6 +296,8 @@ MonoBehaviour:
diffusionProfileSettings: {fileID: 0}
virtualTexturingSettings:
streamingCpuCacheSizeInMegaBytes: 256
streamingMipPreloadTexturesPerFrame: 0
streamingPreloadMipCount: 1
streamingGpuCacheSettings:
- format: 0
sizeInMegaBytes: 128
Expand Down
Loading

0 comments on commit c757aae

Please sign in to comment.