Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -328,25 +328,6 @@ internal void SetOverridesTo(IEnumerable<VolumeParameter> enumerable, bool state
}
}

/// <summary>
/// A custom hashing function that Unity uses to compare the state of parameters.
/// </summary>
/// <returns>A computed hash code for the current instance.</returns>
public override int GetHashCode()
{
unchecked
{
//return parameters.Aggregate(17, (i, p) => i * 23 + p.GetHash());

int hash = 17;

for (int i = 0; i < parameterList.Length; i++)
hash = hash * 23 + parameterList[i].GetHashCode();

return hash;
}
}

/// <summary>
/// Returns true if any of the volume properites has been overridden.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,14 @@ public void Initialize(VolumeProfile globalDefaultVolumeProfile = null, VolumePr
void InitializeBaseTypesArray(VolumeProfile globalDefaultVolumeProfile = null)
{
using var profilerScope = k_ProfilerMarkerInitializeBaseTypesArray.Auto();
#if UNITY_EDITOR
LoadBaseTypesByReflection(GraphicsSettings.currentRenderPipelineAssetType);
#else
#if !UNITY_EDITOR
if (globalDefaultVolumeProfile == null)
{
var defaultVolumeProfileSettings = GraphicsSettings.GetRenderPipelineSettings<IDefaultVolumeProfileAsset>();
globalDefaultVolumeProfile = defaultVolumeProfileSettings?.defaultVolumeProfile;
}
LoadBaseTypes(globalDefaultVolumeProfile);
#endif
LoadBaseTypes(GraphicsSettings.currentRenderPipelineAssetType, globalDefaultVolumeProfile);
}

//This is called by test where the basetypes are tuned for the purpose of the test.
Expand Down Expand Up @@ -311,7 +309,7 @@ public void Deinitialize()
/// <param name="profile">The VolumeProfile to use as the global default profile.</param>
public void SetGlobalDefaultProfile(VolumeProfile profile)
{
LoadBaseTypes(profile);
LoadBaseTypes(GraphicsSettings.currentRenderPipelineAssetType, profile);
globalDefaultProfile = profile;
EvaluateVolumeDefaultState();
}
Expand Down Expand Up @@ -423,8 +421,9 @@ public void DestroyStack(VolumeStack stack)
/// LoadBaseTypes is responsible for loading the list of VolumeComponent types that will be used to build the default state of the VolumeStack. It uses the provided global default profile to determine which component types are relevant for the current render pipeline.
/// This will be called only once at runtime on app boot
/// </summary>
/// <param name="rpType">The Pipeline Type used to check if each VolumeComponent is supported.</param>
/// <param name="globalDefaultVolumeProfile">The global default volume profile to use to build the base component type array.</param>
internal void LoadBaseTypes(VolumeProfile globalDefaultVolumeProfile)
internal void LoadBaseTypesByDefaultVolume(Type rpType, VolumeProfile globalDefaultVolumeProfile)
{
if (globalDefaultVolumeProfile == null)
{
Expand All @@ -434,13 +433,13 @@ internal void LoadBaseTypes(VolumeProfile globalDefaultVolumeProfile)

using (ListPool<Type>.Get(out var list))
{
var pipelineAssetType = GraphicsSettings.currentRenderPipelineAssetType;
foreach (var comp in globalDefaultVolumeProfile.components)
{
if (comp == null) continue;
if (comp == null)
continue;

var componentType = comp.GetType();
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(componentType, pipelineAssetType))
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(componentType, rpType))
continue;

list.Add(componentType);
Expand Down Expand Up @@ -469,15 +468,30 @@ internal Type[] LoadBaseTypesByReflection(Type pipelineAssetType)
if (!SupportedOnRenderPipelineAttribute.IsTypeSupportedOnRenderPipeline(t, pipelineAssetType))
continue;

if (t.GetCustomAttribute<ObsoleteAttribute>() != null)
continue;

list.Add(t);
}

m_BaseComponentTypeArray = list.ToArray();
}

