You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

185 lines
6.0 KiB

${VFXBegin:VFXPassDepth}"DepthForwardOnly"${VFXEnd}
${VFXBegin:VFXPassForward}"ForwardOnly"${VFXEnd}
${VFXBegin:VFXPassShadow}"ShadowCaster"${VFXEnd}
${VFXBegin:VFXPassVelocity}"MotionVectors"${VFXEnd}
${VFXBegin:VFXPassDepthDefine}
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#if VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION
#define SCENESELECTIONPASS
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
#define SCENEPICKINGPASS
#endif
${VFXEnd}
${VFXBegin:VFXPassForwardDefine}#define SHADERPASS SHADERPASS_FORWARD_UNLIT${VFXEnd}
${VFXBegin:VFXPassShadowDefine}#define SHADERPASS SHADERPASS_SHADOWS${VFXEnd}
${VFXBegin:VFXPassVelocityDefine}#define SHADERPASS SHADERPASS_MOTION_VECTORS${VFXEnd}
${VFXBegin:VFXPassDepthAdditionalPragma}#pragma multi_compile _ WRITE_MSAA_DEPTH${VFXEnd}
${VFXBegin:VFXPassForwardAdditionalPragma}#pragma multi_compile _ DEBUG_DISPLAY${VFXEnd}
${VFXBegin:VFXPassVelocityAdditionalPragma}#pragma multi_compile _ WRITE_MSAA_DEPTH${VFXEnd}
${VFXBegin:VFXShaderGraphFunctionsInclude}
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl"
#ifndef SHADERPASS
#error Shaderpass should be defined at this stage.
#endif
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
${VFXEnd}
${VFXBegin:VFXPassDepthCommonFragmentLit}
#if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
${VFXPassVelocityDefine}
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW
${VFXPassShadowDefine}
#else
${VFXPassDepthDefine}
#endif
${VFXIncludeRP("VFXLit.template")}
${SHADERGRAPH_PIXEL_CODE_DEPTHONLY}
#if VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION
int _ObjectId;
int _PassValue;
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
float4 _SelectionID;
#endif
#pragma fragment frag
void frag(ps_input i
#if USE_DOUBLE_SIDED
, bool frontFace : SV_IsFrontFace
#endif
#if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
#ifdef WRITE_MSAA_DEPTH
// We need the depth color as SV_Target0 for alpha to coverage
, out float4 outDepthColor : SV_Target0
, out float4 outMotionVector : SV_Target1
#ifdef WRITE_NORMAL_BUFFER
, out float4 outNormalBuffer : SV_Target2
#endif
#else
// When no MSAA, the motion vector is always the first buffer
, out float4 outMotionVector : SV_Target0
#ifdef WRITE_NORMAL_BUFFER
, out float4 outNormalBuffer : SV_Target1
#endif
#endif
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_ACTUAL
#ifdef WRITE_MSAA_DEPTH
// We need the depth color as SV_Target0 for alpha to coverage
, out float4 outDepthColor : SV_Target0
#ifdef WRITE_NORMAL_BUFFER
, out float4 outNormalBuffer : SV_Target1
#endif
#elif defined(WRITE_NORMAL_BUFFER)
, out float4 outNormalBuffer : SV_Target0
#endif
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION || VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
, out float4 outColor : SV_Target0
#endif
)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
VFXTransformPSInputs(i);
${VFXComputeNormalWS}
#ifdef VFX_SHADERGRAPH
${VFXAdditionalInterpolantsPreparation}
${SHADERGRAPH_PIXEL_CALL_DEPTHONLY}
float alpha = OUTSG.${SHADERGRAPH_PARAM_ALPHA};
#else
float alpha = VFXGetFragmentColor(i).a;
#if HDRP_USE_BASE_COLOR_MAP_ALPHA
alpha *= VFXGetTextureColor(VFX_SAMPLER(baseColorMap),i).a;
#endif
#if VFX_MATERIAL_TYPE_SIX_WAY_SMOKE
#ifndef VFX_VARYING_NORMAL
const VFXUVData uvData = GetUVData(i);
#endif
alpha *= SampleTexture(VFX_SAMPLER(positiveAxesLightmap),uvData).a;
#if VFX_SIX_WAY_USE_ALPHA_REMAP
alpha = SampleCurve(i.VFX_VARYING_ALPHA_REMAP, alpha);
#endif
#endif
#endif
VFXClipFragmentColor(alpha,i);
#ifdef WRITE_NORMAL_BUFFER
#ifndef VFX_SHADERGRAPH
VFXComputePixelOutputToNormalBuffer(i,normalWS,uvData,outNormalBuffer);
#else
#if HAS_SHADERGRAPH_PARAM_NORMAL
float3 n = OUTSG.Normal_8;
normalWS = mul(n,tbn);
#endif
SurfaceData surface = (SurfaceData)0;
surface.normalWS = normalWS;
EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surface), outNormalBuffer);
#endif
#endif
#ifdef WRITE_MSAA_DEPTH
outDepthColor = i.VFX_VARYING_POSCS.z;
#if VFX_USE_ALPHA_TO_MASK
outDepthColor.a = alpha;
#endif
#endif
#if VFX_PASSDEPTH == VFX_PASSDEPTH_MOTION_VECTOR
${VFXComputeOutputMotionVector}
outMotionVector = encodedMotionVector;
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SELECTION
// We use depth prepass for scene selection in the editor, this code allow to output the outline correctly
outColor = float4(_ObjectId, _PassValue, 1.0, 1.0);
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_PICKING
outColor = _SelectionID;
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_ACTUAL
//void
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW
//void
#else
#error VFX_PASSDEPTH undefined
#endif
}
${VFXEnd}
${VFXBegin:VFXPassFullScreenDebugCommonVertex}
#if !defined(SHADER_API_METAL)
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_VERTEX_DENSITY)
IncrementVertexDensityCounter(o.VFX_VARYING_POSCS);
#endif
${VFXEnd}
${VFXBegin:VFXPassFullScreenDebugCommonFragment}
#pragma fragment frag
[earlydepthstencil]
void frag(ps_input i
#if defined(PLATFORM_SUPPORTS_PRIMITIVE_ID_IN_PIXEL_SHADER)
, uint primitiveId : SV_PrimitiveID
#endif
)
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
VFXTransformPSInputs(i);
VFX_FRAG_SETUP_INSTANCE_ID(i);
#ifdef PLATFORM_SUPPORTS_PRIMITIVE_ID_IN_PIXEL_SHADER
if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_QUAD_OVERDRAW)
{
IncrementQuadOverdrawCounter((uint2)i.VFX_VARYING_POSCS.xy, primitiveId);
}
#endif
}
${VFXEnd}