Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@
PackedVaryingsType Vert(AttributesMesh inputMesh)
{
VaryingsType varyingsType;
varyingsType.vmesh = VertMesh(inputMesh);

#if (SHADERPASS == SHADERPASS_DEPTH_ONLY) && defined(HAVE_RECURSIVE_RENDERING) && !defined(SCENESELECTIONPASS)
// If we have a recursive raytrace object, we will not render it.
// As we don't want to rely on renderqueue to exclude the object from the list,
// we cull it by settings position to NaN value.
// TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer
if (_EnableRecursiveRayTracing && _RayTracing > 0.0)
{
ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive.
}
else
#endif
{
varyingsType.vmesh = VertMesh(inputMesh);
}

return PackVaryingsType(varyingsType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,21 @@ PackedVaryingsToPS VertTesselation(VaryingsToDS input)
PackedVaryingsType Vert(AttributesMesh inputMesh)
{
VaryingsType varyingsType;
varyingsType.vmesh = VertMesh(inputMesh);

#if defined(HAVE_RECURSIVE_RENDERING)
// If we have a recursive raytrace object, we will not render it.
// As we don't want to rely on renderqueue to exclude the object from the list,
// we cull it by settings position to NaN value.
// TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer
if (_EnableRecursiveRayTracing && _RayTracing > 0.0)
{
ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive.
}
else
#endif
{
varyingsType.vmesh = VertMesh(inputMesh);
}

return PackVaryingsType(varyingsType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@
PackedVaryingsType Vert(AttributesMesh inputMesh)
{
VaryingsType varyingsType;
varyingsType.vmesh = VertMesh(inputMesh);

#if defined(HAVE_RECURSIVE_RENDERING)
// If we have a recursive raytrace object, we will not render it.
// As we don't want to rely on renderqueue to exclude the object from the list,
// we cull it by settings position to NaN value.
// TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer
if (_EnableRecursiveRayTracing && _RayTracing > 0.0)
{
ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive.
}
else
#endif
{
varyingsType.vmesh = VertMesh(inputMesh);
}

return PackVaryingsType(varyingsType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,86 +98,67 @@ VaryingsToDS InterpolateWithBaryCoordsToDS(VaryingsToDS input0, VaryingsToDS inp
#define PackVaryingsType PackVaryingsToPS
#endif

#define TEST_RECURSIVE_RENDERING (SHADEROPTIONS_RAYTRACING && defined(HAVE_RECURSIVE_RENDERING) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD || (SHADERPASS == SHADERPASS_DEPTH_ONLY && !defined(SCENESELECTIONPASS))))
// TODO: Here we will also have all the vertex deformation (GPU skinning, vertex animation, morph target...) or we will need to generate a compute shaders instead (better! but require work to deal with unpacking like fp16)
// Make it inout so that MotionVectorPass can get the modified input values later.
VaryingsMeshType VertMesh(AttributesMesh input)
{
VaryingsMeshType output;

// If we have a recursive raytrace object, we will not render it.
// As we don't want to rely on renderqueue to exclude the object from the list,
// we cull it by settings position to NaN value.
// TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer
#if TEST_RECURSIVE_RENDERING
// Note: Raytrace object can output in motion vector pass and shadow pass
if (_EnableRecursiveRayTracing && _RayTracing > 0.0)
{
ZERO_INITIALIZE(VaryingsMeshType, output); // Divide by 0 should produce a NaN and thus cull the primitive.
}
else
{
#endif

UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);

#if defined(HAVE_MESH_MODIFICATION)
input = ApplyMeshModification(input, _TimeParameters.xyz);
input = ApplyMeshModification(input, _TimeParameters.xyz);
#endif

// This return the camera relative position (if enable)
float3 positionRWS = TransformObjectToWorld(input.positionOS);
// This return the camera relative position (if enable)
float3 positionRWS = TransformObjectToWorld(input.positionOS);
#ifdef ATTRIBUTES_NEED_NORMAL
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
#else
float3 normalWS = float3(0.0, 0.0, 0.0); // We need this case to be able to compile ApplyVertexModification that doesn't use normal.
float3 normalWS = float3(0.0, 0.0, 0.0); // We need this case to be able to compile ApplyVertexModification that doesn't use normal.
#endif

#ifdef ATTRIBUTES_NEED_TANGENT
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
#endif

// Do vertex modification in camera relative space (if enable)
// Do vertex modification in camera relative space (if enable)
#if defined(HAVE_VERTEX_MODIFICATION)
ApplyVertexModification(input, normalWS, positionRWS, _TimeParameters.xyz);
ApplyVertexModification(input, normalWS, positionRWS, _TimeParameters.xyz);
#endif

#ifdef TESSELLATION_ON
output.positionRWS = positionRWS;
output.normalWS = normalWS;
output.positionRWS = positionRWS;
output.normalWS = normalWS;
#if defined(VARYINGS_NEED_TANGENT_TO_WORLD) || defined(VARYINGS_DS_NEED_TANGENT)
output.tangentWS = tangentWS;
output.tangentWS = tangentWS;
#endif
#else
#ifdef VARYINGS_NEED_POSITION_WS
output.positionRWS = positionRWS;
output.positionRWS = positionRWS;
#endif
output.positionCS = TransformWorldToHClip(positionRWS);
output.positionCS = TransformWorldToHClip(positionRWS);
#ifdef VARYINGS_NEED_TANGENT_TO_WORLD
output.normalWS = normalWS;
output.tangentWS = tangentWS;
output.normalWS = normalWS;
output.tangentWS = tangentWS;
#endif
#endif

#if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)
output.texCoord0 = input.uv0;
output.texCoord0 = input.uv0;
#endif
#if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1)
output.texCoord1 = input.uv1;
output.texCoord1 = input.uv1;
#endif
#if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2)
output.texCoord2 = input.uv2;
output.texCoord2 = input.uv2;
#endif
#if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3)
output.texCoord3 = input.uv3;
output.texCoord3 = input.uv3;
#endif
#if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
output.color = input.color;
#endif

#if TEST_RECURSIVE_RENDERING
}
output.color = input.color;
#endif

return output;
Expand Down