浏览代码

Merge pull request #23 from Unity-Technologies/skinned_mesh_support

Skinned mesh support
/main
GitHub 4 年前
当前提交
7ca1799d
共有 10 个文件被更改,包括 46 次插入32 次删除
  1. 34
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  2. 2
      com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs
  3. 13
      com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs
  4. 2
      com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs
  5. 4
      com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs
  6. 2
      com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs
  7. 2
      com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs
  8. 2
      com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs
  9. 2
      com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs
  10. 15
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs

34
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity


m_Component:
- component: {fileID: 1640252283}
- component: {fileID: 1640252282}
- component: {fileID: 1640252281}
- component: {fileID: 1640252280}
- component: {fileID: 1640252280}
m_Layer: 0
m_Name: Box
m_TagString: Untagged

m_EditorClassIdentifier:
labels:
- Box
--- !u!65 &1640252280
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1640252281
MeshRenderer:
--- !u!137 &1640252280
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
serializedVersion: 2
m_Quality: 0
m_UpdateWhenOffscreen: 0
m_SkinnedMotionVectors: 1
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
m_Bones: []
m_BlendShapeWeights: []
m_RootBone: {fileID: 0}
m_AABB:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0.5, y: 0.5, z: 0.5}
m_DirtyAABB: 0
--- !u!33 &1640252282
MeshFilter:
m_ObjectHideFlags: 0

2
com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs


}
}
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId);
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer meshRenderer, Labeling labeling, uint instanceId);
}
}

13
com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs


void InitGameObjectRecursive(GameObject gameObject, MaterialPropertyBlock mpb, Labeling labeling, uint instanceId)
{
var meshRenderer = gameObject.GetComponent<MeshRenderer>();
if (meshRenderer != null)
var renderer = (Renderer)gameObject.GetComponent<MeshRenderer>();
if (renderer == null)
renderer = gameObject.GetComponent<SkinnedMeshRenderer>();
if (renderer != null)
meshRenderer.GetPropertyBlock(mpb);
renderer.GetPropertyBlock(mpb);
pass.SetupMaterialProperties(mpb, meshRenderer, labeling, instanceId);
pass.SetupMaterialProperties(mpb, renderer, labeling, instanceId);
meshRenderer.SetPropertyBlock(mpb);
renderer.SetPropertyBlock(mpb);
}
for (var i = 0; i < gameObject.transform.childCount; i++)

2
com.unity.perception/Runtime/GroundTruth/GroundTruthPass.cs


public Camera targetCamera;
bool m_IsActivated;
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId);
public abstract void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer meshRenderer, Labeling labeling, uint instanceId);
protected GroundTruthPass(Camera targetCamera)
{

4
com.unity.perception/Runtime/GroundTruth/IGroundTruthGenerator.cs


/// Called by <see cref="GroundTruthLabelSetupSystem"/> when first registered or when a Labeling is created at runtime.
/// </summary>
/// <param name="mpb">The MaterialPropertyBlock for the given meshRenderer. Can be used to set properties for custom rendering.</param>
/// <param name="meshRenderer">The MeshRenderer which exists under the given Labeling.</param>
/// <param name="renderer">The Renderer under the given Labeling.</param>
void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId);
void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId);
}
}

2
com.unity.perception/Runtime/GroundTruth/InstanceSegmentationCrossPipelinePass.cs


}
}
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId)
{
mpb.SetInt(k_SegmentationIdProperty, (int)instanceId);
#if PERCEPTION_DEBUG

2
com.unity.perception/Runtime/GroundTruth/ObjectCountPass.cs


{
}
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer meshRenderer, Labeling labeling, uint instanceId)
{
if (!m_InstanceIdToLabelIndexLookup.IsCreated)
{

2
com.unity.perception/Runtime/GroundTruth/RenderedObjectInfoGenerator.cs


}
/// <inheritdoc/>
public void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
public void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId)
{
if (m_LabelingConfiguration.TryGetMatchingConfigurationEntry(labeling, out _, out var index))
{

2
com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs


DrawRendererList(renderContext, cmd, RendererList.Create(renderList));
}
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, MeshRenderer meshRenderer, Labeling labeling, uint instanceId)
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId)
{
var entry = new LabelEntry();
foreach (var l in m_LabelingConfiguration.LabelEntries)

15
com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs


// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame.
[UnityTest]
public IEnumerator SegmentationPassTestsWithEnumeratorPasses()
public IEnumerator SegmentationPassTestsWithEnumeratorPasses([Values(false, true)] bool useSkinnedMeshRenderer)
{
int timesSegmentationImageReceived = 0;
int? frameStart = null;

//Put a plane in front of the camera
var planeObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
if (useSkinnedMeshRenderer)
{
var oldObject = planeObject;
planeObject = new GameObject();
var meshFilter = oldObject.GetComponent<MeshFilter>();
var meshRenderer = oldObject.GetComponent<MeshRenderer>();
var skinnedMeshRenderer = planeObject.AddComponent<SkinnedMeshRenderer>();
skinnedMeshRenderer.sharedMesh = meshFilter.sharedMesh;
skinnedMeshRenderer.material = meshRenderer.material;
Object.DestroyImmediate(oldObject);
}
planeObject.transform.SetPositionAndRotation(new Vector3(0, 0, 10), Quaternion.Euler(90, 0, 0));
planeObject.transform.localScale = new Vector3(10, -1, 10);
planeObject.AddComponent<Labeling>();

正在加载...
取消
保存