Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f5d9db1
Compute Skinning is applied in VertMesh through defines
Jan 18, 2021
58cbddd
Add front buffer index to access deformed vertices of current/previou…
svens-unity Jan 19, 2021
48b1ecf
Actually get the the vertex position of the current frame when render…
svens-unity Jan 19, 2021
a60bccc
d3d debug pragma for HDTarget
Jan 19, 2021
b6a4805
Remove skin setting component
Jan 19, 2021
b7dd69d
Apply skinning in motion vec pass, rename function
Jan 20, 2021
81d0788
Add motion vectors to unity instancing properties
Jan 20, 2021
0d6a8dd
Remove compute deformation node
Jan 20, 2021
860362d
Merge branch '10.x.x/release' into 10.x.x/dots-deformations/motion-ve…
Jan 21, 2021
4e921d8
Update changelog for HRDP and SG
Jan 21, 2021
82ffcd8
Enable vertexID when DOTS_INSTANCING_ON is defined
Jan 27, 2021
028e908
Remove manual adding of vertex id and defines in HD shader passes
Jan 27, 2021
80c2dcd
Remove skinning include and define
Jan 27, 2021
19846d9
Remove compute mesh index property when dots instancing is not defined
Jan 27, 2021
8ee28d1
Shader cleanup for dots deformations
Jan 27, 2021
0145e4b
Rename shader file for dots skinning functions
Jan 27, 2021
cf88c73
Remove changes from HDShaderPasses
Jan 27, 2021
ce95d4c
Remove formatting issues
Jan 27, 2021
fe9468e
Remove include define
Jan 27, 2021
80199e9
Merge branch '10.x.x/release' into 10.x.x/dots-deformations/motion-ve…
Jan 27, 2021
34db42a
Remove all changes from HDShaderPasses
Jan 27, 2021
2b8ea7d
Remove debug pragma
Jan 27, 2021
ee68b60
Update some comments
Jan 27, 2021
2825bd2
Remove duplicated define
Jan 27, 2021
69e7eae
Add compute mesh index to URP shader variables. Add function to fetch…
Jan 28, 2021
98d986e
Rename some functions, move fetching to different file
Jan 28, 2021
690298f
Rename deformation function for HDRP
Jan 28, 2021
8716688
Merge branch '10.x.x/release' into 10.x.x/dots-deformations/motion-ve…
Jan 29, 2021
b84ffcf
Keep vertex ID as optional when hybrid v2 is not used
Jan 29, 2021
6f3cbf1
Remove formatting from HDTarget
Jan 29, 2021
aa24bcf
Updated changelogs to be more descriptive.
Jan 29, 2021
7ac5ee9
Rename material property
Jan 29, 2021
3c2a52c
Add dots skinning function to URP passes PBR-Forward/GBuffer, Lit-For…
Jan 29, 2021
808bf70
Remove modulus from deform vertex function
Feb 1, 2021
a3c3a8e
Remove modulus, change to uints
Feb 11, 2021
b70a82a
Remove documentation for Compute Deformation Node
Feb 11, 2021
5d3abda
Update Core/ShaderLibrary/DotsDeformation.hlsl.meta file with newly g…
pastasfuture Mar 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added light unit slider for automatic and automatic histrogram exposure limits.
- Added View Bias for mesh decals.
- Added support for the PlayStation 5 platform.
- Added support for skinned motionvectors when using Hybrid Renderer

### Fixed
- Fixed computation of geometric normal in path tracing (case 1293029).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static public PassDescriptor GenerateShadowCaster(bool supportLighting)
lightMode = "ShadowCaster",
useInPreview = false,

validPixelBlocks = new BlockFieldDescriptor[]
validPixelBlocks = new BlockFieldDescriptor[]
{
BlockFields.SurfaceDescription.Alpha,
BlockFields.SurfaceDescription.AlphaClipThreshold,
Expand Down Expand Up @@ -349,7 +349,7 @@ DefineCollection GenerateDefines()
// {
// defines.Add(CoreKeywordDescriptors.WriteNormalBuffer, 1);
// }

return defines;
}

