This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,117 @@
Shader "Hidden/Universal Render Pipeline/Debug/DebugReplacement"
{
SubShader
{
Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True"}
Pass
{
Name "Vertex Attributes"
Tags {"LightMode" = "UniversalForward"}
HLSLPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#define DEBUG_DISPLAY
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl"
//--------------------------------------
// GPU Instancing
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 texcoord7 : TEXCOORD7;
float4 color : COLOR;
float4 normal : NORMAL;
float4 tangent : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float4 texcoord0 : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 texcoord4 : TEXCOORD4;
float4 texcoord5 : TEXCOORD5;
float4 texcoord6 : TEXCOORD6;
float4 texcoord7 : TEXCOORD7;
float4 color : COLOR;
float4 normal : NORMAL;
float4 tangent : TANGENT;
};
Varyings vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
output.texcoord0 = input.texcoord0;
output.texcoord1 = input.texcoord1;
output.texcoord2 = input.texcoord2;
output.texcoord3 = input.texcoord3;
output.texcoord4 = input.texcoord4;
output.texcoord5 = input.texcoord5;
output.texcoord6 = input.texcoord6;
output.texcoord7 = input.texcoord7;
output.color = input.color;
output.normal = input.normal;
output.tangent = input.tangent;
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
return output;
}
half4 frag(Varyings input) : SV_TARGET
{
switch (_DebugVertexAttributeMode)
{
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD0:
return input.texcoord0;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD1:
return input.texcoord1;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD2:
return input.texcoord2;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD3:
return input.texcoord3;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD4:
return input.texcoord4;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD5:
return input.texcoord5;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD6:
return input.texcoord6;
case DEBUGVERTEXATTRIBUTEMODE_TEXCOORD7:
return input.texcoord7;
case DEBUGVERTEXATTRIBUTEMODE_COLOR:
return input.color;
case DEBUGVERTEXATTRIBUTEMODE_TANGENT:
return input.tangent;
case DEBUGVERTEXATTRIBUTEMODE_NORMAL:
return input.normal;
default:
return half4(0, 0, 0, 1);
}
}
ENDHLSL
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cf852408f2e174538bcd9b7fda1c5ae7
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,265 @@
Shader "Hidden/Universal/HDRDebugView"
{
HLSLINCLUDE
#pragma target 4.5
#pragma editor_sync_compilation
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_local_fragment _ HDR_ENCODING
#pragma dynamic_branch_local_fragment _ _HDR_OVERLAY
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/HDROutput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingFullscreen.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Debug.hlsl"
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
TEXTURE2D_X(_OverlayUITexture);
TEXTURE2D(_xyBuffer);
int _DebugHDRMode;
float4 _HDRDebugParams; // xy: xyBuffer size, zw: unused
float4 _HDROutputLuminanceParams; // xy: brightness min/max, z: paper white brightness, w: one over paper white brightness
#define _MinNits _HDROutputLuminanceParams.x
#define _MaxNits _HDROutputLuminanceParams.y
#define _PaperWhite _HDROutputLuminanceParams.z
float2 RGBtoxy(float3 rgb)
{
float3 XYZ = RotateOutputSpaceToXYZ(rgb);
return XYZtoxy(XYZ);
}
float3 uvToGamut(float2 uv)
{
float3 xyzColor = xyYtoXYZ(float3(uv.x, uv.y, 1.0f));
float3 linearRGB = RotateXYZToOutputSpace(xyzColor);
float scale = 1.0f / length(linearRGB);
float desat = dot(linearRGB, 0.333f);
scale *= 1.0 + exp(-length(linearRGB - desat) * 2.0f) * 0.5f;
linearRGB *= scale;
return linearRGB;
}
bool IsInCIExyMapping(float2 xy)
{
return SAMPLE_TEXTURE2D_LOD(_xyBuffer, sampler_PointClamp, xy, 0.0).x != 0;
}
float3 ValuesAbovePaperWhite(half4 color, float2 uv)
{
float maxC = max(color.x, max(color.y, color.z));
if (maxC > _PaperWhite)
{
if ( maxC > _MaxNits)
{
return float3(0, 0, _PaperWhite);
}
else
{
float t = (maxC - _PaperWhite) / (_MaxNits - _PaperWhite);
return lerp(float3(_PaperWhite, _PaperWhite, 0), float3(_PaperWhite, 0, 0), saturate(t));
}
}
else
{
return Luminance(color).xxx;
}
}
void RenderDebugHDR(half4 color, float2 uv, inout half4 debugColor)
{
if (_DebugHDRMode == HDRDEBUGMODE_VALUES_ABOVE_PAPER_WHITE)
{
debugColor.xyz = ValuesAbovePaperWhite(color, uv);
return;
}
int displayClip = (_DebugHDRMode == HDRDEBUGMODE_GAMUT_CLIP);
int gamutPiPSize = _ScreenSize.x / 3.0f;
float2 r_2020 = float2(0.708, 0.292);
float2 g_2020 = float2(0.170, 0.797);
float2 b_2020 = float2(0.131, 0.046);
float2 r_709 = float2(0.64, 0.33);
float2 g_709 = float2(0.3, 0.6);
float2 b_709 = float2(0.15, 0.06);
float2 r_p3 = float2(0.68, 0.32);
float2 g_p3 = float2(0.265, 0.69);
float2 b_p3 = float2(0.15, 0.06);
float2 pos = uv * _ScreenSize.xy;
float lineThickness = 0.002;
float2 xy = RGBtoxy(color.rgb);
float3 rec2020Color = float3(_PaperWhite, 0, 0);
float3 rec2020ColorDesat = float3(3.0, 0.5, 0.5);
float3 rec709Color = float3(0, _PaperWhite, 0);
float3 rec709ColorDesat = float3(0.4, 0.6, 0.4);
float3 p3Color = float3(0, 0, _PaperWhite);
float3 p3ColorDesat = float3(0.4, 0.4, 0.6);
//Display Gamut Clip Scene colour conversion
if (displayClip)
{
float clipAlpha = 0.2f;
if (IsPointInTriangle(xy, r_709, g_709, b_709))
{
color.rgb = (color.rgb * (1 - clipAlpha) + clipAlpha * rec709Color);
}
else if (IsPointInTriangle(xy, r_p3, g_p3, b_p3))
{
color.rgb = (color.rgb * (1 - clipAlpha) + clipAlpha * p3Color);
}
else if (IsPointInTriangle(xy, r_2020, g_2020, b_2020))
{
color.rgb = (color.rgb * (1 - clipAlpha) + clipAlpha * rec2020Color);
}
}
float4 gamutColor = 0;
if (all(pos < gamutPiPSize))
{
float2 uv = pos / gamutPiPSize; // scale-down uv
float4 lineColor = DrawSegment(uv, g_709, b_709, lineThickness, float3(0, 0, 0)) + DrawSegment(uv, b_709, r_709, lineThickness, float3(0, 0, 0)) +
DrawSegment(uv, r_709, g_709, lineThickness, float3(0, 0, 0)) +
DrawSegment(uv, g_2020, b_2020, lineThickness, float3(0, 0, 0)) + DrawSegment(uv, b_2020, r_2020, lineThickness, float3(0, 0, 0)) +
DrawSegment(uv, r_2020, g_2020, lineThickness, float3(0, 0, 0)) +
DrawSegment(uv, g_p3, b_p3, lineThickness, float3(0, 0, 0)) + DrawSegment(uv, b_p3, r_p3, lineThickness, float3(0, 0, 0)) +
DrawSegment(uv, r_p3, g_p3, lineThickness, float3(0, 0, 0));
float3 linearRGB = 0;
bool pointInRec709 = true;
if (IsPointInTriangle(uv, r_2020, g_2020, b_2020))
{
float3 colorSpaceColor = rec709Color;
linearRGB = uvToGamut(uv);
if (displayClip)
{
if (IsPointInTriangle(uv, r_709, g_709, b_709))
{
colorSpaceColor = rec709Color;
linearRGB.rgb = rec709ColorDesat;
}
else if (IsPointInTriangle(uv, r_p3, g_p3, b_p3))
{
colorSpaceColor = p3Color;
linearRGB.rgb = p3ColorDesat;
}
else
{
colorSpaceColor = rec2020Color;
linearRGB.rgb = rec2020ColorDesat;
}
}
gamutColor.a = max(lineColor.a, 0.15);
gamutColor.rgb = linearRGB * _PaperWhite;
if (IsInCIExyMapping(uv))
{
gamutColor.a = 1;
if (displayClip)
gamutColor.rgb = colorSpaceColor;
}
}
gamutColor.rgb = gamutColor.rgb * (1.0f - lineColor.a) + lineColor.rgb;
}
debugColor.rgb = gamutColor.rgb * gamutColor.a + color.rgb * (1 - gamutColor.a);
}
ENDHLSL
SubShader
{
Tags{ "RenderPipeline" = "UniversalPipeline" }
Pass
{
ZWrite Off
ZTest Always
ZClip Off
Blend Off
Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
RW_TEXTURE2D(float, _xyBufferRW);
#define _SizePerDim _HDRDebugParams.xy
half4 Frag(Varyings input) : SV_Target
{
float4 col = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_PointClamp, input.texcoord);
float2 xy = (RGBtoxy(col.rgb));
_xyBufferRW[(xy * _SizePerDim)] = 1;
return col;
}
ENDHLSL
}
Pass
{
ZWrite Off
ZTest Always
ZClip Off
Blend Off
Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
half4 Frag(Varyings input) : SV_Target
{
float4 outCol = 0;
float2 uv = input.texcoord;
half4 col = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_PointClamp, uv);
half4 outColor = 0;
RenderDebugHDR(col, uv, outColor);
#if defined(HDR_ENCODING)
UNITY_BRANCH if(_HDR_OVERLAY)
{
float4 uiSample = SAMPLE_TEXTURE2D_X(_OverlayUITexture, sampler_PointClamp, input.texcoord);
outColor.rgb = SceneUIComposition(uiSample, outColor.rgb, _PaperWhite, _MaxNits);
}
outColor.rgb = OETF(outColor.rgb, _MaxNits);
#endif
#if defined(DEBUG_DISPLAY)
half4 debugColor = 0;
if (CanDebugOverrideOutputColor(outColor, uv, debugColor))
{
return debugColor;
}
#endif
return outColor;
}
ENDHLSL
}
}
Fallback "Hidden/Core/FallbackError"
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 573620ae32aec764abd4d728906d2587
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl"
// Compute worldspace position and normal at given screenspace position and write it in the ResultBuffer
#pragma kernel ComputePositionNormal
RWStructuredBuffer<float4> _ResultBuffer;
uniform float4 _positionSS; // screenspace position
[numthreads(1,1,1)]
void ComputePositionNormal (uint3 id : SV_DispatchThreadID)
{
float deviceDepth = LOAD_TEXTURE2D_X(_CameraDepthTexture, _positionSS.xy).r;
float2 positionNDC = _positionSS.xy *_ScreenSize.zw + (0.5 * _ScreenSize.zw);
float3 positionWS = ComputeWorldSpacePosition(positionNDC, deviceDepth, UNITY_MATRIX_I_VP);
float3 normalWS = LoadSceneNormals(_positionSS.xy);
_ResultBuffer[0] = float4(positionWS, 1.0f);
_ResultBuffer[1] = float4(normalWS, 0.0f);
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 53626a513ea68ce47b59dc1299fe3959
ComputeShaderImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: