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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public enum FullScreenDebugMode
DepthOfFieldCoc,
/// <summary>Display Transparency Overdraw.</summary>
TransparencyOverdraw,
/// <summary>Display Requested Virtual Texturing tiles, colored by the mip</summary>
RequestedVirtualTextureTiles,
/// <summary>Maximum Full Screen Rendering debug mode value (used internally).</summary>
MaxRenderingFullScreenDebug,

Expand Down Expand Up @@ -409,7 +411,7 @@ public bool IsDebugDisplayEnabled()
/// <returns>True if any material debug display is enabled.</returns>
public bool IsDebugMaterialDisplayEnabled()
{
return data.materialDebugSettings.IsDebugDisplayEnabled();
return data.materialDebugSettings.IsDebugDisplayEnabled();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
#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_REQUESTED_VIRTUAL_TEXTURE_TILES (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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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)
{
Expand Down Expand Up @@ -317,6 +334,35 @@ Shader "Hidden/HDRP/DebugFullScreen"
return color;
}

if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_REQUESTED_VIRTUAL_TEXTURE_TILES)
{
float4 color = SAMPLE_TEXTURE2D_X(_DebugFullScreenTexture, s_point_clamp_sampler, input.texcoord);
if (!any(color))
return float4(0, 0, 0, 0);

float tileX = color.r;
float tileY = color.g;
float level = color.b;
float tex = color.a;
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 = 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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Shader "Hidden/DebugVTBlit"
{
SubShader
{
// No culling or depth
Cull Off
ZWrite Off
ZTest Always

Pass
{
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

struct Attributes
{
uint vertexID : SV_VertexID;
};

struct Varyings
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};

float4 _BlitScaleBias;
TEXTURE2D_X(_BlitTexture);

Varyings vert(Attributes input)
{
Varyings o;
o.vertex = GetFullScreenTriangleVertexPosition(input.vertexID);
o.uv = GetNormalizedFullScreenTriangleTexCoord(input.vertexID) * _BlitScaleBias.xy + _BlitScaleBias.zw;;
return o;
}

float4 frag(Varyings i) : SV_Target
{
float4 col = 255.0f * SAMPLE_TEXTURE2D_X(_BlitTexture, s_point_clamp_sampler, i.uv);

float tileX = col.x + fmod(col.y, 8.0f) * 256.0f;
float tileY = floor(col.y / 8.0f) + fmod(col.z, 64.0f) * 32.0f;
float level = floor((col.z) / 64.0f) + fmod(col.w, 4.0f) * 4.0f;
float tex = floor(col.w / 4.0f);

return float4(tileX, tileY, level, tex);
}
ENDHLSL
}
}
Fallback Off
}

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 @@ -287,6 +287,9 @@ internal int GetMaxScreenSpaceShadows()
// Debugging
MaterialPropertyBlock m_SharedPropertyBlock = new MaterialPropertyBlock();
DebugDisplaySettings m_DebugDisplaySettings = new DebugDisplaySettings();
#if ENABLE_VIRTUALTEXTURES
Material m_VTDebugBlit;
#endif
/// <summary>
/// Debug display settings.
/// </summary>
Expand Down Expand Up @@ -454,6 +457,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau
m_DbufferManager.InitializeHDRPResouces(asset);
#if ENABLE_VIRTUALTEXTURES
m_VtBufferManager = new VTBufferManager(asset);
m_VTDebugBlit = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugViewVirtualTexturingBlit);
#endif

m_SharedRTManager.Build(asset);
Expand Down Expand Up @@ -1096,6 +1100,9 @@ protected override void Dispose(bool disposing)
CoreUtils.Destroy(m_CameraMotionVectorsMaterial);
CoreUtils.Destroy(m_DecalNormalBufferMaterial);

#if ENABLE_VIRTUALTEXTURES
CoreUtils.Destroy(m_VTDebugBlit);
#endif
CoreUtils.Destroy(m_DebugViewMaterialGBuffer);
CoreUtils.Destroy(m_DebugViewMaterialGBufferShadowMask);
CoreUtils.Destroy(m_DebugDisplayLatlong);
Expand Down Expand Up @@ -2825,6 +2832,11 @@ void Callback(CommandBuffer c, HDCamera cam)
#if ENABLE_VIRTUALTEXTURES
m_VtBufferManager.Resolve(cmd, m_GbufferManager.GetVTFeedbackBuffer(), hdCamera);
VirtualTexturing.System.Update();

if(m_VTDebugBlit != null)
{
PushFullScreenDebugTexture(cmd, GetVTFeedbackBufferForForward(hdCamera), FullScreenDebugMode.RequestedVirtualTextureTiles, m_VTDebugBlit);
}
#endif

// At this point, m_CameraColorBuffer has been filled by either debug views are regular rendering so we can push it here.
Expand Down Expand Up @@ -4822,6 +4834,16 @@ 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; // We need this flag because otherwise if no full screen debug is pushed (like for example if the corresponding pass is disabled), when we render the result in RenderDebug m_DebugFullScreenTempBuffer will contain potential garbage
HDUtils.BlitCameraTexture(cmd, textureID, m_DebugFullScreenTempBuffer, shader, 0);
}
}