Expand Down Expand Up @@ -389,7 +389,7 @@ IncludeCollection GenerateIncludes()
public static PassDescriptor GenerateForwardOnlyPass(bool supportLighting)
{
return new PassDescriptor
{
{
// Definition
displayName = "ForwardOnly",
referenceName = supportLighting ? "SHADERPASS_FORWARD" : "SHADERPASS_FORWARD_UNLIT",
Expand Down Expand Up @@ -445,7 +445,7 @@ IncludeCollection GenerateIncludes()
includes.Add(CoreIncludes.kPassForward, IncludeLocation.Postgraph);
else
includes.Add(CoreIncludes.kPassForwardUnlit, IncludeLocation.Postgraph);

return includes;
}
}
Expand All @@ -457,7 +457,7 @@ IncludeCollection GenerateIncludes()
public static PassDescriptor GenerateBackThenFront(bool supportLighting)
{
return new PassDescriptor
{
{
// Definition
displayName = "TransparentBackface",
referenceName = supportLighting ? "SHADERPASS_FORWARD" : "SHADERPASS_FORWARD_UNLIT",
Expand Down Expand Up @@ -1064,7 +1064,7 @@ IncludeCollection GenerateIncludes()
// We want to have the normal buffer include if this is a gbuffer and unlit shader
if (!supportLighting)
includes.Add(CoreIncludes.kNormalBuffer, IncludeLocation.Pregraph);

// If this is the gbuffer sub-shader, we want the standard lit data
includes.Add(CoreIncludes.kStandardLit, IncludeLocation.Pregraph);

Expand Down Expand Up @@ -1254,13 +1254,13 @@ IncludeCollection GenerateIncludes()
public static class Defines
{
// Shadows
public static DefineCollection shadowLow = new DefineCollection { {CoreKeywordDescriptors.Shadow, 0} };
public static DefineCollection shadowMedium = new DefineCollection { {CoreKeywordDescriptors.Shadow, 1} };
public static DefineCollection shadowHigh = new DefineCollection { {CoreKeywordDescriptors.Shadow, 2} };
public static DefineCollection shadowLow = new DefineCollection { { CoreKeywordDescriptors.Shadow, 0 } };
public static DefineCollection shadowMedium = new DefineCollection { { CoreKeywordDescriptors.Shadow, 1 } };
public static DefineCollection shadowHigh = new DefineCollection { { CoreKeywordDescriptors.Shadow, 2 } };

// Raytracing Quality
public static DefineCollection raytracingDefault = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 0} };
public static DefineCollection raytracingRaytraced = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 1} };
public static DefineCollection raytracingDefault = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 0 } };
public static DefineCollection raytracingRaytraced = new DefineCollection { { RayTracingQualityNode.GetRayTracingQualityKeyword(), 1 } };
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public struct AttributesMesh
"COLOR", subscriptOptions : StructFieldOptions.Optional);
public static FieldDescriptor instanceID = new FieldDescriptor(AttributesMesh.name, "instanceID", "", ShaderValueType.Uint,
"INSTANCEID_SEMANTIC", "UNITY_ANY_INSTANCING_ENABLED");
public static FieldDescriptor vertexID = new FieldDescriptor(AttributesMesh.name, "vertexID", "ATTRIBUTES_NEED_VERTEXID", ShaderValueType.Uint,
"SV_VertexID", subscriptOptions: StructFieldOptions.Optional);
public static FieldDescriptor vertexID = new FieldDescriptor(AttributesMesh.name, "vertexID", "", ShaderValueType.Uint,
"SV_VertexID", "DOTS_INSTANCING_ON");
}

public struct VaryingsMeshToPS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ static class CorePragmas
{ Pragma.Vertex("Vert") },
{ Pragma.Fragment("Frag") },
{ Pragma.OnlyRenderers(PragmaRenderers.GetHighEndPlatformArray()) },
{ Pragma.DX11Debug },
};

public static PragmaCollection InstancedRenderingLayer = new PragmaCollection
Expand Down Expand Up @@ -947,7 +948,7 @@ static class CoreIncludes
public const string kPassForwardUnlit = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl";
public const string kPassConstant = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassConstant.hlsl";
public const string kPassFullScreenDebug = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassFullScreenDebug.hlsl";

public static IncludeCollection MinimalCorePregraph = new IncludeCollection
{
{ kShaderVariables, IncludeLocation.Pregraph },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,8 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 1.0f;
}

