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.
117 lines
3.4 KiB
117 lines
3.4 KiB
#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
|
|
}
|