NLDClient-yudde/ProjectNLD/Assets/Code/Shaders/builtin_shaders-2022.3.17f1/DefaultResources/Internal-BlendShape.compute

44 lines
1.1 KiB
Plaintext

// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
#pragma kernel main
#pragma kernel main SKIN_NORM
#pragma kernel main SKIN_NORM SKIN_TANG
#include "HLSLSupport.cginc"
#include "Internal-Skinning-Util.cginc"
uint g_FirstVert; // First vertex from blend shape buffer to use
uint g_VertCount; // Sparse vertex count, not the full amount of vertices in mesh
float g_Weight;
SKINNING_GENERIC_VERTEX_RWBUFFER inOutMeshVertices;
SKINNING_GENERIC_SKIN_BUFFER_BLENDSHAPE inBlendShapeVertices;
[numthreads(64, 1, 1)]
void main(uint3 threadID : SV_DispatchThreadID)
{
const uint t = threadID.x;
if (t >= g_VertCount)
{
return;
}
BlendShapeVertex blendShapeVert = FetchBlendShape(inBlendShapeVertices, t + g_FirstVert);
const uint vertIndex = blendShapeVert.index;
MeshVertex vertex = FetchVert(inOutMeshVertices, vertIndex);
vertex.pos += blendShapeVert.pos * g_Weight;
#if SKIN_NORM
vertex.norm += blendShapeVert.norm * g_Weight;
#endif
#if SKIN_TANG
vertex.tang.xyz += blendShapeVert.tang * g_Weight;
#endif
StoreVert(inOutMeshVertices, vertex, vertIndex);
}