Netcode Bootstrap

This commit is contained in:
Luis Gonzalez
2026-05-31 14:27:52 -07:00
parent 99d8d2d2a9
commit 7fa77ce821
1813 changed files with 2921554 additions and 84 deletions
@@ -0,0 +1,11 @@
using Unity.Entities;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
public struct BoneVisualizationComponent: IComponentData
{
public float tripodSize;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3369f72f5a81f7446956bb349d2c7cc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/BoneVisualizationComponents.cs
uploadId: 897522
@@ -0,0 +1,140 @@
#if RUKHANKA_DEBUG_INFO
#if !RUKHANKA_NO_DEBUG_DRAWER
using Rukhanka.DebugDrawer;
#endif
using Rukhanka.Toolbox;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
[WorldSystemFilter(WorldSystemFilterFlags.Default)]
[UpdateInGroup(typeof(PresentationSystemGroup))]
[UpdateAfter(typeof(RukhankaDeformationSystemGroup))]
public partial class BoneVisualizationSystem: SystemBase
{
EntityQuery cpuBoneVisualizeQuery, gpuBoneVisualizeQuery;
struct GPUBoneRendererRigInfo
{
public LocalTransform rigWorldPose;
}
FrameFencedGPUBufferPool<GPUBoneRendererRigInfo> frameRigInfoCB;
internal GPUBoneRenderer gpuBoneRenderer;
/////////////////////////////////////////////////////////////////////////////////
protected override void OnCreate()
{
gpuBoneRenderer = new ();
frameRigInfoCB = new (0xff, GraphicsBuffer.Target.Structured, GraphicsBuffer.UsageFlags.LockBufferForWrite);
cpuBoneVisualizeQuery = SystemAPI.QueryBuilder()
.WithAll<RigDefinitionComponent, BoneVisualizationComponent>()
.WithNone<GPUAnimationEngineTag>()
.Build();
gpuBoneVisualizeQuery = SystemAPI.QueryBuilder()
.WithAll<RigDefinitionComponent, BoneVisualizationComponent, GPUAnimationEngineTag>()
.Build();
RequireForUpdate(cpuBoneVisualizeQuery);
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnUpdate()
{
#if !RUKHANKA_NO_DEBUG_DRAWER
Dependency = RenderBonesForCPUAnimators(Dependency);
#endif
Dependency = RenderBonesForGPUAnimators(Dependency);
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnDestroy()
{
frameRigInfoCB.Dispose();
}
/////////////////////////////////////////////////////////////////////////////////
JobHandle RenderBonesForCPUAnimators(JobHandle dependsOn)
{
if (!SystemAPI.TryGetSingletonRW<Drawer>(out var dd))
return dependsOn;
if (!SystemAPI.TryGetSingleton<RuntimeAnimationData>(out var runtimeData))
return dependsOn;
var hasDCC = SystemAPI.TryGetSingleton<DebugConfigurationComponent>(out var dcc);
var defaultColor = new float4(0, 1, 1, 1);
var boneColorLines = hasDCC ? dcc.cpuRigColor : defaultColor;
var boneColorTriangles = new float4(defaultColor.x, defaultColor.y, defaultColor.z, defaultColor.w * 0.3f);
var boneColorLinesUINT = ColorTools.ToUint(boneColorLines);
var boneColorTriUINT = ColorTools.ToUint(boneColorTriangles);
var renderBonesJob = new RenderBonesCPUAnimatorsJob()
{
bonePoses = runtimeData.worldSpaceBonesBuffer,
drawer = dd.ValueRW,
colorLines = boneColorLinesUINT,
colorTriangles = boneColorTriUINT
};
var rv = renderBonesJob.ScheduleParallel(cpuBoneVisualizeQuery, dependsOn);
return rv;
}
/////////////////////////////////////////////////////////////////////////////////
JobHandle RenderBonesForGPUAnimators(JobHandle dependsOn)
{
if (!SystemAPI.TryGetSingleton<GPURuntimeAnimationData>(out var rad))
return dependsOn;
var rigCount = (int)rad.frameAnimatedRigsCounter;
if (rigCount == 0 || gpuBoneVisualizeQuery.CalculateEntityCount() == 0)
return dependsOn;
frameRigInfoCB.Grow(rigCount);
frameRigInfoCB.BeginFrame();
var frameRigData = frameRigInfoCB.LockBufferForWrite(0, rigCount);
var prepareBoneDataJob = new PrepareGPURigsJob()
{
frameRigData = frameRigData,
localTransformLookup = SystemAPI.GetComponentLookup<LocalTransform>(true),
boneVisualizationLookup = SystemAPI.GetComponentLookup<BoneVisualizationComponent>(true),
gpuFrameOffsetsTypeHandle = SystemAPI.GetComponentTypeHandle<GPURigFrameOffsetsComponent>(true),
entityTypeHandle = SystemAPI.GetEntityTypeHandle()
};
var rv = prepareBoneDataJob.ScheduleParallel(gpuBoneVisualizeQuery, dependsOn);
rv.Complete();
frameRigInfoCB.UnlockBufferAfterWrite(rigCount);
var hasDCC = SystemAPI.TryGetSingleton<DebugConfigurationComponent>(out var dcc);
var defaultColor = new float4(0, 1, 0, 1);
var boneColor = hasDCC ? dcc.gpuRigColor : defaultColor;
gpuBoneRenderer.RenderBones(frameRigInfoCB, boneColor);
frameRigInfoCB.EndFrame();
return rv;
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7dd507e2543b16a41bd8433cfb0bd9d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/BoneVisualizationSystem.cs
uploadId: 897522
@@ -0,0 +1,107 @@
#if RUKHANKA_DEBUG_INFO
using Rukhanka.DebugDrawer;
using Unity.Burst;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
partial class BoneVisualizationSystem
{
[BurstCompile]
partial struct RenderBonesCPUAnimatorsJob: IJobEntity
{
[ReadOnly]
public NativeList<BoneTransform> bonePoses;
public uint colorTriangles;
public uint colorLines;
public Drawer drawer;
/////////////////////////////////////////////////////////////////////////////////
public void Execute(Entity e, in RigDefinitionComponent rd, in BoneVisualizationComponent bvc)
{
var bt = RuntimeAnimationData.GetAnimationDataForRigRO(bonePoses, rd);
var len = bt.Length;
for (int l = rd.rigBlob.Value.rootBoneIndex; l < len; ++l)
{
ref var rb = ref rd.rigBlob.Value.bones[l];
if (rb.parentBoneIndex < 0)
continue;
var bonePose0 = bt[l];
var bonePose1 = bt[rb.parentBoneIndex];
if (math.any(math.abs(bonePose0.pos - bonePose1.pos)))
{
drawer.DrawBoneMesh(bonePose0.pos, bonePose1.pos, colorTriangles, colorLines);
if (bvc.tripodSize > 0)
{
var fwd = math.rotate(bonePose0.rot, math.forward()) * bvc.tripodSize;
var left = math.rotate(bonePose0.rot, math.up()) * bvc.tripodSize;
var up = math.rotate(bonePose0.rot, math.left()) * bvc.tripodSize;
drawer.DrawLine(bonePose0.pos, bonePose0.pos + fwd, 0x0000ffff);
drawer.DrawLine(bonePose0.pos, bonePose0.pos + up, 0x00ff00ff);
drawer.DrawLine(bonePose0.pos, bonePose0.pos + left, 0xff0000ff);
}
}
}
}
}
//------------------------------------------------------------------------------//
[BurstCompile]
struct PrepareGPURigsJob: IJobChunk
{
[ReadOnly]
public ComponentLookup<LocalTransform> localTransformLookup;
[ReadOnly]
public ComponentLookup<BoneVisualizationComponent> boneVisualizationLookup;
[ReadOnly]
public ComponentTypeHandle<GPURigFrameOffsetsComponent> gpuFrameOffsetsTypeHandle;
[ReadOnly]
public EntityTypeHandle entityTypeHandle;
[NativeDisableParallelForRestriction]
public NativeArray<GPUBoneRendererRigInfo> frameRigData;
/////////////////////////////////////////////////////////////////////////////////
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
var entityFrameOffsets = chunk.GetNativeArray(ref gpuFrameOffsetsTypeHandle);
var chunkFrameOffsets = chunk.GetChunkComponentData(ref gpuFrameOffsetsTypeHandle);
var entities = chunk.GetNativeArray(entityTypeHandle);
var cee = new ChunkEntityEnumerator(useEnabledMask, chunkEnabledMask, chunk.Count);
while (cee.NextEntityIndex(out var i))
{
var e = entities[i];
var gpuFrameOffsets = entityFrameOffsets[i];
gpuFrameOffsets.AddOffsets(chunkFrameOffsets);
var rigInfo = new GPUBoneRendererRigInfo();
if (boneVisualizationLookup.HasComponent(e))
{
localTransformLookup.TryGetComponent(e, out rigInfo.rigWorldPose);
}
frameRigData[gpuFrameOffsets.rigIndex] = rigInfo;
}
}
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 60e8486aa5dd60a42913c3cb62d3135d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/BoneVisualizationSystem_Jobs.cs
uploadId: 897522
@@ -0,0 +1,40 @@
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine.Serialization;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
public struct DebugConfigurationComponent: IComponentData
{
public static readonly float4 CPU_RIG_COLOR = new (0, 1, 0, 1);
public static readonly float4 GPU_RIG_COLOR = new (0, 1, 1, 1);
public static readonly float4 STATIC_BOUNDS_COLOR = new (1, 1, 1, 1);
public static readonly float4 DYNAMIC_BOUNDS_COLOR = new (0.0f, 0.7490196f, 1f, 1f);
public bool visualizeAllRigs;
public float4 cpuRigColor;
public float4 gpuRigColor;
public bool visualizeMeshBounds;
public float4 staticMeshBoundsColor;
public float4 dynamicMeshBoundsColor;
/////////////////////////////////////////////////////////////////////////////////
public static DebugConfigurationComponent Default()
{
var rv = new DebugConfigurationComponent()
{
cpuRigColor = CPU_RIG_COLOR,
gpuRigColor = GPU_RIG_COLOR,
staticMeshBoundsColor = STATIC_BOUNDS_COLOR,
dynamicMeshBoundsColor = DYNAMIC_BOUNDS_COLOR,
};
return rv;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8d752df0661bb744a9d199bb8dbda0ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/DebugConfigurationSingleton.cs
uploadId: 897522
@@ -0,0 +1,95 @@
#if RUKHANKA_DEBUG_INFO
using Rukhanka.DebugDrawer;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
public class GPUBoneRenderer
{
Material boneDrawerMat;
Mesh boneMesh;
readonly int ShaderID_animatedBoneWorkload = Shader.PropertyToID("animatedBoneWorkload");
readonly int ShaderID_animationJobs = Shader.PropertyToID("animationJobs");
readonly int ShaderID_rigDefinitions = Shader.PropertyToID("rigDefinitions");
readonly int ShaderID_rigBones = Shader.PropertyToID("rigBones");
readonly int ShaderID_rigSpaceBoneTransforms = Shader.PropertyToID("rigSpaceBoneTransforms");
readonly int ShaderID_rigVisualizationData = Shader.PropertyToID("rigVisualizationData");
GraphicsBuffer framePerBoneAnimationWorkloadGB;
GraphicsBuffer frameRigAnimationJobsGB;
GraphicsBuffer rigDefinitionGB;
GraphicsBuffer rigBonesGB;
GraphicsBuffer rigSpaceAnimatedBonesGB;
int frameAnimatedBonesCount;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public GPUBoneRenderer()
{
boneDrawerMat = CoreUtils.CreateEngineMaterial(Shader.Find($"BoneRendererGPU"));
boneDrawerMat.enableInstancing = true;
boneMesh = DrawerManagedSingleton.CreateBoneMesh();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void SetGPUBuffersForFrame
(
GraphicsBuffer framePerBoneAnimationWorkloadGB,
GraphicsBuffer frameRigAnimationJobsGB,
GraphicsBuffer rigDefinitionGB,
GraphicsBuffer rigBonesGB,
GraphicsBuffer rigSpaceAnimatedBonesGB,
int frameAnimatedBonesCount
)
{
this.framePerBoneAnimationWorkloadGB = framePerBoneAnimationWorkloadGB;
this.frameRigAnimationJobsGB = frameRigAnimationJobsGB;
this.rigDefinitionGB = rigDefinitionGB;
this.rigBonesGB = rigBonesGB;
this.rigSpaceAnimatedBonesGB = rigSpaceAnimatedBonesGB;
this.frameAnimatedBonesCount = frameAnimatedBonesCount;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void RenderBones(GraphicsBuffer rigVisualizationDataGB, float4 boneColor)
{
var rp = new RenderParams();
rp.camera = null;
rp.layer = 0;
rp.lightProbeProxyVolume = null;
rp.lightProbeUsage = LightProbeUsage.Off;
rp.motionVectorMode = MotionVectorGenerationMode.ForceNoMotion;
rp.receiveShadows = false;
rp.reflectionProbeUsage = ReflectionProbeUsage.Off;
rp.rendererPriority = 0;
rp.renderingLayerMask = 0xffffffff;
rp.shadowCastingMode = ShadowCastingMode.Off;
rp.worldBounds = new Bounds(Vector3.zero, Vector3.one * 100000);
rp.matProps = new MaterialPropertyBlock();
rp.matProps.SetBuffer(ShaderID_animatedBoneWorkload, framePerBoneAnimationWorkloadGB);
rp.matProps.SetBuffer(ShaderID_animationJobs, frameRigAnimationJobsGB);
rp.matProps.SetBuffer(ShaderID_rigDefinitions, rigDefinitionGB);
rp.matProps.SetBuffer(ShaderID_rigBones, rigBonesGB);
rp.matProps.SetBuffer(ShaderID_rigSpaceBoneTransforms, rigSpaceAnimatedBonesGB);
rp.matProps.SetBuffer(ShaderID_rigVisualizationData, rigVisualizationDataGB);
rp.material = boneDrawerMat;
rp.matProps.SetVector("boneColor", boneColor);
Graphics.RenderMeshPrimitives(rp, boneMesh, 1, frameAnimatedBonesCount);
boneColor.w = 0.3f;
rp.matProps.SetVector("boneColor", boneColor);
Graphics.RenderMeshPrimitives(rp, boneMesh, 0, frameAnimatedBonesCount);
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a834de16146d78140a220115b0aac106
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/GPUBoneRenderer.cs
uploadId: 897522
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1381c18820adb254d9208671c3cb35ca
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,66 @@
#ifndef BONE_RENDERER_GPU_HLSL_
#define BONE_RENDERER_GPU_HLSL_
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#ifdef IS_HDRP
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightDefinition.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl"
#endif
/////////////////////////////////////////////////////////////////////////////////
#include "Packages/com.rukhanka.animation/Rukhanka.DebugDrawer/Resources/RukhankaBoneRenderer.hlsl"
#include "Packages/com.rukhanka.animation/Rukhanka.Runtime/GPUAnimationEngine/Resources/GPUStructures.hlsl"
StructuredBuffer<BoneTransform> rigSpaceBoneTransforms;
struct RigVisInfo
{
float3 pos;
float scale;
float4 rot;
};
StructuredBuffer<RigVisInfo> rigVisualizationData;
float4 boneColor;
/////////////////////////////////////////////////////////////////////////////////
VertexToPixel VSGPUAnimator(VertexInput i)
{
VertexToPixel o = (VertexToPixel)0;
AnimatedBoneWorkload boneWorkload = animatedBoneWorkload[i.instanceID];
AnimationJob animationJob = animationJobs[boneWorkload.animationJobIndex];
RigDefinition rigDef = RigDefinition::ReadFromRawBuffer(rigDefinitions, animationJob.rigDefinitionIndex);
RigBone rigBone = RigBone::ReadFromRawBuffer(rigBones, rigDef.rigBonesRange.x + boneWorkload.boneIndexInRig);
int parentBoneIndex = rigBone.parentBoneIndex;
if (parentBoneIndex < rigDef.rootBoneIndex)
return o;
BoneData bd;
RigVisInfo rvi = rigVisualizationData[boneWorkload.animationJobIndex];
int boneId = animationJob.animatedBoneIndexOffset + boneWorkload.boneIndexInRig;
bd.pos0 = rigSpaceBoneTransforms[boneId].pos;
if (parentBoneIndex >= 0)
bd.pos1 = rigSpaceBoneTransforms[animationJob.animatedBoneIndexOffset + parentBoneIndex].pos;
float3 worldPos = ComputeVertexWorldPos(bd, i.pos, i.vertexID);
BoneTransform entityPose;
entityPose.pos = rvi.pos;
entityPose.scale = rvi.scale;
entityPose.rot.value = rvi.rot;
worldPos = BoneTransform::TransformPoint(entityPose, worldPos);
worldPos = GetCameraRelativePositionWS(worldPos);
o.pos = mul(unity_MatrixVP, float4(worldPos, 1));
o.color = boneColor;
return o;
}
#endif
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 27c1027c96c0de44cb7d0cd95c1edd82
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/Resources/BoneRendererGPU.hlsl
uploadId: 897522
@@ -0,0 +1,75 @@
Shader "BoneRendererGPU"
{
SubShader
{
PackageRequirements
{
"com.unity.render-pipelines.high-definition": "1.0.0"
}
Tags
{
"RenderPipeline" = "HDRenderPipeline"
"RenderType" = "HDUnlitShader"
"Queue" = "Transparent+0"
}
Pass
{
Name "ForwardOnly"
Tags
{
"LightMode" = "ForwardOnly"
}
Blend SrcAlpha OneMinusSrcAlpha
ZTest off
HLSLPROGRAM
#pragma target 5.0
#pragma vertex VSGPUAnimator
#pragma fragment PS
#define IS_HDRP
#include "BoneRendererGPU.hlsl"
ENDHLSL
}
}
/////////////////////////////////////////////////////////////////////////////////
SubShader
{
PackageRequirements
{
"com.unity.render-pipelines.universal": "1.0.0"
}
Tags
{
"RenderPipeline"="UniversalPipeline"
"Queue" = "Transparent+0"
}
Pass
{
Tags
{
"LightMode" = "UniversalForward"
}
Blend SrcAlpha OneMinusSrcAlpha
ZTest off
HLSLPROGRAM
#pragma target 5.0
#pragma vertex VSGPUAnimator
#pragma fragment PS
#include "BoneRendererGPU.hlsl"
ENDHLSL
}
}
}
@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: 53e554c5c17b29f4ebb95370af0ddd20
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/Resources/BoneRendererGPU.shader
uploadId: 897522
@@ -0,0 +1,75 @@
#if RUKHANKA_SHADER_DEBUG
using System;
using Unity.Entities;
using UnityEngine;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
[WorldSystemFilter(WorldSystemFilterFlags.Default | WorldSystemFilterFlags.Editor)]
[UpdateInGroup(typeof(RukhankaDeformationSystemGroup), OrderLast = true)]
public partial class ShaderDebugAndValidationSystem: SystemBase
{
/////////////////////////////////////////////////////////////////////////////////
protected override void OnUpdate()
{
for (var i = 0; i < ShaderDebugAndValidationInitSystem.debugLoggerReadbackData.Length; ++i)
{
var errorsCount = ShaderDebugAndValidationInitSystem.debugLoggerReadbackData[i];
if (errorsCount == 0)
continue;
var dm = (RukhankaDebugMarkers)i;
Debug.LogException(new Exception($"Shader Validation: '{dm.ToString()}' marker error count '{errorsCount}'"));
}
}
}
//-------------------------------------------------------------------------------//
[WorldSystemFilter(WorldSystemFilterFlags.Default | WorldSystemFilterFlags.Editor)]
[UpdateInGroup(typeof(InitializationSystemGroup), OrderFirst = true)]
internal partial class ShaderDebugAndValidationInitSystem: SystemBase
{
public static GraphicsBuffer debugLoggerCB;
public static int[] debugLoggerReadbackData;
public static int[] debugLoggerZeroData;
static readonly int ShaderID_debugLoggerCB = Shader.PropertyToID("debugLoggerCB");
/////////////////////////////////////////////////////////////////////////////////
protected override void OnCreate()
{
var totalMarkers = (int)RukhankaDebugMarkers.Total;
debugLoggerReadbackData = new int[totalMarkers];
debugLoggerZeroData = new int[totalMarkers];
debugLoggerCB = new GraphicsBuffer(GraphicsBuffer.Target.Structured, GraphicsBuffer.UsageFlags.None, totalMarkers, sizeof(int));
debugLoggerCB.SetData(debugLoggerZeroData);
Shader.SetGlobalBuffer(ShaderID_debugLoggerCB, debugLoggerCB);
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnUpdate()
{
Shader.SetGlobalBuffer(ShaderID_debugLoggerCB, debugLoggerCB);
debugLoggerCB.GetData(debugLoggerReadbackData);
debugLoggerCB.SetData(debugLoggerZeroData);
}
/////////////////////////////////////////////////////////////////////////////////
protected override void OnDestroy()
{
if (debugLoggerCB != null)
debugLoggerCB.Dispose();
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 93c556d11524b8b49b51197a53a0d570
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/ShaderDebugAndValidationSystem.cs
uploadId: 897522
@@ -0,0 +1,48 @@
#if RUKHANKA_DEBUG_INFO
#if !RUKHANKA_NO_DEBUG_DRAWER
using Rukhanka.DebugDrawer;
#endif
using Unity.Entities;
using Unity.Rendering;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
[WorldSystemFilter(WorldSystemFilterFlags.Default)]
[UpdateInGroup(typeof(PresentationSystemGroup))]
[UpdateAfter(typeof(RukhankaDeformationSystemGroup))]
public partial struct SkinnedMeshBoundsVisualizationSystem: ISystem
{
EntityQuery skinnedMeshQuery;
/////////////////////////////////////////////////////////////////////////////////
public void OnUpdate(ref SystemState ss)
{
if (!SystemAPI.TryGetSingletonRW<Drawer>(out var dRef))
return;
if (!SystemAPI.TryGetSingleton<DebugConfigurationComponent>(out var debugConfig))
return;
if (!debugConfig.visualizeMeshBounds)
return;
var shouldUpdateBoundingBoxTagLookup = SystemAPI.GetComponentLookup<ShouldUpdateBoundingBoxTag>(true);
var renderSkinnedMeshBoundsJob = new RenderSkinnedMeshBoundsJob()
{
shouldUpdateBoundingBoxTagLookup = shouldUpdateBoundingBoxTagLookup,
dcc = debugConfig,
dd = dRef.ValueRW
};
ss.Dependency = renderSkinnedMeshBoundsJob.ScheduleParallel(ss.Dependency);
}
}
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 61a9c2a4d4c3a954084ee62994a71f59
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/SkinnedMeshBoundsVisualizationSystem.cs
uploadId: 897522
@@ -0,0 +1,42 @@
#if RUKHANKA_DEBUG_INFO
/////////////////////////////////////////////////////////////////////////////////
#if !RUKHANKA_NO_DEBUG_DRAWER
using Rukhanka.DebugDrawer;
using Rukhanka.Toolbox;
#endif
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Rendering;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka
{
public partial struct SkinnedMeshBoundsVisualizationSystem
{
partial struct RenderSkinnedMeshBoundsJob: IJobEntity
{
public Drawer dd;
public DebugConfigurationComponent dcc;
[ReadOnly]
public ComponentLookup<ShouldUpdateBoundingBoxTag> shouldUpdateBoundingBoxTagLookup;
void Execute(Entity e, WorldRenderBounds wrb, SkinnedMeshRendererComponent smrc)
{
var transform = new RigidTransform(quaternion.identity, wrb.Value.Center);
var color = shouldUpdateBoundingBoxTagLookup.HasComponent(e) ? dcc.dynamicMeshBoundsColor : dcc.staticMeshBoundsColor;
dd.DrawWireCuboid(wrb.Value.Size, ColorTools.ToUint(color), transform);
}
}
}
}
/////////////////////////////////////////////////////////////////////////////////
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9dd8e0cd878969445b6a8901d1a5d0d9
AssetOrigin:
serializedVersion: 1
productId: 298480
packageName: Rukhanka Animation System 2
packageVersion: 2.9.0
assetPath: Packages/com.rukhanka.animation/Rukhanka.Runtime/DebugAndVisualization/SkinnedMeshBoundsVisualizationSystem_Jobs.cs
uploadId: 897522