return m_BaseComponentTypeArray;
}
#endif
/// <summary>
/// Helper to choose a type loading depending if we are in Editor and Standalone.
/// </summary>
/// <param name="pipelineAssetType">The Pipeline Type used to check if each VolumeComponent is supported.</param>
/// <param name="globalDefaultVolumeProfile">The global default volume profile to use to build the base component type array.</param>
void LoadBaseTypes(Type pipelineAssetType, VolumeProfile globalDefaultVolumeProfile = null)
{
#if UNITY_EDITOR
LoadBaseTypesByReflection(pipelineAssetType);
#else
LoadBaseTypesByDefaultVolume(pipelineAssetType, globalDefaultVolumeProfile);
#endif
}

internal void InitializeVolumeComponents()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,33 +321,16 @@ public bool TryGetAllSubclassOf<T>(Type type, List<T> result)
return count != result.Count;
}

/// <summary>
/// A custom hashing function that Unity uses to compare the state of parameters.
/// </summary>
/// <returns>A computed hash code for the current instance.</returns>
public override int GetHashCode()
{
unchecked
{
int hash = 17;

for (int i = 0; i < components.Count; i++)
hash = hash * 23 + components[i].GetHashCode();

return hash;
}
}

internal int GetComponentListHashCode()
{
unchecked
{
int hash = 17;
var hashCode = HashFNV1A32.Create();

for (int i = 0; i < components.Count; i++)
hash = hash * 23 + components[i].GetType().GetHashCode();
hashCode.Append(components[i].GetType().GetHashCode());

return hash;
return hashCode.value;
}
}

Expand Down
5 changes: 5 additions & 0 deletions Packages/com.unity.render-pipelines.core/Runtime/Vrs/Vrs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class VisualizationPassData
/// <summary>
/// Check if conversion of color texture to shading rate image is supported.
/// Convenience to abstract all capabilities checks.
///
/// The `IsColorMaskTextureConversionSupported` method checks for the following:
///- VRS hardware support through [ShadingRateInfo.supportsPerImageTile](xref:UnityEngine.Rendering.ShadingRateInfo.supportsPerImageTile). The `supportsPerImageTile` property determines whether your GPU can define different quality levels to different tiles.
///- Compute shader support through [SystemInfo.supportsComputeShaders](xref:UnityEngine.Device.SystemInfo.supportsComputeShaders)
///- Proper initialization of VRS utility functions and compute shaders required for converting color textures to shading rate image (SRI). This is automatically handled by the render pipeline. However, for custom implementations, you must call <see cref="InitializeResources"/> manually.
/// </summary>
/// <returns>Returns true if conversion of color texture to shading rate image is supported, false otherwise.</returns>
public static bool IsColorMaskTextureConversionSupported()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
Expand Down Expand Up @@ -122,4 +123,5 @@ void BakeVATArray(GameObject target, List<AnimationClip> clips, int fps)

Debug.Log($"VAT Array (RGBAHalf) baked: {path} with {clips.Count} clips. Max frames = {maxFrames}");
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,7 @@ out ScriptableCullingParameters cullingParams
frozenCullingParamAvailable = false;
}

cullingParams.conservativeEnclosingSphere = currentAsset.m_ShouldUseConservativeEnclosingSphere;
LightLoopUpdateCullingParameters(ref cullingParams, hdCamera);