m_ShaderVariablesGlobalCB._HybridDeformedVertexStreamIndex = UnityEngine.Time.frameCount % 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we will want to put this behind a Dots define 🤔

I also think we can improve the name I came up with. Perhaps _DotsDeformedMeshFrontBufferIndex? It's tricky because this is the index we use to index the index property that stores the index into the deformed mesh buffer...


ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef SKINNING_INCLUDED
#define SKINNING_INCLUDED

#if defined(DOTS_INSTANCING_ON)
struct DeformedVertexData
{
float3 Position;
float3 Normal;
float3 Tangent;
};

uniform StructuredBuffer<DeformedVertexData> _DeformedMeshData;
uniform StructuredBuffer<DeformedVertexData> _PreviousFrameDeformedMeshData;

void DOTS_Deformation(inout AttributesMesh input)
{
// x = curr frame index
// y = prev frame index
// z = deformation check (0 = no deformation, 1 = has deformation)
// w = skinned motion vectors
const int4 deformProperty = asint(unity_ComputeMeshIndex);
const int doSkinning = deformProperty.z;
if (doSkinning == 1)
{
const int streamIndex = _HybridDeformedVertexStreamIndex;
const int startIndex = deformProperty[streamIndex];
const DeformedVertexData vertexData = _DeformedMeshData[startIndex + input.vertexID]; //if vertexid defined

input.positionOS = vertexData.Position;
#ifdef ATTRIBUTES_NEED_NORMAL
input.normalOS = vertexData.Normal;
#endif
#ifdef ATTRIBUTES_NEED_TANGENT
input.tangentOS = float4(vertexData.Tangent, 0);
#endif
}
}
#endif

//LBS Node not supported (skinning in vertex shader)

#if defined(DOTS_INSTANCING_ON)
// position only for motion vec vs
void DOTS_Deformation_MotionVecPass(inout float3 currPos, inout float3 prevPos, uint vertexID)
{
// x = curr frame index
// y = prev frame index
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

// z = deformation check (0 = no deformation, 1 = has deformation)
// w = skinned motion vectors
const int4 deformProperty = asint(unity_ComputeMeshIndex);
const int doSkinning = deformProperty.w;
if (doSkinning == 1)
{
const int currStreamIndex = _HybridDeformedVertexStreamIndex;
const int prevStreamIndex = (currStreamIndex + 1) % 2;

const int currMeshStart = deformProperty[currStreamIndex];
const int prevMeshStart = deformProperty[prevStreamIndex];

currPos = _DeformedMeshData[currMeshStart + vertexID].Position;
prevPos = _PreviousFrameDeformedMeshData[prevMeshStart + vertexID].Position;
}
}
#endif