void PushFullScreenDebugTextureMip(HDCamera hdCamera, CommandBuffer cmd, RTHandle texture, int lodCount, FullScreenDebugMode debugMode)
{
if (debugMode == m_CurrentDebugDisplaySettings.data.fullScreenDebugMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public sealed class ShaderResources
public ComputeShader debugLightVolumeCS;
[Reload("Runtime/Debug/DebugBlitQuad.Shader")]
public Shader debugBlitQuad;
[Reload("Runtime/Debug/DebugVTBlit.Shader")]
public Shader debugViewVirtualTexturingBlit;

// Lighting
[Reload("Runtime/Lighting/Deferred.Shader")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,22 @@ public static void BlitOctahedralWithPaddingMultiply(CommandBuffer cmd, Texture
/// <param name="bilinear">Enable bilinear filtering.</param>
public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, float mipLevel, bool bilinear)
{
s_PropertyBlock.SetTexture(HDShaderIDs._BlitTexture, source);
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBias, scaleBias);
s_PropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, mipLevel);
cmd.DrawProcedural(Matrix4x4.identity, GetBlitMaterial(TextureXR.dimension), bilinear ? 1 : 0, MeshTopology.Triangles, 3, 1, s_PropertyBlock);
BlitTexture(cmd, source, scaleBias, GetBlitMaterial(TextureXR.dimension), bilinear ? 1 : 0);
}
/// <summary>
/// Blit a RTHandle texture
/// </summary>
/// <param name="cmd">Command Buffer used for rendering.</param>
/// <param name="source">Source RTHandle.</param>
/// <param name="scaleBias">Scale and bias for sampling the input texture.</param>
/// <param name="material">Material to invoke when blitting.</param>
/// <param name="pass">Pass idx within the material to invoke.</param>
static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
{
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBias, scaleBias);
s_PropertyBlock.SetTexture(HDShaderIDs._BlitTexture, source);
cmd.DrawProcedural(Matrix4x4.identity, material, pass, MeshTopology.Triangles, 3, 1, s_PropertyBlock);
}

// In the context of HDRP, the internal render targets used during the render loop are the same for all cameras, no matter the size of the camera.
Expand All @@ -351,6 +363,24 @@ public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandl
BlitTexture(cmd, source, viewportScale, mipLevel, bilinear);
}

/// <summary>
/// Blit a RTHandle to another RTHandle.
/// This will properly account for partial usage (in term of resolution) of the texture for the current viewport.
/// This overloads allows the user to override the default blit shader
/// </summary>
/// <param name="cmd">Command Buffer used for rendering.</param>
/// <param name="source">Source RTHandle.</param>
/// <param name="destination">Destination RTHandle.</param>
/// <param name="material">The material to use when blitting</param>
/// <param name="pass">pass to use of the provided material</param>
public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Material material, int pass)
{
Vector2 viewportScale = new Vector2(source.rtHandleProperties.rtHandleScale.x, source.rtHandleProperties.rtHandleScale.y);
// Will set the correct camera viewport as well.
CoreUtils.SetRenderTarget(cmd, destination);
BlitTexture(cmd, source, viewportScale, material, pass);
}


/// <summary>
/// Blit a RTHandle to another RTHandle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ MonoBehaviour:
debugLightVolumeCS: {fileID: 7200000, guid: f5d5d21faef5cf445ac2c5d8ff9c4184,
type: 3}
debugBlitQuad: {fileID: 4800000, guid: cf5ca5b6ef18b3f429ed707ee9ceac9f, type: 3}
debugViewVirtualTexturingBlit: {fileID: 4800000, guid: 55d195396b03b804eb78c92d468e3c8e,
type: 3}
deferredPS: {fileID: 4800000, guid: 00dd221e34a6ab349a1196b0f2fab693, type: 3}
colorPyramidPS: {fileID: 4800000, guid: 2fcfb8d92f45e4549b3f0bad5d0654bf, type: 3}
depthPyramidCS: {fileID: 7200000, guid: 64a553bb564274041906f78ffba955e4, type: 3}
Expand Down Expand Up @@ -212,6 +214,8 @@ MonoBehaviour:
DoFCoCPyramidCS: {fileID: 7200000, guid: df41a69211c03fe479b63a8bed3bfbb4, type: 3}
contrastAdaptiveSharpenCS: {fileID: 7200000, guid: 560896aec2f412c48995be35551a4ac6,
type: 3}
VTFeedbackDownsample: {fileID: 7200000, guid: 32d963548086c2c439aeb23a93e9a00a,
type: 3}
accumulationCS: {fileID: 7200000, guid: ed80add7a217efa468d137d6f7c668f3, type: 3}
alphaInjectionPS: {fileID: 4800000, guid: 4edd96259a5e8b44c90479928f0cd11e, type: 3}
chromaKeyingPS: {fileID: 4800000, guid: 49feb6b111e82ec4eb6d3d08e4b6903e, type: 3}
Expand Down