// If we don't use environment light (like when rendering reflection probes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace UnityEngine.Rendering.HighDefinition
#endif
public partial class HDRenderPipelineAsset : RenderPipelineAsset<HDRenderPipeline>, IVirtualTexturingEnabledRenderPipeline, IProbeVolumeEnabledRenderPipeline, IGPUResidentRenderPipeline, IRenderGraphEnabledRenderPipeline, ISTPEnabledRenderPipeline
{
//This is not exposed to the UI. It can be enabled via Debug inspector if it is really needed.
[SerializeField] internal bool m_ShouldUseConservativeEnclosingSphere;
/// <inheritdoc/>
public override string renderPipelineShaderTag => HDRenderPipeline.k_ShaderTagName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ internal TargetBuffer getConstrainedDepthBuffer()
{
TargetBuffer depth = targetDepthBuffer;
if (depth == TargetBuffer.Camera &&
HDRenderPipeline.currentAsset != null &&
HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.enabled &&
currentHDCamera.allowDynamicResolution &&
currentHDCamera != null && currentHDCamera.allowDynamicResolution &&
injectionPoint == CustomPassInjectionPoint.AfterPostProcess)
{
// This custom pass is injected after postprocessing, and Dynamic Resolution Scaling is enabled, which
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,18 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
// Early out for preview camera
if (cameraData.cameraType == CameraType.Preview)
isLitView = false;

DebugHandler debugHandler = GetActiveDebugHandler(cameraData);
if (debugHandler != null)
isLitView = debugHandler.IsLightingActive;
#endif

// Preset global light textures for first batch
if (batchIndex == 0)
{
using (var builder = graph.AddRasterRenderPass<SetGlobalPassData>(k_SetLightBlendTexture, out var passData, m_SetLightBlendTextureProfilingSampler))
{
if (layerBatch.lightStats.useLights)
if (layerBatch.lightStats.useLights && isLitView)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
Expand Down Expand Up @@ -168,7 +172,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData
builder.UseRendererList(passData.rendererList);
}

if (passData.layerUseLights)
if (passData.layerUseLights && isLitView)
{
passData.lightTextures = universal2DResourceData.lightTextures[batchIndex];
for (var i = 0; i < passData.lightTextures.Length; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private struct ImportResourceSummary
CopyDepthPass m_CopyDepthPass;
UpscalePass m_UpscalePass;
CopyCameraSortingLayerPass m_CopyCameraSortingLayerPass;
CapturePass m_CapturePass;
FinalBlitPass m_FinalBlitPass;
FinalBlitPass m_OffscreenUICoverPrepass;
DrawScreenSpaceUIPass m_DrawOffscreenUIPass;
Expand Down Expand Up @@ -117,6 +118,7 @@ public Renderer2D(Renderer2DData data) : base(data)

m_UpscalePass = new UpscalePass(RenderPassEvent.AfterRenderingPostProcessing, m_BlitMaterial);
m_CopyCameraSortingLayerPass = new CopyCameraSortingLayerPass(m_BlitMaterial);
m_CapturePass = new CapturePass(RenderPassEvent.AfterRendering);
m_FinalBlitPass = new FinalBlitPass(RenderPassEvent.AfterRendering + k_FinalBlitPassQueueOffset, m_BlitMaterial, m_BlitHDRMaterial);
m_OffscreenUICoverPrepass = new FinalBlitPass(RenderPassEvent.BeforeRenderingPostProcessing, m_BlitMaterial, m_BlitOffscreenUICoverMaterial);

Expand Down Expand Up @@ -201,7 +203,8 @@ private RenderPassInputSummary GetRenderPassInputs(UniversalCameraData cameraDat
|| cameraData.cameraTargetDescriptor.msaaSamples > 1 && UniversalRenderer.PlatformRequiresExplicitMsaaResolve()
|| m_Renderer2DData.useCameraSortingLayerTexture
|| !Mathf.Approximately(cameraData.renderScale, 1.0f)
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget));
|| (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget))
|| cameraData.captureActions != null;

return inputSummary;
}
Expand Down Expand Up @@ -958,6 +961,12 @@ private void OnAfterRendering(RenderGraph renderGraph)
var finalBlitTarget = resolveToDebugScreen ? commonResourceData.debugScreenColor : commonResourceData.backBufferColor;
var finalDepthHandle = resolveToDebugScreen ? commonResourceData.debugScreenDepth : commonResourceData.backBufferDepth;

// Capture pass for Unity Recorder
if (hasCaptureActions)
{
m_CapturePass.RecordRenderGraph(renderGraph, frameData);
}

if (applyFinalPostProcessing)
{
m_PostProcessPassRenderGraph.RenderFinalPassRenderGraph(renderGraph, frameData, in finalColorHandle, commonResourceData.overlayUITexture, in finalBlitTarget, needsColorEncoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
SetupGrain(m_OnTileUberMaterial, cameraData, filmgrain, m_PostProcessData);
SetupDithering(m_OnTileUberMaterial, cameraData, m_PostProcessData);

CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings.LinearToSRGBConversion, cameraData.requireSrgbConversion);
CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings.UseFastSRGBLinearConversion, postProcessingData.useFastSRGBLinearConversion);
CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT, cameraData.isAlphaOutputEnabled);

UberShaderPasses shaderPass = useVisibilityMesh ? UberShaderPasses.NormalVisMesh : UberShaderPasses.Normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Shader "OnTileUberPost"
#pragma multi_compile_local_fragment _ _HDR_GRADING _TONEMAP_ACES _TONEMAP_NEUTRAL
#pragma multi_compile_local_fragment _ _FILM_GRAIN
#pragma multi_compile_local_fragment _ _DITHERING
#pragma multi_compile_local_fragment _ _GAMMA_20 _LINEAR_TO_SRGB_CONVERSION
#pragma multi_compile_local_fragment _ _USE_FAST_SRGB_LINEAR_CONVERSION
#pragma multi_compile_local_fragment _ _ENABLE_ALPHA_OUTPUT
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"

Expand Down Expand Up @@ -73,6 +75,14 @@ Shader "OnTileUberPost"
{
half3 color = inputColor.rgb;

// Gamma space... Just do the rest of Uber in linear and convert back to sRGB at the end
#if UNITY_COLORSPACE_GAMMA
{
color = GetSRGBToLinear(color);
inputColor = GetSRGBToLinear(inputColor);
}
#endif

// To save on variants we use an uniform branch for vignette. This may have performance impact on lower end platforms
UNITY_BRANCH
if (VignetteIntensity > 0)
Expand All @@ -97,12 +107,26 @@ Shader "OnTileUberPost"
}
#endif

// When Unity is configured to use gamma color encoding, we ignore the request to convert to gamma 2.0 and instead fall back to sRGB encoding
#if _GAMMA_20 && !UNITY_COLORSPACE_GAMMA
{
color = LinearToGamma20(color);
inputColor = LinearToGamma20(inputColor);
}
// Back to sRGB
#elif UNITY_COLORSPACE_GAMMA || _LINEAR_TO_SRGB_CONVERSION
{
color = GetLinearToSRGB(color);
inputColor = LinearToSRGB(inputColor);
}
#endif

#if _DITHERING
{
color = ApplyDithering(color, uv, TEXTURE2D_ARGS(_BlueNoise_Texture, sampler_PointRepeat), DitheringScale, DitheringOffset, PaperWhite, OneOverPaperWhite);
}
#endif

#if _ENABLE_ALPHA_OUTPUT
// Saturate is necessary to avoid issues when additive blending pushes the alpha over 1.
return half4(color, saturate(inputColor.a));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ float3 UnitySkinSprite( in float3 inputData, in uint4 blendIndices, in float4 bl

void SetUpSpriteInstanceProperties()
{
#ifdef UNITY_INSTANCING_ENABLED
#if defined(UNITY_INSTANCING_ENABLED) && !defined(HAVE_VFX_MODIFICATION)
unity_SpriteProps.xy = unity_SpriteFlip;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Returns the result of converting the value of input **In** from one colorspace s
| Name | Type | Options | Description |
|:------------ |:-------------|:-----|:---|
| From | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert from |
| To | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert to |
| To | Dropdown | RGB, Linear, HSV | Selects the colorspace to convert to. Returns values in the range 0 to 1, or higher if the color space is HDR. |

## Generated Code Example

Expand Down
Loading
Loading