#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ PackedVaryingsType MotionVectorVS(inout VaryingsType varyingsType, AttributesMes
{
bool hasDeformation = unity_MotionVectorsParams.x > 0.0; // Skin or morph target

float3 effectivePositionOS = (hasDeformation ? inputPass.previousPositionOS : inputMesh.positionOS);
float3 deformedPrevPos = inputPass.previousPositionOS;

#if defined(DOTS_INSTANCING_ON)
DOTS_Deformation_MotionVecPass(inputMesh.positionOS, deformedPrevPos, inputMesh.vertexID);
#endif
float3 effectivePositionOS = (hasDeformation) ? deformedPrevPos : inputMesh.positionOS;

#if defined(_ADD_PRECOMPUTED_VELOCITY)
effectivePositionOS -= inputPass.precomputedVelocity;
#endif

// Need to apply any vertex animation to the previous worldspace position, if we want it to show up in the motion vector buffer
#if defined(HAVE_MESH_MODIFICATION)
AttributesMesh previousMesh = inputMesh;
previousMesh.positionOS = effectivePositionOS ;
previousMesh.positionOS = effectivePositionOS;

previousMesh = ApplyMeshModification(previousMesh, _LastTimeParameters.xyz);
float3 previousPositionRWS = TransformPreviousObjectToWorld(previousMesh.positionOS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ struct AttributesMesh
#ifdef ATTRIBUTES_NEED_COLOR
float4 color : COLOR;
#endif

#ifdef DOTS_INSTANCING_ON
uint vertexID : SV_VertexID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: be sure this compile on DX12 / PS4 / Xbox. We have get various surprise with system sematic ordering on those platform (with double sided, instance id etc...)

also we need to use VERTEXID_SEMANTIC and not SV_VertexID

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Guess for now Vertex_ID is only used with skinned mesh right?
so it should not be define when DOTS_INSTANCING_ON is on, but when DOTS_SKINNING_INSTANCING_ON ? (which doesnt exist but you get the idea). Just wondering :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok reading more code it seems that we can only know dynamically if we use skinning or not, so fine.

#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ VaryingsToDS InterpolateWithBaryCoordsToDS(VaryingsToDS input0, VaryingsToDS inp
#define PackVaryingsType PackVaryingsToPS
#endif

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/DotsDeformation.hlsl"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surround with dots instancing on define?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


// 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, float3 worldSpaceOffset)
Expand All @@ -135,6 +137,10 @@ VaryingsMeshType VertMesh(AttributesMesh input, float3 worldSpaceOffset)
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);

#if defined(DOTS_INSTANCING_ON)
DOTS_Deformation(input);
#endif

#if defined(HAVE_MESH_MODIFICATION)
input = ApplyMeshModification(input, _TimeParameters.xyz);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ UNITY_DOTS_INSTANCING_START(BuiltinPropertyMetadata)
UNITY_DOTS_INSTANCED_PROP(float4, unity_ProbesOcclusion)
UNITY_DOTS_INSTANCED_PROP(float3x4, unity_MatrixPreviousM)
UNITY_DOTS_INSTANCED_PROP(float3x4, unity_MatrixPreviousMI)
UNITY_DOTS_INSTANCED_PROP(float4, unity_MotionVectorsParams)
UNITY_DOTS_INSTANCED_PROP(float4, unity_ComputeMeshIndex)
UNITY_DOTS_INSTANCING_END(BuiltinPropertyMetadata)

// Note: Macros for unity_ObjectToWorld and unity_WorldToObject are declared elsewhere
Expand All @@ -391,7 +393,8 @@ UNITY_DOTS_INSTANCING_END(BuiltinPropertyMetadata)
#define unity_ProbesOcclusion UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_ProbesOcclusion)
#define unity_MatrixPreviousM LoadDOTSInstancedData_float4x4_from_float3x4(UNITY_DOTS_INSTANCED_METADATA_NAME_FROM_MACRO(float3x4, Metadata_unity_MatrixPreviousM))
#define unity_MatrixPreviousMI LoadDOTSInstancedData_float4x4_from_float3x4(UNITY_DOTS_INSTANCED_METADATA_NAME_FROM_MACRO(float3x4, Metadata_unity_MatrixPreviousMI))

#define unity_MotionVectorsParams UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_MotionVectorsParams)
#define unity_ComputeMeshIndex UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO(float4, Metadata_unity_ComputeMeshIndex)
#endif

// Define View/Projection matrix macro
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,6 @@ unsafe struct ShaderVariablesGlobal
public float _GlobalTessellationFactorMultiplier;

public float _SpecularOcclusionBlend;
public float _Pad9;
public int _HybridDeformedVertexStreamIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0)
int _TransparentCameraOnlyMotionVectors;
float _GlobalTessellationFactorMultiplier;
float _SpecularOcclusionBlend;
float _Pad9;
int _HybridDeformedVertexStreamIndex;
CBUFFER_END


Expand Down
3 changes: 3 additions & 0 deletions com.unity.shadergraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Texture and SamplerState types are now HLSL structures (defined in com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl). CustomFunctionNode use of the old plain types is supported, but the user should upgrade to structures to avoid bugs.
- The shader graph inspector window will now switch to the "Node Settings" tab whenever a property/node/other selectable item in the graph is clicked on to save the user a click

### Removed
- Removed Compute Deformation Node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide the reason why? Maybe something along the lines of;
the deformed vertices will be injected without the need of the node. See X for more information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to be more descriptive. Maybe when we know which version this will land in we can link to the actual documentation page?


### Fixed
- Fixed an issue where shaders could be generated with CR/LF ("\r\n") instead of just LF ("\n") line endings [1286430]
- All textures in a ShaderGraph, even those not used, will now be pulled into an Exported Package [1283902]
Expand Down
Loading