diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
index 34bc9598dba..0c24e68ae6d 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs
@@ -99,6 +99,8 @@ public enum FullScreenDebugMode
DepthOfFieldCoc,
/// Display Transparency Overdraw.
TransparencyOverdraw,
+ /// Display Virtual Texturing resolver feedback.
+ VirtualTexturingFeedback,
/// Maximum Full Screen Rendering debug mode value (used internally).
MaxRenderingFullScreenDebug,
@@ -113,6 +115,11 @@ public enum FullScreenDebugMode
MaxMaterialFullScreenDebug
}
+ public enum VirtualTexturingFeedbackMode
+ {
+ HighlightMips = 0,
+ HighlightStackConfiguration = 1
+ }
///
/// Class managing debug display in HDRP.
///
@@ -195,6 +202,8 @@ public class DebugData
public uint screenSpaceShadowIndex = 0;
/// Display ray tracing ray count per frame.
public bool countRays = false;
+ /// Toggle focus on mips vs VT tilesets
+ public VirtualTexturingFeedbackMode VTFeedbackMode = VirtualTexturingFeedbackMode.HighlightMips;
/// Index of the camera to freeze for visibility.
public int debugCameraToFreeze = 0;
@@ -216,6 +225,7 @@ public class DebugData
internal int tileClusterDebugByCategoryEnumIndex;
internal int lightVolumeDebugTypeEnumIndex;
internal int renderingFulscreenDebugModeEnumIndex;
+ internal int vtFeedbackEnumIndex;
internal int terrainTextureEnumIndex;
internal int colorPickerDebugModeEnumIndex;
internal int msaaSampleDebugModeEnumIndex;
@@ -1376,6 +1386,18 @@ void RegisterRenderingDebug()
});
}
+ if (data.fullScreenDebugMode == FullScreenDebugMode.VirtualTexturingFeedback)
+ {
+ widgetList.Add(new DebugUI.Container
+ {
+ children =
+ {
+ new DebugUI.EnumField {displayName = "Debug mode ", getter = () => (int)data.VTFeedbackMode, setter = value => data.VTFeedbackMode = (VirtualTexturingFeedbackMode)value, autoEnum = typeof(VirtualTexturingFeedbackMode), getIndex = () => data.vtFeedbackEnumIndex, setIndex = value => data.vtFeedbackEnumIndex = value}
+ }
+ })
+ ;
+ }
+
widgetList.AddRange(new DebugUI.Widget[]
{
new DebugUI.EnumField { displayName = "MipMaps", getter = () => (int)data.mipMapDebugSettings.debugMipMapMode, setter = value => SetMipMapMode((DebugMipMapMode)value), autoEnum = typeof(DebugMipMapMode), onValueChanged = RefreshRenderingDebug, getIndex = () => data.mipMapsEnumIndex, setIndex = value => { data.ResetExclusiveEnumIndices(); data.mipMapsEnumIndex = value; } },
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
index f619aa2f7ce..0b45a40b9ce 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl
@@ -29,11 +29,13 @@
#define FULLSCREENDEBUGMODE_COLOR_LOG (19)
#define FULLSCREENDEBUGMODE_DEPTH_OF_FIELD_COC (20)
#define FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW (21)
-#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (22)
-#define FULLSCREENDEBUGMODE_MIN_MATERIAL_FULL_SCREEN_DEBUG (23)
-#define FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR (24)
-#define FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR (25)
-#define FULLSCREENDEBUGMODE_MAX_MATERIAL_FULL_SCREEN_DEBUG (26)
+#define FULLSCREENDEBUGMODE_VIRTUAL_TEXTURING_FEEDBACK (22)
+#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (23)
+#define FULLSCREENDEBUGMODE_MIN_MATERIAL_FULL_SCREEN_DEBUG (24)
+#define FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR (25)
+#define FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR (26)
+#define FULLSCREENDEBUGMODE_MAX_MATERIAL_FULL_SCREEN_DEBUG (27)
+
// Generated from UnityEngine.Rendering.HighDefinition.ShaderVariablesDebugDisplay
// PackingRules = Exact
@@ -66,5 +68,4 @@ CBUFFER_START(ShaderVariablesDebugDisplay)
float3 _DebugDisplayPad0;
CBUFFER_END
-
#endif
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
index 7d16243a47c..d6772060afd 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugFullScreen.shader
@@ -29,6 +29,7 @@ Shader "Hidden/HDRP/DebugFullScreen"
CBUFFER_START (UnityDebug)
float _FullScreenDebugMode;
float _TransparencyOverdrawMaxPixelCost;
+ float _VTFocusMips;
uint _DebugContactShadowLightIndex;
int _DebugDepthPyramidMip;
CBUFFER_END
@@ -58,6 +59,23 @@ Shader "Hidden/HDRP/DebugFullScreen"
return output;
}
+ static float4 VTDebugColors[] = {
+ float4(1.0f, 1.0f, 1.0f, 1.0f),
+ float4(1.0f, 1.0f, 0.0f, 1.0f),
+ float4(0.0f, 1.0f, 1.0f, 1.0f),
+ float4(0.0f, 1.0f, 0.0f, 1.0f),
+ float4(1.0f, 0.0f, 1.0f, 1.0f),
+ float4(1.0f, 0.0f, 0.0f, 1.0f),
+ float4(0.0f, 0.0f, 1.0f, 1.0f),
+ float4(0.5f, 0.5f, 0.5f, 1.0f),
+ float4(0.5f, 0.5f, 0.0f, 1.0f),
+ float4(0.0f, 0.5f, 0.5f, 1.0f),
+ float4(0.0f, 0.5f, 0.0f, 1.0f),
+ float4(0.5f, 0.0f, 0.5f, 1.0f),
+ float4(0.5f, 0.0f, 0.0f, 1.0f),
+ float4(0.0f, 0.0f, 0.5f, 1.0f)
+ };
+
// Motion vector debug utilities
float DistanceToLine(float2 p, float2 p1, float2 p2)
{
@@ -317,6 +335,56 @@ Shader "Hidden/HDRP/DebugFullScreen"
return color;
}
+ if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_VIRTUAL_TEXTURING_FEEDBACK)
+ {
+ float4 color = SAMPLE_TEXTURE2D_X(_DebugFullScreenTexture, s_point_clamp_sampler, input.texcoord);
+ if (color.r == 0 && color.g == 0 && color.b == 0 && color.a == 0) return float4(0, 0, 0, 0);
+
+ float4 swiz;
+ swiz = color;
+ swiz *= 255.0f;
+
+ float tileX = color.r;
+ float tileY = color.g;
+ float level = color.b;
+ float tex = color.a;
+
+ float h = 0;
+ if (_VTFocusMips == 1)
+ {
+ if (tex < 8.0f) h = ((uint)tex % 8) * 45.0f;
+ else if (tex < 16.0f) h = ((uint) tex % 8) * 45.0f + 22.5f;
+ else if (tex < 32.0f) h = ((uint) tex % 8) * 45.0f + 11.25f;
+
+ h /= 360.0f;
+
+ float s = 1.0f;
+ float v = 1.0f;
+ v = ((uint)tileY % 5) / 10.0f + 0.25f;
+ s = ((uint)tileX % 5) / 10.0f + 0.25f;
+ s = 1.0f - s;
+
+ return float4(HsvToRgb(float3(h, s, v)), 1.0f);
+ }
+ else
+ {
+ float3 hsv = RgbToHsv(VTDebugColors[level].rgb);
+ //dont adjust hue/saturation when trying to show white or grey (on mips 0 and 7)
+ if (level == 0 || level == 7)
+ {
+ hsv.z = ((uint)tileY % 5) / 5.0f + 1.0f - (((uint)tileX % 5) / 5.0f);
+ hsv.z /= 2.0f;
+ hsv.x = 0.0f;
+ hsv.y = 0.0f;
+ }
+ else
+ {
+ hsv.y = ((uint)tileY % 5) / 10.0f + 0.5f;
+ hsv.z = 1.0f - (((uint)tileX % 5) / 10.0f + 0.5f);
+ }
+ return float4(HsvToRgb(hsv), 1.0f);
+ }
+ }
return float4(0.0, 0.0, 0.0, 0.0);
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader
new file mode 100644
index 00000000000..4559fdd77cb
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader
@@ -0,0 +1,66 @@
+Shader "Hidden/DebugVTBlit"
+{
+
+ SubShader
+ {
+ // No culling or depth
+ Cull Off ZWrite Off ZTest Always
+
+ Pass
+ {
+ CGPROGRAM
+ #pragma vertex vert
+ #pragma fragment frag
+ #pragma multi_compile_local __ USE_TEXARRAY
+
+ #include "UnityCG.cginc"
+
+ struct appdata
+ {
+ float4 vertex : POSITION;
+ float2 uv : TEXCOORD0;
+ };
+
+ struct v2f
+ {
+ float2 uv : TEXCOORD0;
+ float4 vertex : SV_POSITION;
+ };
+
+ v2f vert(appdata v)
+ {
+ v2f o;
+ o.vertex = UnityObjectToClipPos(v.vertex);
+ o.uv = v.uv;
+ return o;
+ }
+
+#ifdef USE_TEXARRAY
+ UNITY_DECLARE_TEX2DARRAY(_MainTex);
+#else
+ sampler2D _MainTex;
+#endif
+
+ fixed4 frag(v2f i) : SV_Target
+ {
+#ifdef USE_TEXARRAY
+ fixed4 col = UNITY_SAMPLE_TEX2DARRAY(_MainTex,float3(i.uv,0.0f));
+#else
+ fixed4 col = tex2D(_MainTex, i.uv);
+#endif
+
+ float4 swiz;
+ swiz = col;
+ swiz *= 255.0f;
+
+ float tileX = swiz.x + fmod(swiz.y, 8.0f) * 256.0f;
+ float tileY = floor(swiz.y / 8.0f) + fmod(swiz.z, 64.0f) * 32.0f;
+ float level = floor((swiz.z) / 64.0f) + fmod(swiz.w, 4.0f) * 4.0f;
+ float tex = floor(swiz.w / 4.0f);
+
+ return float4(tileX,tileY,level,tex);
+ }
+ ENDCG
+ }
+ }
+}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader.meta b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader.meta
new file mode 100644
index 00000000000..7ea74d22c6f
--- /dev/null
+++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugVTBlit.shader.meta
@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: de1f42f132e4e9948bd09358ef124d46
+ShaderImporter:
+ externalObjects: {}
+ defaultTextures: []
+ nonModifiableTextures: []
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
index 23a2872f6d5..c76c8f0bb28 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
@@ -278,6 +278,7 @@ internal int GetMaxScreenSpaceShadows()
// Debugging
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock();
DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings();
+ Material m_VTDebugBlit;
///
/// Debug display settings.
///
@@ -1229,6 +1230,16 @@ void ConfigureKeywords(bool enableBakeShadowMask, HDCamera hdCamera, CommandBuff
// Raise or remove the depth msaa flag based on the frame setting
CoreUtils.SetKeyword(cmd, "WRITE_MSAA_DEPTH", hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+
+#if UNITY_EDITOR && ENABLE_VIRTUALTEXTURES
+ //Set VTDebug mode based on useTexArray
+ if (!m_VTDebugBlit) m_VTDebugBlit = new Material(Shader.Find("Hidden/DebugVTBlit"));
+ if (m_VTDebugBlit)
+ {
+ if (TextureXR.useTexArray) m_VTDebugBlit.EnableKeyword("USE_TEXARRAY");
+ else m_VTDebugBlit.DisableKeyword("USE_TEXARRAY");
+ }
+#endif
}
struct RenderRequest
@@ -2534,6 +2545,14 @@ void Callback(CommandBuffer c, HDCamera cam)
#if ENABLE_VIRTUALTEXTURES
m_VtBufferManager.Resolve(cmd, m_GbufferManager.GetVTFeedbackBuffer(), hdCamera);
VirtualTexturing.System.Update();
+#if UNITY_EDITOR
+ if(m_VTDebugBlit != null)
+ {
+ PushFullScreenDebugTexture(cmd, GetVTFeedbackBufferForForward(hdCamera), FullScreenDebugMode.VirtualTexturingFeedback, m_VTDebugBlit);
+ m_DebugFullScreenPropertyBlock.SetFloat(HDShaderIDs._VTFocusMips, (int)m_DebugDisplaySettings.data.VTFeedbackMode);
+ }
+
+#endif
#endif
// At this point, m_CameraColorBuffer has been filled by either debug views are regular rendering so we can push it here.
@@ -4379,6 +4398,17 @@ internal void PushFullScreenDebugTexture(HDCamera hdCamera, CommandBuffer cmd, R
}
}
+ void PushFullScreenDebugTexture(CommandBuffer cmd, RTHandle textureID, FullScreenDebugMode debugMode, Material shader)
+ {
+ if(debugMode == m_CurrentDebugDisplaySettings.data.fullScreenDebugMode)
+ {
+ m_FullScreenDebugPushed = true;
+ var stringsz = shader.GetTexturePropertyNames();
+ cmd.SetGlobalTexture("_MainTex", textureID);
+ cmd.Blit(textureID, m_DebugFullScreenTempBuffer, shader,0);
+ }
+ }
+
void PushFullScreenDebugTextureMip(HDCamera hdCamera, CommandBuffer cmd, RTHandle texture, int lodCount, FullScreenDebugMode debugMode)
{
if (debugMode == m_CurrentDebugDisplaySettings.data.fullScreenDebugMode)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
index 46e2b05c52b..e27ea21dd26 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
@@ -448,6 +448,9 @@ static class HDShaderIDs
public static readonly int _HorizonZenithShiftPower = Shader.PropertyToID("_HorizonZenithShiftPower");
public static readonly int _HorizonZenithShiftScale = Shader.PropertyToID("_HorizonZenithShiftScale");
+ //Virtual Texturing debug
+ public static readonly int _VTFocusMips = Shader.PropertyToID("_VTFocusMips");
+
// Raytracing variables
public static readonly int _RaytracingRayBias = Shader.PropertyToID("_RaytracingRayBias");
public static readonly int _RayTracingLayerMask = Shader.PropertyToID("_RayTracingLayerMask");