You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #ROBOMERGE-OWNER: charles.derousiers #ROBOMERGE-AUTHOR: charles.derousiers #ROBOMERGE-SOURCE: CL 16566234 #ROBOMERGE-BOT: (v828-16531559) #ROBOMERGE-CONFLICT from-shelf [CL 16566334 by charles derousiers in ue5-main branch]
66 lines
1.9 KiB
Plaintext
66 lines
1.9 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "Common.ush"
|
|
|
|
#include "ShaderDrawDebug.ush"
|
|
|
|
// The shader used to render the debug element on view
|
|
StructuredBuffer<FPackedShaderDrawElement> ShaderDrawDebugPrimitive;
|
|
|
|
Texture2D<float> DepthTexture;
|
|
int2 DepthTextureResolution;
|
|
float2 DepthTextureInvResolution;
|
|
SamplerState DepthSampler;
|
|
|
|
#if GPU_DEBUG_RENDERING_VS
|
|
void ShaderDrawDebugVS(
|
|
in uint InstanceId : SV_InstanceID,
|
|
in uint VertexId : SV_VertexID,
|
|
out float4 Position : SV_POSITION,
|
|
out float4 ColorAlpha : TEXCOORD0)
|
|
{
|
|
FPackedShaderDrawElement PackedLine = ShaderDrawDebugPrimitive[InstanceId];
|
|
FShaderDrawElement Line = UnpackShaderElement(PackedLine);
|
|
|
|
float4 VertexPosition = float4(VertexId == 0 ? Line.Pos0 : Line.Pos1, 1.0f);
|
|
float4 VertexColor = VertexId == 0 ? Line.Color0 : Line.Color1;
|
|
|
|
Position = mul(VertexPosition, View.WorldToClip);
|
|
ColorAlpha = VertexColor;
|
|
}
|
|
#endif
|
|
|
|
#if GPU_DEBUG_RENDERING_PS
|
|
void ShaderDrawDebugPS(
|
|
in float4 Position : SV_POSITION,
|
|
in float4 ColorAlpha : TEXCOORD0,
|
|
out float4 OutSceneColor : SV_Target0)
|
|
{
|
|
uint2 PixelCoord = Position.xy;
|
|
|
|
const float2 DepthUV = float2(PixelCoord) * DepthTextureInvResolution;
|
|
const float Depth = DepthTexture.SampleLevel(DepthSampler, DepthUV, 0);
|
|
const bool bIsHidden = Position.z < Depth; // Reverse-Z
|
|
|
|
const float ColorScale = bIsHidden ? 0.4f : 1;
|
|
const float CheckerboardScale = ((PixelCoord.x%2) ^ (PixelCoord.y%2)) > 0 ? 1 : 0.0;
|
|
const float OcclusionScale = bIsHidden ? CheckerboardScale : 1;
|
|
OutSceneColor = OcclusionScale * ColorAlpha * float4(ColorAlpha.aaa * ColorScale, 1.0); // Pre multiplied alpha with color scale
|
|
}
|
|
#endif
|
|
|
|
#if GPU_DEBUG_RENDERING_CLEAR_CS
|
|
|
|
RWStructuredBuffer<FPackedShaderDrawElement> DataBuffer;
|
|
RWBuffer<uint> IndirectBuffer;
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void ShaderDrawDebugClearCS(uint3 DispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
IndirectBuffer[0] = 2;
|
|
IndirectBuffer[1] = 0;
|
|
IndirectBuffer[2] = 0;
|
|
IndirectBuffer[3] = 0;
|
|
}
|
|
#endif |