-
Notifications
You must be signed in to change notification settings - Fork 860
[Feature] Skinned motion vectors for HDRP Hybrid #3224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
f5d9db1
58cbddd
48b1ecf
a60bccc
b6a4805
b7dd69d
81d0788
0d6a8dd
860362d
4e921d8
82ffcd8
028e908
80c2dcd
19846d9
8ee28d1
0145e4b
cf88c73
ce95d4c
fe9468e
80199e9
34db42a
2b8ea7d
ee68b60
2825bd2
69e7eae
98d986e
690298f
8716688
b84ffcf
6f3cbf1
aa24bcf
7ac5ee9
3c2a52c
808bf70
a3c3a8e
b70a82a
5d3abda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1345,6 +1345,8 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd) | |
| m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 1.0f; | ||
| } | ||
|
|
||
| m_ShaderVariablesGlobalCB._HybridDeformedVertexStreamIndex = UnityEngine.Time.frameCount % 2; | ||
|
||
|
|
||
| ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); | ||
| } | ||
|
|
||
|
|
||
| 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) | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| // x = curr frame index | ||
| // y = prev frame index | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // 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]; | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const DeformedVertexData vertexData = _DeformedMeshData[startIndex + input.vertexID]; //if vertexid defined | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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) | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // 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 | ||
|
||
| // 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; | ||
he-ax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const int currMeshStart = deformProperty[currStreamIndex]; | ||
| const int prevMeshStart = deformProperty[prevStreamIndex]; | ||
he-ax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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 |
|---|---|---|
|
|
@@ -22,7 +22,9 @@ struct AttributesMesh | |
| #ifdef ATTRIBUTES_NEED_COLOR | ||
| float4 color : COLOR; | ||
| #endif | ||
|
|
||
| #ifdef DOTS_INSTANCING_ON | ||
| uint vertexID : SV_VertexID; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. surround with dots instancing on define?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
||
|
|
||
| ### 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] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.