浏览代码

merging from master and resolving merger conflicts

/with_cloud_tests
Priyesh Wani 4 年前
当前提交
f8b8eaeb
共有 269 个文件被更改,包括 5091 次插入575 次删除
  1. 13
      .github/pull_request_template.md
  2. 15
      .yamato/environments.yml
  3. 8
      .yamato/promote.yml
  4. 2
      .yamato/publish.yml
  5. 49
      .yamato/upm-ci-full.yml
  6. 8
      .yamato/upm-ci-testprojects.yml
  7. 15
      README.md
  8. 6
      TestProjects/PerceptionHDRP/Packages/manifest.json
  9. 12
      TestProjects/PerceptionHDRP/Packages/packages-lock.json
  10. 5
      TestProjects/PerceptionHDRP/ProjectSettings/ProjectSettings.asset
  11. 4
      TestProjects/PerceptionHDRP/ProjectSettings/ProjectVersion.txt
  12. 60
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  13. 6
      TestProjects/PerceptionURP/Packages/manifest.json
  14. 12
      TestProjects/PerceptionURP/Packages/packages-lock.json
  15. 37
      TestProjects/PerceptionURP/ProjectSettings/ProjectSettings.asset
  16. 4
      TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt
  17. 43
      com.unity.perception/CHANGELOG.md
  18. 13
      com.unity.perception/Documentation~/PerceptionCamera.md
  19. 3
      com.unity.perception/Documentation~/TableOfContents.md
  20. 9
      com.unity.perception/Documentation~/index.md
  21. 2
      com.unity.perception/Editor/GroundTruth/CameraLabelerDrawer.cs
  22. 87
      com.unity.perception/Editor/GroundTruth/LabelingEditor.cs
  23. 12
      com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
  24. 3
      com.unity.perception/Editor/Unity.Perception.Editor.asmdef
  25. 23
      com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
  26. 2
      com.unity.perception/Runtime/GroundTruth/GroundTruthCrossPipelinePass.cs
  27. 20
      com.unity.perception/Runtime/GroundTruth/GroundTruthLabelSetupSystem.cs
  28. 26
      com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs
  29. 107
      com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
  30. 82
      com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs
  31. 32
      com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs
  32. 34
      com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs
  33. 141
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  34. 167
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs
  35. 23
      com.unity.perception/Runtime/GroundTruth/Labeling/IdLabelEntry.cs
  36. 9
      com.unity.perception/Runtime/GroundTruth/Labeling/LabelEntryMatchCache.cs
  37. 22
      com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs
  38. 197
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
  39. 54
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera_InstanceSegmentation.cs
  40. 11
      com.unity.perception/Runtime/GroundTruth/Resources/InstanceSegmentation.shader
  41. 18
      com.unity.perception/Runtime/GroundTruth/Resources/LabeledObjectHistogram.compute
  42. 21
      com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader
  43. 10
      com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs
  44. 67
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs
  45. 6
      com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs
  46. 19
      com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs
  47. 64
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs
  48. 6
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs.meta
  49. 46
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs
  50. 6
      com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs.meta
  51. 50
      com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
  52. 161
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
  53. 24
      com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs
  54. 152
      com.unity.perception/Tests/Runtime/GroundTruthTests/VisualizationTests.cs
  55. 16
      com.unity.perception/package.json
  56. 984
      TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion.unity
  57. 7
      TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion.unity.meta
  58. 8
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.meta
  59. 8
      TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.meta
  60. 840
      TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.unity
  61. 7
      TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.unity.meta
  62. 31
      TestProjects/PerceptionURP/Assets/TestMpbPerMaterial.cs
  63. 11
      TestProjects/PerceptionURP/Assets/TestMpbPerMaterial.cs.meta
  64. 8
      com.unity.perception/Editor/Randomization.meta
  65. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/solid_white.png
  66. 104
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/solid_white.png.meta
  67. 8
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Shaders.meta
  68. 200
      com.unity.perception/Runtime/GroundTruth/LensDistortionCrossPipelinePass.cs
  69. 3
      com.unity.perception/Runtime/GroundTruth/LensDistortionCrossPipelinePass.cs.meta
  70. 54
      com.unity.perception/Runtime/GroundTruth/LensDistortionPass.cs
  71. 3
      com.unity.perception/Runtime/GroundTruth/LensDistortionPass.cs.meta
  72. 98
      com.unity.perception/Runtime/GroundTruth/Resources/LensDistortion.shader
  73. 9
      com.unity.perception/Runtime/GroundTruth/Resources/LensDistortion.shader.meta
  74. 50
      com.unity.perception/Runtime/GroundTruth/Resources/Packing.hlsl
  75. 3
      com.unity.perception/Runtime/GroundTruth/Resources/Packing.hlsl.meta
  76. 8
      com.unity.perception/Runtime/Randomization.meta
  77. 93
      com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs
  78. 11
      com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs.meta
  79. 8
      com.unity.perception/Tests/Runtime/Randomization.meta
  80. 53
      TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset
  81. 53
      TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset
  82. 8
      TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset.meta
  83. 85
      com.unity.perception/Documentation~/Randomization/Images/ColorParameter.png
  84. 206
      com.unity.perception/Documentation~/Randomization/Images/ParameterConfiguration.png
  85. 101
      com.unity.perception/Documentation~/Randomization/Images/TestScenario.png
  86. 93
      com.unity.perception/Documentation~/Randomization/Images/TutorialBuild.png
  87. 90
      com.unity.perception/Documentation~/Randomization/Parameters.md
  88. 87
      com.unity.perception/Documentation~/Randomization/Samplers.md
  89. 32
      com.unity.perception/Documentation~/Randomization/Scenarios.md
  90. 182
      com.unity.perception/Documentation~/Randomization/Tutorial.md
  91. 69
      com.unity.perception/Documentation~/Randomization/Index.md
  92. 3
      com.unity.perception/Editor/Randomization/CategoricalOptionElement.cs.meta

13
.github/pull_request_template.md


## Dev Testing:
**Tests Added**:
<br>
**Package Tests (Pass/Fail)**:
[X] - Make sure automation passes
<br>
<br>
<br>
## Checklist
- [ ] - Updated docs
- [ ] - Updated changelog

15
.yamato/environments.yml


upmci_registry: https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
test_editors:
- version: 2019.3.15f1
# sticking to 2019.4.6f1 for testing for now because Linux Editor fails to open PerceptionHDRP on 2019.4.8f1
# see https://fogbugz.unity3d.com/default.asp?1273518_d68j5lb6eucglb84
coverage_editors:
- version: 2019.4.6f1
per_commit_editors:
- version: 2019.4.6f1
publish_editors:
- version: 2019.3.15f1
complete_editors:
- version: 2019.4.6f1
- version: 2020.1.3f1
# - version: 2020.2.0a21
publish_platforms:
- name: win

8
.yamato/promote.yml


---
{% for variant in package_variants %}
{% for editor in test_editors %}
{% for editor in complete_editors %}
name : Package tests ({{variant.name}} pkg, {{ editor.version }}, {{ platform.name }})
name : Package promotion tests ({{variant.name}} pkg, {{ editor.version }}, {{ platform.name }})
agent:
type: {{ platform.type }}
image: {{ platform.image }}

promotion_test_trigger:
name: Promotion Tests Trigger
dependencies:
{% for editor in publish_editors %}
{% for editor in complete_editors %}
{% for platform in publish_platforms %}
{% for suite in suites %}
{% for project in projects %}

- "upm-ci~/packages/*.tgz"
dependencies:
{% for variant in package_variants %}
{% for editor in publish_editors %}
{% for editor in complete_editors %}
{% for platform in publish_platforms %}
- .yamato/upm-ci-full.yml#pack_{{ variant.name }}
- .yamato/promote.yml#promotion_test_{{ platform.name }}_{{ editor.version }}

2
.yamato/publish.yml


- "upm-ci~/packages/*.tgz"
dependencies:
- .yamato/upm-ci-full.yml#pack_Perception
{% for editor in publish_editors %}
{% for editor in complete_editors %}
{% for platform in publish_platforms %}
{% for suite in suites %}
{% for project in projects %}

49
.yamato/upm-ci-full.yml


{% endfor %}
{% for variant in package_variants %}
{% for editor in test_editors %}
{% for editor in complete_editors %}
{% for platform in test_platforms %}
pkg_test_{{variant.name}}_{{ platform.name }}_{{ editor.version }}:
name : Package tests ({{variant.name}} pkg, {{ editor.version }}, {{ platform.name }})

{% endfor %}
test_trigger:
name: All Tests
name: Per Commit Tests
agent:
type: Unity::VM
image: package-ci/win10:stable

branches:
only:
- "/.*/"
cancel_old_ci: true
artifacts:
logs:
paths:
- "upm-ci~/test-results/**/*"
packages:
paths:
- "upm-ci~/packages/**/*"
dependencies:
{% for variant in package_variants %}
{% for editor in per_commit_editors %}
{% for platform in test_platforms %}
- .yamato/upm-ci-full.yml#pkg_test_{{variant.name}}_{{platform.name}}_{{editor.version}}
{% endfor %}
{% endfor %}
{% endfor %}
{% for editor in coverage_editors %}
- .yamato/upm-ci-testprojects.yml#codecoverage_windows_editmode_{{editor.version}}
{% endfor %}
{% for editor in per_commit_editors %}
{% for project in projects %}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_windows_standalone_{{editor.version}}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_linux_standalone_{{editor.version}}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_windows_editmode_{{editor.version}}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_linux_editmode_{{editor.version}}
{% endfor %}
{% endfor %}
all_tests:
name: Complete Tests
agent:
type: Unity::VM
image: package-ci/win10:stable
flavor: b1.small
commands:
- dir
triggers:
recurring:
- branch: master
frequency: daily # Should run between midnight and 6AM UTC

- "upm-ci~/packages/**/*"
dependencies:
{% for variant in package_variants %}
{% for editor in test_editors %}
{% for editor in complete_editors %}
{% for platform in test_platforms %}
- .yamato/upm-ci-full.yml#pkg_test_{{variant.name}}_{{platform.name}}_{{editor.version}}
{% endfor %}

# Disabling trigger of standalone tests which aren't working at the moment
{% for editor in test_editors %}
{% for editor in coverage_editors %}
{% endfor %}
{% for editor in complete_editors %}
{% for project in projects %}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_windows_standalone_{{editor.version}}
- .yamato/upm-ci-testprojects.yml#{{project.name}}_linux_standalone_{{editor.version}}

8
.yamato/upm-ci-testprojects.yml


---
{% for editor in test_editors %}
{% for editor in complete_editors %}
{% for suite in suites %}
{% for project in projects %}
{{project.name}}_windows_{{suite.name}}_{{editor.version}}:

{% endfor %}
{% endfor %}
{% for editor in test_editors %}
{% for editor in coverage_editors %}
{% for suite in suites %}
codecoverage_windows_{{suite.name}}_{{editor.version}}:
name : CodeCoverage {{ suite.display_name }} tests ({{ editor.version }}, Windows)

{% endfor %}
{% endfor %}
{% for editor in test_editors %}
{% for editor in complete_editors %}
{% for suite in suites %}
{% for project in projects %}
{{project.name}}_linux_{{suite.name}}_{{editor.version}}:

# Not including OSX because the only OSX platform on Bokken with a GPU is a Mac Mini, of which there are only a few and setting up Yamato jobs is very complicated.
# {% for variant in package_variants %}
# {% for editor in test_editors %}
# {% for editor in complete_editors %}
# code_coverage_win_{{editor.version}}:
# name: Code Coverage Report - Windows
# agent:

15
README.md


> com.unity.perception is in active development. Its features and API are subject to significant change as development progresses.
## Documenation
## Documentation
[Randomizing your simulation](com.unity.perception/Documentation~/Randomization/Index.md)
## Local development
The repository includes two projects for local development in `TestProjects` folder, one set up for HDRP and the other for URP.

## License
* [License](com.unity.perception/LICENSE.md)
## Citation
If you find this package useful, consider citing it using:
```
@misc{com.unity.perception2020,
title={Unity {P}erception Package},
author={{Unity Technologies}},
howpublished={\url{https://github.com/Unity-Technologies/com.unity.perception}},
year={2020}
}
```

6
TestProjects/PerceptionHDRP/Packages/manifest.json


"com.unity.perception": "file:../../../com.unity.perception",
"com.unity.render-pipelines.core": "7.3.1",
"com.unity.render-pipelines.high-definition": "7.3.1",
"com.unity.simulation.capture": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.17",
"com.unity.test-framework": "1.1.14",
"com.unity.simulation.capture": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.19",
"com.unity.test-framework": "1.1.16",
"com.unity.testtools.codecoverage": "0.2.2-preview",
"com.unity.textmeshpro": "2.0.1",
"com.unity.ugui": "1.0.0",

12
TestProjects/PerceptionHDRP/Packages/packages-lock.json


"com.unity.nuget.newtonsoft-json": "1.1.2",
"com.unity.render-pipelines.core": "7.1.6",
"com.unity.entities": "0.8.0-preview.8",
"com.unity.simulation.capture": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.17"
"com.unity.simulation.capture": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.19"
}
},
"com.unity.platforms": {

"url": "https://packages.unity.com"
},
"com.unity.simulation.capture": {
"version": "0.0.10-preview.10",
"version": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.17"
"com.unity.simulation.core": "0.0.10-preview.19"
"version": "0.0.10-preview.17",
"version": "0.0.10-preview.19",
"depth": 0,
"source": "registry",
"dependencies": {},

"version": "1.1.14",
"version": "1.1.16",
"depth": 0,
"source": "registry",
"dependencies": {

5
TestProjects/PerceptionHDRP/ProjectSettings/ProjectSettings.asset


useOnDemandResources: 0
accelerometerFrequency: 60
companyName: DefaultCompany
productName: UnityTestFramework
productName: PerceptionHDRP
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}

ps4ShareFilePath:
ps4ShareOverlayImagePath:
ps4PrivacyGuardImagePath:
ps4ExtraSceSysFile:
ps4NPtitleDatPath:
ps4RemotePlayKeyAssignment: -1
ps4RemotePlayKeyMappingDir:

ps4disableAutoHideSplash: 0
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4attribVROutputEnabled: 0

4
TestProjects/PerceptionHDRP/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.7f1
m_EditorVersionWithRevision: 2019.4.7f1 (e992b1a16e65)
m_EditorVersion: 2019.4.8f1
m_EditorVersionWithRevision: 2019.4.8f1 (60781d942082)

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


- component: {fileID: 411238278}
- component: {fileID: 411238277}
- component: {fileID: 411238282}
- component: {fileID: 411238283}
m_Layer: 0
m_Name: Crate
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!114 &411238283
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 695e410829600ff40bcdd76fa0818f6a, type: 3}
m_Name:
m_EditorClassIdentifier:
materialPropertyTarget: 1
color: {r: 0.745283, g: 0.40428087, b: 0.40428087, a: 0}
--- !u!1 &464025704
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 464025706}
- component: {fileID: 464025705}
- component: {fileID: 464025710}
- component: {fileID: 464025711}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged

m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0

m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!114 &464025711
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 695e410829600ff40bcdd76fa0818f6a, type: 3}
m_Name:
m_EditorClassIdentifier:
materialPropertyTarget: 1
color: {r: 0.34109113, g: 0.42664438, b: 0.6886792, a: 0}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0

m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
- component: {fileID: 705507996}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged

m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &705507996
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 963194229}
- component: {fileID: 963194227}
- component: {fileID: 963194231}
- component: {fileID: 963194232}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera

m_EditorClassIdentifier:
targetLight: {fileID: 705507993}
target: {fileID: 1640252278}
--- !u!114 &963194232
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53f4c974fdf704444959724a41de0cfe, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
yDegreesPerSecond: 180

6
TestProjects/PerceptionURP/Packages/manifest.json


"com.unity.package-validation-suite": "0.9.1-preview",
"com.unity.perception": "file:../../../com.unity.perception",
"com.unity.render-pipelines.universal": "7.3.1",
"com.unity.simulation.capture": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.17",
"com.unity.test-framework": "1.1.14",
"com.unity.simulation.capture": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.19",
"com.unity.test-framework": "1.1.16",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.12",
"com.unity.ugui": "1.0.0",

12
TestProjects/PerceptionURP/Packages/packages-lock.json


"com.unity.nuget.newtonsoft-json": "1.1.2",
"com.unity.render-pipelines.core": "7.1.6",
"com.unity.entities": "0.8.0-preview.8",
"com.unity.simulation.capture": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.17"
"com.unity.simulation.capture": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.19"
}
},
"com.unity.platforms": {

"url": "https://packages.unity.com"
},
"com.unity.simulation.capture": {
"version": "0.0.10-preview.10",
"version": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.17"
"com.unity.simulation.core": "0.0.10-preview.19"
"version": "0.0.10-preview.17",
"version": "0.0.10-preview.19",
"depth": 0,
"source": "registry",
"dependencies": {},

"version": "1.1.14",
"version": "1.1.16",
"depth": 0,
"source": "registry",
"dependencies": {

37
TestProjects/PerceptionURP/ProjectSettings/ProjectSettings.asset


defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
m_ShowUnitySplashScreen: 1
m_ShowUnitySplashScreen: 0
m_ShowUnitySplashLogo: 1
m_SplashScreenOverlayOpacity: 1
m_SplashScreenAnimation: 1

bakeCollisionMeshes: 0
forceSingleInstance: 0
useFlipModelSwapchain: 1
resizableWindow: 0
resizableWindow: 1
useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games
gpuSkinning: 1

xboxEnableFitness: 0
visibleInBackground: 1
allowFullscreenSwitch: 1
fullscreenMode: 1
fullscreenMode: 3
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0
xboxEnableGuest: 0

switchNVNShaderPoolsGranularity: 33554432
switchNVNDefaultPoolsGranularity: 16777216
switchNVNOtherPoolsGranularity: 16777216
switchNVNMaxPublicTextureIDCount: 0
switchNVNMaxPublicSamplerIDCount: 0
stadiaPresentMode: 0
stadiaTargetFramerate: 0
vulkanEnableLateAcquireNextImage: 0
m_SupportedAspectRatios:
4:3: 1
5:4: 1

AndroidMinSdkVersion: 19
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
aotOptions:
aotOptions: nimt-trampolines=1024
stripEngineCode: 1
iPhoneStrippingLevel: 0
iPhoneScriptCallOptimization: 0

uIStatusBarHidden: 1
uIExitOnSuspend: 0
uIStatusBarStyle: 0
iPhoneSplashScreen: {fileID: 0}
iPhoneHighResSplashScreen: {fileID: 0}
iPhoneTallHighResSplashScreen: {fileID: 0}
iPhone47inSplashScreen: {fileID: 0}
iPhone55inPortraitSplashScreen: {fileID: 0}
iPhone55inLandscapeSplashScreen: {fileID: 0}
iPhone58inPortraitSplashScreen: {fileID: 0}
iPhone58inLandscapeSplashScreen: {fileID: 0}
iPadPortraitSplashScreen: {fileID: 0}
iPadHighResPortraitSplashScreen: {fileID: 0}
iPadLandscapeSplashScreen: {fileID: 0}
iPadHighResLandscapeSplashScreen: {fileID: 0}
iPhone65inPortraitSplashScreen: {fileID: 0}
iPhone65inLandscapeSplashScreen: {fileID: 0}
iPhone61inPortraitSplashScreen: {fileID: 0}
iPhone61inLandscapeSplashScreen: {fileID: 0}
appleTVSplashScreen: {fileID: 0}
appleTVSplashScreen2x: {fileID: 0}
tvOSSmallIconLayers: []

m_Automatic: 0
- m_BuildTarget: WebGLSupport
m_APIs: 0b000000
m_Automatic: 0
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 02000000
m_Automatic: 0
m_BuildTargetVRSettings: []
openGLRequireES31: 0

ps4ShareFilePath:
ps4ShareOverlayImagePath:
ps4PrivacyGuardImagePath:
ps4ExtraSceSysFile:
ps4NPtitleDatPath:
ps4RemotePlayKeyAssignment: -1
ps4RemotePlayKeyMappingDir:

ps4UseResolutionFallback: 0
ps4ReprojectionSupport: 0
ps4UseAudio3dBackend: 0
ps4UseLowGarlicFragmentationMode: 1
ps4SocialScreenEnabled: 0
ps4ScriptOptimizationLevel: 0
ps4Audio3dVirtualSpeakerCount: 14

ps4disableAutoHideSplash: 0
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4attribVROutputEnabled: 0

XboxOnePersistentLocalStorageSize: 0
XboxOneXTitleMemory: 8
XboxOneOverrideIdentityName:
XboxOneOverrideIdentityPublisher:
vrEditorSettings:
daydream:
daydreamIconForeground: {fileID: 0}

4
TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.7f1
m_EditorVersionWithRevision: 2019.4.7f1 (e992b1a16e65)
m_EditorVersion: 2019.4.8f1
m_EditorVersionWithRevision: 2019.4.8f1 (60781d942082)

43
com.unity.perception/CHANGELOG.md


### Fixed
## [0.4.0-preview.1] - 2020-08-07
### Added
Added new experimental randomization tools
Added support for 2020.1
Added Labeling.RefreshLabeling(), which can be used to update ground truth generators after the list of labels or the renderers is changed
Added support for renderers with MaterialPropertyBlocks assigned to individual materials
### Changed
Changed the way realtime visualizers rendered to avoid rendering conflicts
Changed default labeler ids to be lower-case to be consistent with the ids in the dataset
Switched to latest versions of com.unity.simulation.core and com.unity.simulation.capture
### Deprecated
### Removed
### Fixed
Fixed 2d bounding boxes being reported for objects that do not match the label config.
Fixed a categorical parameter UI error in which deleting an individual option would successfully remove the option from the UI but only serialize the option to null during serialization instead of removing it
Fixed the "Application Frequency" parameter UI field not initializing to a default value
Fixed the IterateSeed() method where certain combinations of indices and random seeds would produce a random state value of zero, causing Unity.Mathematics.Random to throw an exception
Fixed labeler editor to allow for editing multiple labelers at a time
Fixed labeler editor to ensure that when duplicating prefabs all labeler entries are also duplicated
Fixed colors in semantic segmentation images being darker than those specified in the label config
Fixed objects being incorrectly labeled when they do not match any entries in the label config
Fixed lens distortion in URP and HDRP now being applied to ground truth
### Security
## [0.3.0-preview.1] - 2020-08-07

13
com.unity.perception/Documentation~/PerceptionCamera.md


```
_Example rendered object info for a single object_
The Rendered Object Info Labeler records a list of all objects visible in the camera image, including its instance id, resolved label id and visible pixels. Objects not resolved to a label in the given ID Label Config are not recorded.
The Rendered Object Info Labeler records a list of all objects visible in the camera image, including its instance id, resolved label id and visible pixels. Objects not resolved to a label in the given ID Label Config are not recorded.
## Limitations
Ground truth is not compatible with all rendering features, especially ones that modify the visibility or shape of objects in the frame.
When generating ground truth:
* Vertex and geometry shaders are not run
* Transparency is not considered. All geometry is considered opaque
* Besides built-in Lens Distortion in URP and HDRP, post-processing effects are not run
If you encounter additional incompatibilities, please open an [issue](https://github.com/Unity-Technologies/com.unity.perception/issues)

3
com.unity.perception/Documentation~/TableOfContents.md


* [Getting Started](GettingStarted.md)
* [Labeling](GroundTruth-Labeling.md)
* [Perception Camera](PerceptionCamera.md)
* [Dataset Capture](DatasetCapture.md)
* [Dataset Capture](DatasetCapture.md)
* [Randomization](Randomization/Index.md)

9
com.unity.perception/Documentation~/index.md


[Setting up your first perception scene](GettingStarted.md)
[Randomizing your simulation (Experimental)](Randomization/Index.md)
## Example projects using Perception
### SynthDet

|[Labeling](GroundTruth-Labeling.md)|Component which marks a GameObject and its descendants with a set of labels|
|[LabelConfig](GroundTruth-Labeling.md#LabelConfig)|Asset which defines a taxonomy of labels for ground truth generation|
|[Perception Camera](PerceptionCamera.md)|Captures RGB images and ground truth from a [Camera](https://docs.unity3d.com/Manual/class-Camera.html)|
|[DatasetCapture](DatasetCapture.md)|Ensures sensors are triggered at proper rates and accepts data for the JSON dataset|
|[DatasetCapture](DatasetCapture.md)|Ensures sensors are triggered at proper rates and accepts data for the JSON dataset|
|[Randomization (Experimental)](Randomization/Index.md)|Integrate domain randomization principles into your simulation|
## Known Issues
* The Linux Editor 2019.4.7f1 and 2019.4.8f1 have been found to hang when importing HDRP-based perception projects. For Linux Editor support, use 2019.4.6f1 or 2020.1

2
com.unity.perception/Editor/GroundTruth/CameraLabelerDrawer.cs


enabledRect.x = rect.xMax - enabledSize.x;
enabledRect.width = enabledSize.x;
EditorGUI.LabelField(headerRect, $"{cameraLabeler.GetType().Name}", EditorStyles.boldLabel);
EditorGUI.LabelField(headerRect, new GUIContent($"{cameraLabeler.GetType().Name}", $"{cameraLabeler.description}"), EditorStyles.boldLabel);
EditorGUIUtility.labelWidth = enabledRect.width - 14;
m_Enabled.boolValue = EditorGUI.Toggle(enabledRect, Styles.enabled, m_Enabled.boolValue);
EditorGUIUtility.labelWidth = 0;

87
com.unity.perception/Editor/GroundTruth/LabelingEditor.cs


using Unity.Entities;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;

[CustomEditor(typeof(Labeling))]
[CustomEditor(typeof(Labeling)), CanEditMultipleObjects]
const int k_Indent = 7;
ReorderableList m_LabelsList;
public void OnEnable()

m_LabelsList.onAddCallback += OnAdd;
m_LabelsList.onRemoveCallback += OnRemove;
m_LabelsList.onReorderCallbackWithDetails += OnReordered;
labeling.labels.RemoveAt(list.index);
{
var value = labeling.labels[list.index];
foreach (var t in targets)
{
((Labeling)t).labels.Remove(value);
}
}
}
Labeling labeling => (Labeling)target;

labeling.labels.Add("");
foreach (var t in targets)
{
var castedTarget = ((Labeling)t);
castedTarget.labels.Add("");
EditorUtility.SetDirty(castedTarget);
}
}
void OnReordered(ReorderableList list, int oldIndex, int newIndex)
{
var label = labeling.labels[newIndex];
foreach (var t in targets)
{
var l = (Labeling)t;
if (this.labeling == l) continue;
ReorderLabels(l, label, newIndex);
}
}
static void ReorderLabels(Labeling labeling, string label, int newIndex)
{
if (labeling.labels.Contains(label))
{
labeling.labels.Remove(label);
if (newIndex < labeling.labels.Count)
labeling.labels.Insert(newIndex, label);
else
labeling.labels.Add(label);
}
}
static void ReplaceLabel(Labeling labeling, string oldLabel, string newLabel)
{
var idx = labeling.labels.IndexOf(oldLabel);
if (idx == -1) return;
labeling.labels[idx] = newLabel;
}
private void ReplaceLabel(int index, string newLabel)
{
labeling.labels[index] = newLabel;
}
void ReplaceLabelAll(int index, string currentLabel)
{
var oldLabel = labeling.labels[index];
ReplaceLabel(index, currentLabel);
foreach (var t in targets)
{
var l = (Labeling)t;
if (this.labeling == l) continue;
ReplaceLabel(l, oldLabel, currentLabel);
}
}
void DrawElement(Rect rect, int index, bool isactive, bool isfocused)

var indent = k_Indent * index;
if (indent >= rect.width)
return;
var contentRect = new Rect(rect.x, rect.y, rect.width, rect.height);
var value = EditorGUI.DelayedTextField(contentRect, labeling.labels[index]);
var contentRect = new Rect(rect.x + indent, rect.y, rect.width - indent, rect.height);
var value = EditorGUI.TextField(contentRect, labeling.labels[index]);
labeling.labels[index] = value;
ReplaceLabelAll(index, value);
if (PrefabUtility.IsPartOfAnyPrefab(target))
{
EditorUtility.SetDirty(target);
}
}
}
}

12
com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs


{
using(new EditorGUI.DisabledScope(EditorApplication.isPlaying))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.description)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.period)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startTime)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.showVisualizations)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.description)), new GUIContent("Description", "Provide a description for this perception camera (optional)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.period)), new GUIContent("Capture Interval", "The interval at which the perception camera should render and capture (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.startTime)), new GUIContent("Start Time","Time at which this perception camera starts rendering and capturing (seconds)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.showVisualizations)), new GUIContent("Show Labeler Visualizations", "Display realtime visualizations for labelers that are currently active on this perception camera."));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(perceptionCamera.captureRgbImages)),new GUIContent("Save Camera Output to Disk", "For each captured frame, save an RGB image of the perception camera's output to disk."));
serializedObject.ApplyModifiedProperties();
//EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.labelers)));

#if HDRP_PRESENT
var hdRenderPipelineAsset = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset as UnityEngine.Rendering.HighDefinition.HDRenderPipelineAsset;
if (hdRenderPipelineAsset != null &&
hdRenderPipelineAsset.currentPlatformRenderPipelineSettings.supportedLitShaderMode ==
hdRenderPipelineAsset.currentPlatformRenderPipelineSettings.supportedLitShaderMode ==
UnityEngine.Rendering.HighDefinition.RenderPipelineSettings.SupportedLitShaderMode.DeferredOnly)
{
EditorGUILayout.HelpBox("Deferred Only shader mode is not supported by rendering-based labelers. " +

3
com.unity.perception/Editor/Unity.Perception.Editor.asmdef


"Unity.Collections",
"Unity.Perception.Runtime",
"PathCreatorEditor",
"PathCreator"
"PathCreator",
"UnityEngine.UI"
],
"includePlatforms": [
"Editor"

23
com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs


using System;
using System.Collections.Generic;
using System.IO;
using Unity.Collections;
using Unity.Simulation;
using UnityEngine;

static readonly Guid k_DatasetGuid = Guid.NewGuid();
internal static SimulationState SimulationState { get; private set; } = CreateSimulationData();
internal static string OutputDirectory => SimulationState.OutputDirectory;
internal static string OutputDirectory => SimulationState.GetOutputDirectoryNoCreate();
/// <summary>
/// The json metadata schema version the DatasetCapture's output conforms to.

static SimulationState CreateSimulationData()
{
//TODO: Remove the Guid path when we have proper dataset merging in USim/Thea
return new SimulationState(Manager.Instance.GetDirectoryFor($"Dataset{k_DatasetGuid}"));
return new SimulationState($"Dataset{k_DatasetGuid}");
}
[RuntimeInitializeOnLoadMethod]

/// <param name="values">The annotation data.</param>
/// <typeparam name="T">The type of the data.</typeparam>
/// <exception cref="ArgumentNullException">Thrown if values is null</exception>
public void ReportValues<T>(T[] values)
public void ReportValues<T>(IEnumerable<T> values)
{
if (values == null)
throw new ArgumentNullException(nameof(values));
m_SimulationState.ReportAsyncAnnotationResult(this, values: values);
}
/// <summary>
/// Report a value-based data for this annotation.
/// </summary>
/// <param name="values">The annotation data.</param>
/// <typeparam name="T">The type of the data.</typeparam>
/// <exception cref="ArgumentNullException">Thrown if values is null</exception>
public void ReportValues<T>(NativeSlice<T> values) where T : struct
{
if (values == null)
throw new ArgumentNullException(nameof(values));

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


namespace UnityEngine.Perception.GroundTruth
{
abstract class GroundTruthCrossPipelinePass : IGroundTruthGenerator
internal abstract class GroundTruthCrossPipelinePass : IGroundTruthGenerator
{
public Camera targetCamera;

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


{
instanceId = instanceId
});
labeling.SetInstanceId(instanceId);
});
}

pass.SetupMaterialProperties(mpb, renderer, labeling, instanceId);
renderer.SetPropertyBlock(mpb);
var materialCount = renderer.materials.Length;
for (int i = 0; i < materialCount; i++)
{
renderer.GetPropertyBlock(mpb, i);
//Only apply to individual materials if there is already a MaterialPropertyBlock on it
if (!mpb.isEmpty)
{
foreach (var pass in m_ActiveGenerators)
pass.SetupMaterialProperties(mpb, renderer, labeling, instanceId);
renderer.SetPropertyBlock(mpb, i);
}
}
}
for (var i = 0; i < gameObject.transform.childCount; i++)

public bool Deactivate(IGroundTruthGenerator generator)
{
return m_ActiveGenerators.Remove(generator);
}
internal void RefreshLabeling(Entity labelingEntity)
{
EntityManager.RemoveComponent<GroundTruthInfo>(labelingEntity);
}
}
}

26
com.unity.perception/Runtime/GroundTruth/GroundTruthRendererFeature.cs


class SemanticSegmentationUrpPass : ScriptableRenderPass
{
SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass;
public SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass;
public SemanticSegmentationUrpPass(Camera camera, RenderTexture targetTexture, SemanticSegmentationLabelConfig labelConfig)
{

public void Cleanup()
{
m_SemanticSegmentationCrossPipelinePass.Cleanup();
}
}
class LensDistortionUrpPass : ScriptableRenderPass
{
public LensDistortionCrossPipelinePass m_LensDistortionCrossPipelinePass;
public LensDistortionUrpPass(Camera camera, RenderTexture targetTexture)
{
m_LensDistortionCrossPipelinePass = new LensDistortionCrossPipelinePass(camera, targetTexture);
ConfigureTarget(targetTexture, targetTexture.depthBuffer);
m_LensDistortionCrossPipelinePass.Setup();
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
var commandBuffer = CommandBufferPool.Get(nameof(SemanticSegmentationUrpPass));
m_LensDistortionCrossPipelinePass.Execute(context, commandBuffer, renderingData.cameraData.camera, renderingData.cullResults);
CommandBufferPool.Release(commandBuffer);
}
public void Cleanup()
{
m_LensDistortionCrossPipelinePass.Cleanup();
}
}

107
com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs


[Serializable]
public sealed class BoundingBox2DLabeler : CameraLabeler
{
///<inheritdoc/>
public override string description
{
get => "Produces 2D bounding box annotations for all visible objects that bear a label defined in this labeler's associated label configuration.";
protected set {}
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
struct BoundingBoxValue

Dictionary<int, AsyncAnnotation> m_AsyncAnnotations;
AnnotationDefinition m_BoundingBoxAnnotationDefinition;
BoundingBoxValue[] m_BoundingBoxValues;
List<BoundingBoxValue> m_BoundingBoxValues;
private GameObject visualizationHolder = null;
Vector2 m_OriginalScreenSize = Vector2.zero;
private Vector2 originalScreenSize = Vector2.zero;
Texture m_BoundingBoxTexture;
Texture m_LabelTexture;
GUIStyle m_Style;
/// <summary>
/// Creates a new BoundingBox2DLabeler. Be sure to assign <see cref="idLabelConfig"/> before adding to a <see cref="PerceptionCamera"/>.

throw new InvalidOperationException("BoundingBox2DLabeler's idLabelConfig field must be assigned");
m_AsyncAnnotations = new Dictionary<int, AsyncAnnotation>();
m_BoundingBoxValues = new List<BoundingBoxValue>();
m_BoundingBoxAnnotationDefinition = DatasetCapture.RegisterAnnotationDefinition("bounding box", idLabelConfig.GetAnnotationSpecification(),
"Bounding box for each labeled object visible to the sensor", id: new Guid(annotationId));

// Record the original screen size. The screen size can change during play, and the visual bounding
// boxes need to be scaled appropriately
originalScreenSize = new Vector2(Screen.width, Screen.height);
m_OriginalScreenSize = new Vector2(Screen.width, Screen.height);
m_BoundingBoxTexture = Resources.Load<Texture>("outline_box");
m_LabelTexture = Resources.Load<Texture>("solid_white");
m_Style = new GUIStyle();
m_Style.normal.textColor = Color.black;
m_Style.fontSize = 16;
m_Style.padding = new RectOffset(4, 4, 4, 4);
m_Style.contentOffset = new Vector2(4, 0);
m_Style.alignment = TextAnchor.MiddleLeft;
}
/// <inheritdoc/>

using (s_BoundingBoxCallback.Auto())
{
if (m_BoundingBoxValues == null || m_BoundingBoxValues.Length != renderedObjectInfos.Length)
m_BoundingBoxValues = new BoundingBoxValue[renderedObjectInfos.Length];
m_BoundingBoxValues.Clear();
for (var i = 0; i < renderedObjectInfos.Length; i++)
{
var objectInfo = renderedObjectInfos[i];

m_BoundingBoxValues[i] = new BoundingBoxValue
m_BoundingBoxValues.Add(new BoundingBoxValue
{
label_id = labelEntry.id,
label_name = labelEntry.label,

width = objectInfo.boundingBox.width,
height = objectInfo.boundingBox.height,
};
});
if (visualizationEnabled)
{
Visualize();
}
asyncAnnotation.ReportValues(m_BoundingBoxValues);
}

protected override void PopulateVisualizationPanel(ControlPanel panel)
protected override void OnVisualize()
panel.AddToggleControl("BoundingBoxes", enabled => {
visualizationEnabled = enabled;
});
if (m_BoundingBoxValues == null) return;
objectPool = new List<GameObject>();
visualizationHolder = new GameObject("BoundsHolder" + Time.frameCount);
visualizationCanvas.AddComponent(visualizationHolder);
}
void ClearObjectPool(int count)
{
for (int i = count; i < objectPool.Count; i++)
{
objectPool[i].SetActive(false);
}
}
List<GameObject> objectPool = null;
void Visualize()
{
ClearObjectPool(m_BoundingBoxValues.Length);
GUI.depth = 5;
float screenRatioWidth = Screen.width / originalScreenSize.x;
float screenRatioHeight = Screen.height / originalScreenSize.y;
float screenRatioWidth = Screen.width / m_OriginalScreenSize.x;
float screenRatioHeight = Screen.height / m_OriginalScreenSize.y;
for (int i = 0; i < m_BoundingBoxValues.Length; i++)
foreach (var box in m_BoundingBoxValues)
var boxVal = m_BoundingBoxValues[i];
float x = box.x * screenRatioWidth;
float y = box.y * screenRatioHeight;
if (i >= objectPool.Count)
{
var boundingBoxObject = GameObject.Instantiate(Resources.Load<GameObject>("BoundingBoxPrefab"));
objectPool.Add(boundingBoxObject);
var rectTransform = (RectTransform)boundingBoxObject.transform;
rectTransform.SetParent(visualizationHolder.transform, false);
}
if (!objectPool[i].activeSelf) objectPool[i].SetActive(true);
string label = boxVal.label_name + "_" + boxVal.instance_id;
objectPool[i].GetComponentInChildren<Text>().text = label;
var rectTrans = objectPool[i].transform as RectTransform;
rectTrans.anchoredPosition = new Vector2(boxVal.x * screenRatioWidth, -boxVal.y * screenRatioHeight);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxVal.width * screenRatioWidth);
rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxVal.height * screenRatioHeight);
var boxRect = new Rect(x, y, box.width * screenRatioWidth, box.height * screenRatioHeight);
var labelWidth = Math.Min(120, box.width * screenRatioWidth);
var labelRect = new Rect(x, y - 17, labelWidth, 17);
GUI.DrawTexture(boxRect, m_BoundingBoxTexture, ScaleMode.StretchToFill, true, 0, Color.yellow, 3, 0.25f);
GUI.DrawTexture(labelRect, m_LabelTexture, ScaleMode.StretchToFill, true, 0, Color.yellow, 0, 0);
GUI.Label(labelRect, box.label_name + "_" + box.instance_id, m_Style);
}
/// <inheritdoc/>
override protected void OnVisualizerEnabledChanged(bool enabled)
{
if (visualizationHolder != null)
visualizationHolder.SetActive(enabled);
}
}
}

82
com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs


using Unity.Simulation;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.UIElements;
namespace UnityEngine.Perception.GroundTruth
{

[Serializable]
public abstract class CameraLabeler
{
/// <summary>
/// A human-readable description of the labeler
/// </summary>
public abstract string description { get; protected set; }
/// <summary>
/// Whether the CameraLabeler should be set up and called each frame.
/// </summary>

}
/// <summary>
/// Retrieve a handle to the visualization canvas <see cref="VisualizationCanvas"/>. This is the specific canvas that all visualization
/// labelers should be added to. The canvas has helper functions to create many common visualization components.
/// </summary>
public VisualizationCanvas visualizationCanvas { get; private set; }
/// <summary>
/// The control panel that is attached to the visualization canvas. The common location to add interactive controls.
/// </summary>
public ControlPanel controlPanel => visualizationCanvas != null ? visualizationCanvas.controlPanel : null;
/// <summary>
public HUDPanel hudPanel => visualizationCanvas != null ? visualizationCanvas.hudPanel : null;
public HUDPanel hudPanel => perceptionCamera != null ? perceptionCamera.hudPanel : null;
/// <summary>
/// The <see cref="PerceptionCamera"/> that contains this labeler.

/// </summary>
protected virtual void Setup() { }
/// <summary>
/// Called immediately after <see cref="setup"/>. Implement this to initialize labeler's visualization
/// capability if one exists <see cref="supportVisualization"/>.
/// </summary>
/// <param name="panel">The target control panel for the labeler's visualization component</param>
protected virtual void PopulateVisualizationPanel(ControlPanel panel) { }
/// <summary>
/// <param name="enabled">The current enabled state of the visualizer</param>
protected virtual void OnVisualizerEnabledChanged(bool enabled) {}
/// <param name="visualizerEnabled">The current enabled state of the visualizer</param>
protected virtual void OnVisualizerEnabledChanged(bool visualizerEnabled) {}
/// <summary>
/// Called during the Update each frame the the labeler is enabled and <see cref="SensorHandle.ShouldCaptureThisFrame"/> is true.
/// </summary>

/// </summary>
protected virtual void OnBeginRendering() {}
/// <summary>
/// Labeling pass to display labeler's visualization components, if applicable. Important note, all labeler's visualizations need
/// to use Unity's Immediate Mode GUI (IMGUI) <see cref="https://docs.unity3d.com/Manual/GUIScriptingGuide.html"/> system.
/// This called is triggered from <see cref="perceptionCamera.OnGUI"/> call. This call happens immediately before <see cref="OnVisualizeAdditionalUI"/>
/// so that the visualization components are drawn below the UI elements.
/// </summary>
protected virtual void OnVisualize() {}
/// <summary>
/// In this pass, a labeler can add custom GUI controls to the scene. Important note, all labeler's additional
/// GUIs need to use Unity's Immediate Mode GUI (IMGUI) <see cref="https://docs.unity3d.com/Manual/GUIScriptingGuide.html"/> system.
/// This called is triggered from <see cref="perceptionCamera.OnGUI"/> call. This call happens immediately after the <see cref="OnVisualize"/>
/// so that the visualization components are drawn below the UI elements.
/// </summary>
protected virtual void OnVisualizeAdditionalUI() {}
/// <summary>
/// Called when the Labeler is about to be destroyed or removed from the PerceptionCamera. Use this to clean up to state.

internal void InternalSetup() => Setup();
internal void InternalPopulateVisualizationPanel(GameObject panel) => PopulateVisualizationPanel(controlPanel);
internal bool InternalVisualizationEnabled
{

internal void InternalOnUpdate() => OnUpdate();
internal void InternalOnBeginRendering() => OnBeginRendering();
internal void InternalCleanup() => Cleanup();
internal void InternalVisualize() => OnVisualize();
private bool m_ShowVisualizations = false;

/// this will not function.
/// </summary>
protected bool visualizationEnabled
internal bool visualizationEnabled
{
get
{

{
if (!supportsVisualization) return;
if (visualizationCanvas == null) return;
if (value != m_ShowVisualizations)
{

}
}
internal void Init(PerceptionCamera newPerceptionCamera, VisualizationCanvas visualizationCanvas)
internal void VisualizeUI()
{
if (supportsVisualization)
{
GUILayout.Label(GetType().Name);
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.Label("Enabled");
GUILayout.FlexibleSpace();
visualizationEnabled = GUILayout.Toggle(visualizationEnabled, "");
GUILayout.EndHorizontal();
if (visualizationEnabled) OnVisualizeAdditionalUI();
}
}
internal void Visualize()
{
if (visualizationEnabled) OnVisualize();
}
internal void Init(PerceptionCamera newPerceptionCamera)
this.visualizationCanvas = visualizationCanvas;
if (supportsVisualization && visualizationCanvas != null)
{
m_ShowVisualizations = true;
InitVisualizationUI();
}
m_ShowVisualizations = supportsVisualization && perceptionCamera.showVisualizations;
}
catch (Exception)
{

}
private void InitVisualizationUI()
{
PopulateVisualizationPanel(controlPanel);
}
}
}

32
com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs


[Serializable]
public sealed class ObjectCountLabeler : CameraLabeler
{
///<inheritdoc/>
public override string description
{
get => "Produces object counts for each label defined in this labeler's associated label configuration.";
protected set {}
}
/// <summary>
/// The ID to use for object count annotations in the resulting dataset
/// </summary>

Dictionary<int, AsyncMetric> m_ObjectCountAsyncMetrics;
MetricDefinition m_ObjectCountMetricDefinition;
List<string> vizEntries = null;
/// <summary>
/// Creates a new ObjectCountLabeler. This constructor should only be used by serialization. For creation from

m_ClassCountValues = new ClassCountValue[entries.Count];
bool visualize = visualizationEnabled;
if (visualize && vizEntries == null)
{
vizEntries = new List<string>();
}
for (var i = 0; i < entries.Count; i++)
{

if (visualize)
{
var label = entries[i].label + " Counts";
hudPanel.UpdateEntry(this, label, counts[i].ToString());
hudPanel.UpdateEntry(label, counts[i].ToString());
vizEntries.Add(label);
}
}

/// <inheritdoc/>
protected override void PopulateVisualizationPanel(ControlPanel panel)
protected override void OnVisualizerEnabledChanged(bool enabled)
panel.AddToggleControl("Object Counts", enabled => { visualizationEnabled = enabled; });
}
/// <inheritdoc/>
override protected void OnVisualizerEnabledChanged(bool enabled)
{
if (!enabled)
{
hudPanel.RemoveEntries(vizEntries);
vizEntries.Clear();
}
if (enabled) return;
hudPanel.RemoveEntries(this);
}
}
}

34
com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs


[Serializable]
public sealed class RenderedObjectInfoLabeler : CameraLabeler
{
///<inheritdoc/>
public override string description
{
get => "Produces label id, instance id, and visible pixel count in a single metric each frame for each object which takes up one or more pixels in the camera's frame, based on this labeler's associated label configuration.";
protected set {}
}
// ReSharper disable InconsistentNaming
struct RenderedObjectInfoValue
{

RenderedObjectInfoValue[] m_VisiblePixelsValues;
Dictionary<int, AsyncMetric> m_ObjectInfoAsyncMetrics;
MetricDefinition m_RenderedObjectInfoMetricDefinition;
List<string> vizEntries = null;
/// <summary>
/// Creates a new RenderedObjectInfoLabeler. Be sure to assign <see cref="idLabelConfig"/> before adding to a <see cref="PerceptionCamera"/>.

m_VisiblePixelsValues = new RenderedObjectInfoValue[renderedObjectInfos.Length];
bool visualize = visualizationEnabled;
if (visualize && vizEntries == null)
{
vizEntries = new List<string>();
}
for (var i = 0; i < renderedObjectInfos.Length; i++)
{

if (visualize)
{
var label = labelEntry.label + "_" + objectInfo.instanceId;
hudPanel.UpdateEntry(label, objectInfo.pixelCount.ToString());
vizEntries.Add(label);
hudPanel.UpdateEntry(this, label, objectInfo.pixelCount.ToString());
}
}

bool TryGetLabelEntryFromInstanceId(uint instanceId, out IdLabelEntry labelEntry)
{
return idLabelConfig.TryGetLabelEntryFromInstanceId(instanceId, out labelEntry);

protected override void PopulateVisualizationPanel(ControlPanel panel)
protected override void OnVisualizerEnabledChanged(bool enabled)
panel.AddToggleControl("Pixel Counts", enabled => { visualizationEnabled = enabled; });
}
/// <inheritdoc/>
override protected void OnVisualizerEnabledChanged(bool enabled)
{
if (!enabled)
{
hudPanel.RemoveEntries(vizEntries);
vizEntries.Clear();
}
if (enabled) return;
hudPanel.RemoveEntries(this);
}
}
}

141
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


using Unity.Simulation;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
#if HDRP_PRESENT

[Serializable]
public sealed class SemanticSegmentationLabeler : CameraLabeler
{
///<inheritdoc/>
public override string description
{
get => "Generates a semantic segmentation image for each captured frame. Each object is rendered to the semantic segmentation image using the color associated with it based on this labeler's associated semantic segmentation label configuration. " +
"Semantic segmentation images are saved to the dataset in PNG format. " +
"Please note that only one " + this.GetType().Name + " can render at once across all cameras.";
protected set {}
}
const string k_SemanticSegmentationDirectory = "SemanticSegmentation";
const string k_SegmentationFilePrefix = "segmentation_";

AnnotationDefinition m_SemanticSegmentationAnnotationDefinition;
RenderTextureReader<Color32> m_SemanticSegmentationTextureReader;
#if HDRP_PRESENT
internal bool m_fLensDistortionEnabled = false;
#if HDRP_PRESENT
#endif
LensDistortionPass m_LensDistortionPass;
#elif URP_PRESENT
SemanticSegmentationUrpPass m_SemanticSegmentationPass;
LensDistortionUrpPass m_LensDistortionPass;
#endif
private float defaultSegmentTransparency = 0.8f;
private float defaultBackgroundTransparency = 0.0f;
private float segmentTransparency = 0.8f;
private float backgroundTransparency = 0.0f;
/// <summary>
/// Creates a new SemanticSegmentationLabeler. Be sure to assign <see cref="labelConfig"/> before adding to a <see cref="PerceptionCamera"/>.

int camWidth = 0;
int camHeight = 0;
private GameObject segCanvas;
GUIStyle labelStyle = null;
GUIStyle sliderStyle = null;
/// <inheritdoc/>
protected override bool supportsVisualization => true;

name = "Labeling Pass"
};
customPassVolume.customPasses.Add(m_SemanticSegmentationPass);
#endif
#if URP_PRESENT
perceptionCamera.AddScriptableRenderPass(new SemanticSegmentationUrpPass(myCamera, targetTexture, labelConfig));
m_LensDistortionPass = new LensDistortionPass(myCamera, targetTexture)
{
name = "Lens Distortion Pass"
};
customPassVolume.customPasses.Add(m_LensDistortionPass);
m_fLensDistortionEnabled = true;
#elif URP_PRESENT
// Semantic Segmentation
m_SemanticSegmentationPass = new SemanticSegmentationUrpPass(myCamera, targetTexture, labelConfig);
perceptionCamera.AddScriptableRenderPass(m_SemanticSegmentationPass);
// Lens Distortion
m_LensDistortionPass = new LensDistortionUrpPass(myCamera, targetTexture);
perceptionCamera.AddScriptableRenderPass(m_LensDistortionPass);
m_fLensDistortionEnabled = true;
#endif
var specs = labelConfig.labelEntries.Select((l) => new SemanticSegmentationSpec()

visualizationEnabled = supportsVisualization;
}
private void SetupVisualizationElements()
{
segmentTransparency = 0.8f;
backgroundTransparency = 0.0f;
segVisual = GameObject.Instantiate(Resources.Load<GameObject>("SegmentTexture"));
segImage = segVisual.GetComponent<RawImage>();
segImage.material.SetFloat("_SegmentTransparency", segmentTransparency);
segImage.material.SetFloat("_BackTransparency", backgroundTransparency);
segImage.texture = targetTexture;
var rt = segVisual.transform as RectTransform;
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, camWidth);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, camHeight);
if (segCanvas == null)
{
segCanvas = new GameObject(perceptionCamera.gameObject.name + "_segmentation_canvas");
segCanvas.AddComponent<RectTransform>();
var canvas = segCanvas.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
segCanvas.AddComponent<CanvasScaler>();
segVisual.transform.SetParent(segCanvas.transform, false);
}
labelStyle = new GUIStyle(GUI.skin.label) {padding = {left = 10}};
sliderStyle = new GUIStyle(GUI.skin.horizontalSlider) {margin = {left = 12}};
}
void OnSemanticSegmentationImageRead(int frameCount, NativeArray<Color32> data)
{
if (!m_AsyncAnnotations.TryGetValue(frameCount, out var annotation))

m_SemanticSegmentationTextureReader?.Dispose();
m_SemanticSegmentationTextureReader = null;
Object.Destroy(segCanvas);
segCanvas = null;
if (m_TargetTextureOverride != null)
m_TargetTextureOverride.Release();

/// <inheritdoc/>
protected override void PopulateVisualizationPanel(ControlPanel panel)
override protected void OnVisualizerEnabledChanged(bool enabled)
panel.AddToggleControl("Segmentation Information", enabled => { visualizationEnabled = enabled; });
if (segVisual != null)
segVisual.SetActive(enabled);
}
defaultSegmentTransparency = 0.8f;
defaultBackgroundTransparency = 0.0f;
panel.AddSliderControl("Object Alpha", defaultSegmentTransparency, val => {
if (segImage != null) segImage.material.SetFloat("_SegmentTransparency", val);
});
panel.AddSliderControl("Background Alpha", defaultBackgroundTransparency, val => {
if (segImage != null) segImage.material.SetFloat("_BackTransparency", val);
});
/// <inheritdoc/>
protected override void OnVisualizeAdditionalUI()
{
if (segImage == null)
{
SetupVisualizationElements();
}
segVisual = GameObject.Instantiate(Resources.Load<GameObject>("SegmentTexture"));
var rt = segVisual.transform as RectTransform;
if (rt != null && camHeight != Screen.height)
{
camHeight = Screen.height;
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, camHeight);
}
segImage = segVisual.GetComponent<RawImage>();
segImage.material.SetFloat("_SegmentTransparency", defaultSegmentTransparency);
segImage.material.SetFloat("_BackTransparency", defaultBackgroundTransparency);
segImage.texture = targetTexture;
if (rt != null && camWidth != Screen.width)
{
camWidth = Screen.width;
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
}
RectTransform rt = segVisual.transform as RectTransform;
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, camWidth);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, camHeight);
GUILayout.Space(4);
GUILayout.Label("Object Alpha:", labelStyle);
segmentTransparency = GUILayout.HorizontalSlider(segmentTransparency, 0.0f, 1.0f, sliderStyle, GUI.skin.horizontalSliderThumb);
GUILayout.Space(4);
GUILayout.Label("Background Alpha:", labelStyle);
backgroundTransparency = GUILayout.HorizontalSlider(backgroundTransparency, 0.0f, 1.0f, sliderStyle, GUI.skin.horizontalSliderThumb);
GUI.skin.label.padding.left = 0;
visualizationCanvas.AddComponent(segVisual, setAsLowestElement: true);
}
if (!GUI.changed) return;
segImage.material.SetFloat("_SegmentTransparency", segmentTransparency);
segImage.material.SetFloat("_BackTransparency", backgroundTransparency);
/// <inheritdoc/>
override protected void OnVisualizerEnabledChanged(bool enabled)
{
if (segVisual != null)
segVisual.SetActive(enabled);
}
}
}

167
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/HUDPanel.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

/// </summary>
public class HUDPanel : MonoBehaviour
{
Dictionary<string, (bool, KeyValuePanel)> entries = new Dictionary<string, (bool, KeyValuePanel)>();
Stack<KeyValuePanel> orphans = new Stack<KeyValuePanel>();
readonly Dictionary<CameraLabeler, Dictionary<string, string>> m_Entries = new Dictionary<CameraLabeler, Dictionary<string, string>>();
/// <summary>
/// The panel that will hold all of the key value panel elements, this reference is needed to be able to hide the panel
/// </summary>
public GameObject contentPanel = null;
/// <summary>
/// The scroll rect of the HUD panel, this reference is needed to be able to hide the panel
/// </summary>
public ScrollRect scrollRect = null;
GUIStyle m_KeyStyle;
GUIStyle m_ValueStyle;
const int k_LineHeight = 22;
const int k_XPadding = 10;
const int k_YPadding = 10;
const int k_BoxWidth = 200;
const int k_YLineSpacing = 4;
/// The background image of the HUD panel, this reference is needed to be able to hide the panel
/// The number of labelers currently displaying real-time information on the visualization HUD
public Image img = null;
public int entryCount => m_Entries.Keys.Count();
void Update()
void Awake()
if (entries.Any() != scrollRect.enabled)
m_KeyStyle = new GUIStyle
scrollRect.enabled = !scrollRect.enabled;
img.enabled = scrollRect.enabled;
foreach (var i in GetComponentsInChildren<Image>())
{
i.enabled = scrollRect.enabled;
}
}
alignment = TextAnchor.MiddleLeft,
padding = new RectOffset(10, 10, 5, 5),
normal = {textColor = Color.white}
};
// Go through everyone that has not been updated and remove them and
// if they have been updated mark them dirty for next round
var keys = new List<string>(entries.Keys);
foreach (var key in keys)
m_ValueStyle = new GUIStyle
var entry = entries[key];
if (!entry.Item1)
{
entry.Item2.gameObject.SetActive(false);
orphans.Push(entry.Item2);
}
else
{
entry.Item1 = false;
entries[key] = entry;
}
}
alignment = TextAnchor.MiddleRight,
padding = new RectOffset(10, 10, 5, 5),
normal = {textColor = Color.white}
};
/// <param name="labeler">The labeler that requested the HUD entry</param>
public void UpdateEntry(string key, string value)
public void UpdateEntry(CameraLabeler labeler, string key, string value)
{
if (!m_Entries.ContainsKey(labeler))
{
m_Entries[labeler] = new Dictionary<string, string>();
}
m_Entries[labeler][key] = value;
}
Vector2 m_ScrollPosition;
bool m_GUIStylesInitialized = false;
void SetUpGUIStyles()
{
GUI.skin.label.fontSize = 12;
GUI.skin.label.font = Resources.Load<Font>("Inter-Light");
GUI.skin.label.padding = new RectOffset(0, 0, 1, 1);
GUI.skin.label.margin = new RectOffset(0, 0, 1, 1);
GUI.skin.box.padding = new RectOffset(5, 5, 5, 5);
GUI.skin.toggle.margin = new RectOffset(0, 0, 0, 0);
GUI.skin.horizontalSlider.margin = new RectOffset(0, 0, 0, 0);
m_GUIStylesInitialized = true;
}
int EntriesCount()
{
return m_Entries.Count + m_Entries.Sum(entry => entry.Value.Count);
}
internal void OnDrawGUI()
(bool, KeyValuePanel) val;
if (m_Entries.Count == 0) return;
if (!entries.ContainsKey(key))
if (!m_GUIStylesInitialized) SetUpGUIStyles();
GUI.depth = 0; // Draw HUD objects on the top of other UI objects
var height = Math.Min(k_LineHeight * EntriesCount(), Screen.height * 0.5f - k_YPadding * 2);
var xPos = Screen.width - k_BoxWidth - k_XPadding;
var yPos = Screen.height - height - k_YPadding;
GUILayout.BeginArea(new Rect(xPos, yPos, k_BoxWidth, height), GUI.skin.box);
m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
var firstTime = true;
foreach (var labeler in m_Entries.Keys)
if (orphans.Any())
if (!firstTime) GUILayout.Space(k_YLineSpacing);
firstTime = false;
GUILayout.Label(labeler.GetType().Name);
foreach (var entry in m_Entries[labeler])
val = (true, orphans.Pop());
val.Item2.gameObject.SetActive(true);
GUILayout.BeginHorizontal();
GUILayout.Space(5);
GUILayout.Label(entry.Key);
GUILayout.FlexibleSpace();
GUILayout.Label(entry.Value);
GUILayout.EndHorizontal();
else
{
val = (true, GameObject.Instantiate(Resources.Load<GameObject>("KeyValuePanel")).GetComponent<KeyValuePanel>());
val.Item2.transform.SetParent(contentPanel.transform, false);
}
val.Item2.SetKey(key);
}
else
{
val = entries[key];
val.Item1 = true;
val.Item2.SetValue(value);
entries[key] = val;
GUILayout.EndScrollView();
GUILayout.EndArea();
/// <param name="labeler">The labeler that requested the removal</param>
public void RemoveEntry(string key)
public void RemoveEntry(CameraLabeler labeler, string key)
if (entries.ContainsKey(key))
if (m_Entries.ContainsKey(labeler))
var entry = entries[key];
entry.Item2.gameObject.SetActive(false);
entries.Remove(key);
orphans.Push(entry.Item2);
m_Entries[labeler].Remove(key);
}
}

/// <param name="keys">List of keys to remove from the panel</param>
public void RemoveEntries(List<string> keys)
{
foreach (var k in keys) RemoveEntry(k);
}
/// <summary>
/// Removes all of the passed in entries from the HUD
/// </summary>
/// <param name="keys">List of keys t remove from the panel</param>
public void RemoveEntries(string[] keys)
/// <param name="labeler">The labeler that requested the removal</param>
public void RemoveEntries(CameraLabeler labeler)
foreach (var k in keys) RemoveEntry(k);
m_Entries.Remove(labeler);
}
}
}

23
com.unity.perception/Runtime/GroundTruth/Labeling/IdLabelEntry.cs


/// An entry for <see cref="IdLabelConfig"/> mapping a label to an integer id.
/// </summary>
[Serializable]
public struct IdLabelEntry : ILabelEntry
public struct IdLabelEntry : ILabelEntry, IEquatable<IdLabelEntry>
{
string ILabelEntry.label => this.label;
/// <summary>

/// The id to associate with the label.
/// </summary>
public int id;
/// <inheritdoc/>
public bool Equals(IdLabelEntry other)
{
return label == other.label && id == other.id;
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is IdLabelEntry other && Equals(other);
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return ((label != null ? label.GetHashCode() : 0) * 397) ^ id;
}
}
}
}

9
com.unity.perception/Runtime/GroundTruth/Labeling/LabelEntryMatchCache.cs


const int k_StartingObjectCount = 1 << 8;
NativeList<ushort> m_InstanceIdToLabelEntryIndexLookup;
IdLabelConfig m_IdLabelConfig;
ushort m_DefaultValue;
public LabelEntryMatchCache(IdLabelConfig idLabelConfig)
{

{
labelEntry = default;
index = -1;
if (m_InstanceIdToLabelEntryIndexLookup.Length <= instanceId)
if (m_InstanceIdToLabelEntryIndexLookup.Length <= instanceId || m_InstanceIdToLabelEntryIndexLookup[(int)instanceId] == m_DefaultValue)
return false;
index = m_InstanceIdToLabelEntryIndexLookup[(int)instanceId];

{
if (m_IdLabelConfig.TryGetMatchingConfigurationEntry(labeling, out _, out var index))
{
m_DefaultValue = ushort.MaxValue;
Debug.Assert(index < m_DefaultValue, "Too many entries in the label config");
var oldLength = m_InstanceIdToLabelEntryIndexLookup.Length;
for (int i = oldLength; i < instanceId; i++)
m_InstanceIdToLabelEntryIndexLookup[i] = m_DefaultValue;
}
m_InstanceIdToLabelEntryIndexLookup[(int)instanceId] = (ushort)index;
}

22
com.unity.perception/Runtime/GroundTruth/Labeling/Labeling.cs


public class Labeling : MonoBehaviour
{
/// <summary>
/// The label names to associate with the GameObject.
/// The label names to associate with the GameObject. Modifications to this list after the Update() step of the frame the object is created in are
/// not guaranteed to be reflected by labelers.
/// <summary>
/// The unique id of this labeling component instance
/// </summary>
public uint instanceId { get; private set; }
internal void SetInstanceId(uint instanceId)
{
this.instanceId = instanceId;
}
void Awake()
{
m_Entity = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity();

{
if (World.DefaultGameObjectInjectionWorld != null)
World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(m_Entity);
}
/// <summary>
/// Refresh ground truth generation for the labeling of the attached GameObject. This is necessary when the
/// list of labels changes or when renderers or materials change on objects in the hierarchy.
/// </summary>
public void RefreshLabeling()
{
World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<GroundTruthLabelSetupSystem>().RefreshLabeling(m_Entity);
}
}
}

197
com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs


using System;
using System;
using System.IO;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Profiling;
using Unity.Simulation;
using UnityEngine;

using UnityEngine.Serialization;
using UnityEngine.UI;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#endif

/// </summary>
public string description;
/// <summary>
/// The period in seconds that the Camera should render
/// The interval in seconds at which the camera should render and capture.
/// </summary>
public float period = .0166f;
/// <summary>

Dictionary<string, object> m_PersistentSensorData = new Dictionary<string, object>();
int m_LastFrameCaptured = -1;
Ego m_EgoMarker;
#pragma warning disable 414
//only used to confirm that GroundTruthRendererFeature is present in URP

static PerceptionCamera s_VisualizedPerceptionCamera;
static GameObject s_VisualizationCamera;
static GameObject s_VisualizationCanvas;
/// <summary>
/// Turns on/off the realtime visualization capability.

bool m_ShowingVisualizations;
bool m_ShowingVisualizations = false;
public SensorHandle SensorHandle { get; private set; }
public SensorHandle SensorHandle
{
get
{
EnsureSensorRegistered();
return m_SensorHandle;
}
private set => m_SensorHandle = value;
}
SensorHandle m_SensorHandle;
Ego m_EgoMarker;
static ProfilerMarker s_WriteFrame = new ProfilerMarker("Write Frame (PerceptionCamera)");
static ProfilerMarker s_EncodeAndSave = new ProfilerMarker("Encode and save (PerceptionCamera)");

passes.Add(pass);
}
#endif
VisualizationCanvas visualizationCanvas => m_ShowingVisualizations ? s_VisualizationCanvas.GetComponent<VisualizationCanvas>() : null;
/// <summary>
/// Add a data object which will be added to the dataset with each capture. Overrides existing sensor data associated with the given key.

// Start is called before the first frame update
void Awake()
{
m_EgoMarker = this.GetComponentInParent<Ego>();
var ego = m_EgoMarker == null ? DatasetCapture.RegisterEgo("") : m_EgoMarker.EgoHandle;
SensorHandle = DatasetCapture.RegisterSensor(ego, "camera", description, period, startTime);
AsyncRequest.maxJobSystemParallelism = 0; // Jobs are not chained to one another in any way, maximizing parallelism
AsyncRequest.maxAsyncRequestFrameAge = 4; // Ensure that readbacks happen before Allocator.TempJob allocations get stale

#if UNITY_EDITOR || DEVELOPMENT_BUILD
#endif
void EnsureSensorRegistered()
{
if (m_SensorHandle.IsNil)
{
m_EgoMarker = GetComponentInParent<Ego>();
var ego = m_EgoMarker == null ? DatasetCapture.RegisterEgo("") : m_EgoMarker.EgoHandle;
SensorHandle = DatasetCapture.RegisterSensor(ego, "camera", description, period, startTime);
}
}
void OnEnable()
{
RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;

void Start()
{
var cam = GetComponent<Camera>();
cam.enabled = false;
}
internal HUDPanel hudPanel = null;
#if !UNITY_EDITOR && !DEVELOPMENT_BUILD
showVisualizations = false;
#else
var visualizationAllowed = s_VisualizedPerceptionCamera == null;
if (!visualizationAllowed && showVisualizations)

m_ShowingVisualizations = true;
s_VisualizedPerceptionCamera = this;
// set up to render to a render texture instead of the screen
var visualizationRenderTexture = new RenderTexture(cam.pixelWidth, cam.pixelHeight, 8, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
visualizationRenderTexture.name = cam.name + "_visualization_texture";
cam.targetTexture = visualizationRenderTexture;
s_VisualizationCamera = new GameObject(cam.name + "_VisualizationCamera");
var visualizationCameraComponent = s_VisualizationCamera.AddComponent<Camera>();
int layerMask = 1 << LayerMask.NameToLayer("UI");
visualizationCameraComponent.orthographic = true;
visualizationCameraComponent.cullingMask = layerMask;
s_VisualizationCanvas = GameObject.Instantiate(Resources.Load<GameObject>("VisualizationUI"));
s_VisualizationCanvas.name = cam.name + "_VisualizationCanvas";
var canvas = s_VisualizationCanvas.GetComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.worldCamera = visualizationCameraComponent;
var imgObj = new GameObject(cam.name + "_Image");
var img = imgObj.AddComponent<RawImage>();
img.texture = visualizationRenderTexture;
var rect = imgObj.transform as RectTransform;
rect.SetParent(s_VisualizationCanvas.transform, false);
//ensure the rgb image is rendered in the back
rect.SetAsFirstSibling();
rect.anchorMin = new Vector2(0, 0);
rect.anchorMax = new Vector2(1, 1);
rect.pivot = new Vector2(0.5f, 0.5f);
rect.offsetMax = Vector2.zero;
rect.offsetMin = Vector2.zero;
hudPanel = gameObject.AddComponent<HUDPanel>();
#endif
}
void CheckForRendererFeature(ScriptableRenderContext context, Camera camera)

// Update is called once per frame
void Update()
{
EnsureSensorRegistered();
var cam = GetComponent<Camera>(); // TODO I don't like this... Get the camera handle, we should have it
cam.enabled = SensorHandle.ShouldCaptureThisFrame;
bool anyVisualizing = false;
foreach (var labeler in m_Labelers)

if (!labeler.isInitialized)
{
labeler.Init(this, visualizationCanvas);
labeler.Init(this);
}
labeler.InternalOnUpdate();

// Currently there is an issue in the perception camera that causes the UI layer not to be visualized
// if we are utilizing async readback and we have to flip our captured image. We have created a jira
// issue for this (aisv-779) and have notified the engine team about this.
anyVisualizing = true;
void LateUpdate()
private Vector2 scrollPosition;
private const float panelWidth = 200;
private const float panelHeight = 250;
private void SetUpGUIStyles()
{
GUI.skin.label.fontSize = 12;
GUI.skin.label.font = Resources.Load<Font>("Inter-Light");
GUI.skin.label.padding = new RectOffset(0, 0, 1, 1);
GUI.skin.label.margin = new RectOffset(0, 0, 1, 1);
GUI.skin.box.padding = new RectOffset(5, 5, 5, 5);
GUI.skin.toggle.margin = new RectOffset(0, 0, 0, 0);
GUI.skin.horizontalSlider.margin = new RectOffset(0, 0, 0, 0);
m_GUIStylesInitialized = true;
}
private bool m_GUIStylesInitialized = false;
private void DisplayNoLabelersMessage()
var cam = GetComponent<Camera>();
if (showVisualizations)
var x = Screen.width - panelWidth - 10;
var height = Math.Min(Screen.height * 0.5f - 20, 90);
GUILayout.BeginArea(new Rect(x, 10, panelWidth, height), GUI.skin.box);
GUILayout.Label("Visualization: No labelers are currently active. Enable at least one labeler from the inspector window of your perception camera to see visualizations.");
// If a labeler has never been initialized then it was off from the
// start, it should not be called to draw on the UI
foreach (var labeler in m_Labelers.Where(labeler => labeler.isInitialized))
cam.enabled = false;
if (SensorHandle.ShouldCaptureThisFrame) cam.Render();
labeler.VisualizeUI();
GUILayout.Space(4);
else
cam.enabled = SensorHandle.ShouldCaptureThisFrame;
GUILayout.EndArea();
}
private void OnGUI()
{
if (!m_ShowingVisualizations) return;
if (!m_GUIStylesInitialized) SetUpGUIStyles();
GUI.depth = 5;
var anyLabelerEnabled = false;
// If a labeler has never been initialized then it was off from the
// start, it should not be called to draw on the UI
foreach (var labeler in m_Labelers.Where(labeler => labeler.isInitialized))
{
labeler.Visualize();
anyLabelerEnabled = true;
}
if (!anyLabelerEnabled)
{
DisplayNoLabelersMessage();
return;
}
GUI.depth = 0;
hudPanel.OnDrawGUI();
var x = Screen.width - panelWidth - 10;
var height = Math.Min(Screen.height * 0.5f - 20, panelHeight);
GUILayout.BeginArea(new Rect(x, 10, panelWidth, height), GUI.skin.box);
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
// If a labeler has never been initialized then it was off from the
// start, it should not be called to draw on the UI
foreach (var labeler in m_Labelers.Where(labeler => labeler.isInitialized))
{
labeler.VisualizeUI();
GUILayout.Space(4);
}
GUILayout.EndScrollView();
GUILayout.EndArea();
}
void OnValidate()

}
};
CaptureCamera.Capture(cam, colorFunctor, flipY: ShouldFlipY(cam));
CaptureCamera.Capture(cam, colorFunctor, flipY: flipY);
Profiler.EndSample();
}

{
#if HDRP_PRESENT
var hdAdditionalCameraData = GetComponent<HDAdditionalCameraData>();

continue;
if (!labeler.isInitialized)
labeler.Init(this, visualizationCanvas);
labeler.Init(this);
labeler.InternalOnBeginRendering();
}

{
if (s_VisualizedPerceptionCamera == this)
{
Destroy(s_VisualizationCamera);
Destroy(s_VisualizationCanvas);
s_VisualizationCamera = null;
s_VisualizationCanvas = null;
}
}

54
com.unity.perception/Runtime/GroundTruth/PerceptionCamera_InstanceSegmentation.cs


using Unity.Collections;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#endif
#if URP_PRESENT
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#elif URP_PRESENT
using UnityEngine.Rendering.Universal;
#endif
namespace UnityEngine.Perception.GroundTruth

RenderTexture m_InstanceSegmentationTexture;
RenderTextureReader<uint> m_InstanceSegmentationReader;
internal bool m_fLensDistortionEnabled = false;
#if HDRP_PRESENT || URP_PRESENT
#if HDRP_PRESENT
InstanceSegmentationPass m_InstanceSegmentationPass;
LensDistortionPass m_LensDistortionPass;
#elif URP_PRESENT
InstanceSegmentationUrpPass m_InstanceSegmentationPass;
LensDistortionUrpPass m_LensDistortionPass;
#endif
internal void OverrideLensDistortionIntensity(float? intensity)
{
m_LensDistortionPass.m_LensDistortionCrossPipelinePass.lensDistortionOverride = intensity;
}
#endif
void SetupInstanceSegmentation()
{
var myCamera = GetComponent<Camera>();

m_InstanceSegmentationTexture.filterMode = FilterMode.Point;
m_InstanceSegmentationTexture.name = "InstanceSegmentation";
m_RenderedObjectInfoGenerator = new RenderedObjectInfoGenerator();

customPassVolume.injectionPoint = CustomPassInjectionPoint.BeforeRendering;
customPassVolume.isGlobal = true;
var instanceSegmentationPass = new InstanceSegmentationPass()
m_InstanceSegmentationPass = new InstanceSegmentationPass()
instanceSegmentationPass.EnsureInit();
customPassVolume.customPasses.Add(instanceSegmentationPass);
#endif
#if URP_PRESENT
AddScriptableRenderPass(new InstanceSegmentationUrpPass(myCamera, m_InstanceSegmentationTexture));
m_InstanceSegmentationPass.EnsureInit();
customPassVolume.customPasses.Add(m_InstanceSegmentationPass);
m_LensDistortionPass = new LensDistortionPass(GetComponent<Camera>(), m_InstanceSegmentationTexture)
{
name = "Instance Segmentation Lens Distortion Pass"
};
m_LensDistortionPass.EnsureInit();
customPassVolume.customPasses.Add(m_LensDistortionPass);
m_fLensDistortionEnabled = true;
#elif URP_PRESENT
m_InstanceSegmentationPass = new InstanceSegmentationUrpPass(myCamera, m_InstanceSegmentationTexture);
AddScriptableRenderPass(m_InstanceSegmentationPass);
// Lens Distortion
m_LensDistortionPass = new LensDistortionUrpPass(myCamera, m_InstanceSegmentationTexture);
AddScriptableRenderPass(m_LensDistortionPass);
m_fLensDistortionEnabled = true;
#endif
m_InstanceSegmentationReader = new RenderTextureReader<uint>(m_InstanceSegmentationTexture, myCamera, (frameCount, data, tex) =>

11
com.unity.perception/Runtime/GroundTruth/Resources/InstanceSegmentation.shader


#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
#include "UnityCG.cginc"
#include "Packing.hlsl"
struct appdata
{

fixed4 frag (v2f i) : SV_Target
{
return float4(UnpackUIntToFloat((uint)_SegmentationId, 0, 8), UnpackUIntToFloat(_SegmentationId, 8, 8), UnpackUIntToFloat(_SegmentationId, 16, 8), UnpackUIntToFloat(_SegmentationId, 24, 8));
return fixed4(
UnpackUIntToFloat((uint)_SegmentationId, 0, 8),
UnpackUIntToFloat((uint)_SegmentationId, 8, 8),
UnpackUIntToFloat((uint)_SegmentationId, 16, 8),
UnpackUIntToFloat((uint)_SegmentationId, 24, 8)
);
}
ENDCG
}

18
com.unity.perception/Runtime/GroundTruth/Resources/LabeledObjectHistogram.compute


return objectId;
}
// For each pixel in the segmentation image, set InstanceIdPresenceMask[pixelValue] to 1
// For each pixel in the segmentation image, set InstanceIdPresenceMask[pixelValue] to 1
[numthreads(8,8,1)]
void PresenseMask (uint3 id : SV_DispatchThreadID)
{

//Attempt at packing presense into single bits. Good for memory, bad for perf due to InterlockedOr.
//Attempt at packing presense into single bits. Good for memory, bad for perf due to InterlockedOr.
//InterlockedOr(IdPresenceMask[maskOffset], 1 << bitOffset);
}

uint mask = InstanceIdPresenceMask[id.x];
if (mask > 0)
InterlockedAdd(ClassCounts[InstanceIdToClassId[id.x]], 1);
//Attempt at packing presense into single bits. Good for memory, bad for perf due to InterlockedOr in PresenseMask(...).
//Attempt at packing presense into single bits. Good for memory, bad for perf due to InterlockedOr in PresenseMask(...).
//int idStart = id.x * 32;
//for(int i = 0; i < 32 ; i++)
//{

// InterlockedAdd(ClassCounts[InstanceIdToClassId[idStart + i]], 1);
// }
//}
}
}

21
com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader


CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma vertex semanticSegmentationVertexStage
#pragma fragment semanticSegmentationFragmentStage
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
#include "UnityCG.cginc"
struct appdata
struct in_vert
struct v2f
struct vertexToFragment
v2f vert (appdata v)
vertexToFragment semanticSegmentationVertexStage (in_vert vertWorldSpace)
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
vertexToFragment vertScreenSpace;
vertScreenSpace.vertex = UnityObjectToClipPos(vertWorldSpace.vertex);
return vertScreenSpace;
fixed4 frag (v2f i) : SV_Target
fixed4 semanticSegmentationFragmentStage (vertexToFragment vertScreenSpace) : SV_Target
{
return LabelingId;
}

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


{
base.Setup();
m_ClassLabelingShader = Shader.Find(k_ShaderName);
shaderVariantCollection.Add(new ShaderVariantCollection.ShaderVariant(m_ClassLabelingShader, PassType.ScriptableRenderPipeline));
shaderVariantCollection.WarmUp();
if (shaderVariantCollection != null)
{
shaderVariantCollection.Add(new ShaderVariantCollection.ShaderVariant(m_ClassLabelingShader, PassType.ScriptableRenderPipeline));
}
shaderVariantCollection.WarmUp();
}
protected override void ExecutePass(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult)

67
com.unity.perception/Runtime/GroundTruth/SimulationState.cs


using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
using Unity.Collections;
using Unity.Mathematics;
using Unity.Simulation;
using UnityEngine;
using UnityEngine.Profiling;

{
partial class SimulationState
{
public string OutputDirectory { get; }
HashSet<SensorHandle> m_ActiveSensors = new HashSet<SensorHandle>();
Dictionary<SensorHandle, SensorData> m_Sensors = new Dictionary<SensorHandle, SensorData>();
HashSet<EgoHandle> m_Egos = new HashSet<EgoHandle>();

CustomSampler m_SerializeMetricsAsyncSampler = CustomSampler.Create("SerializeMetricsAsync");
CustomSampler m_GetOrCreatePendingCaptureForThisFrameSampler = CustomSampler.Create("GetOrCreatePendingCaptureForThisFrame");
float m_LastTimeScale;
readonly string m_OutputDirectoryName;
string m_OutputDirectoryPath;
public string OutputDirectory
{
get
{
if (m_OutputDirectoryPath == null)
m_OutputDirectoryPath = Manager.Instance.GetDirectoryFor(m_OutputDirectoryName);
return m_OutputDirectoryPath;
}
}
//A sensor will be triggered if sequenceTime is within includeThreshold seconds of the next trigger
const float k_IncludeInFrameThreshold = .01f;
const int k_MinPendingCapturesBeforeWrite = 150;

public SimulationState(string outputDirectory)
{
OutputDirectory = outputDirectory;
m_OutputDirectoryName = outputDirectory;
IsRunning = true;
}

}
}
public string GetOutputDirectoryNoCreate() => Path.Combine(Configuration.Instance.GetStoragePath(), m_OutputDirectoryName);
void EnsureSequenceTimingsUpdated()
{
if (!m_HasStarted)

float SequenceTimeOfNextCapture(SensorData sensorData)
{
// If the first capture hasn't happened yet, sequenceTimeNextCapture field won't be valid
return sensorData.period - (UnscaledSequenceTime - sensorData.firstCaptureTime) % sensorData.period;
return sensorData.sequenceTimeNextCapture;
}
public bool Contains(Guid id) => m_Ids.Contains(id);

if (!activeSensor.ShouldCaptureThisFrame)
continue;
//Just in case we get in a situation where we are so far beyond sequenceTimeNextCapture that incrementing next time by the period still doesn't get us to a time past "now"
do
{
sensorData.sequenceTimeNextCapture += sensorData.period;
}
while (sensorData.sequenceTimeNextCapture <= UnscaledSequenceTime);
// TODO: AISV-845 This is an errant modification of this record that can lead to undefined behavior
// Leaving as-is for now because too many components depend on this logic
sensorData.sequenceTimeNextCapture += sensorData.period;
Debug.Assert(sensorData.sequenceTimeNextCapture > UnscaledSequenceTime,
$"Next scheduled capture should be after {UnscaledSequenceTime} but is {sensorData.sequenceTimeNextCapture}");
// sensorData.sequenceTimeNextCapture = SequenceTimeOfNextCapture(sensorData);
sensorData.lastCaptureFrameCount = Time.frameCount;
m_Sensors[activeSensor] = sensorData;
}

return new AsyncAnnotation(ReportAnnotationFile(annotationDefinition, sensorHandle, null), this);
}
public void ReportAsyncAnnotationResult<T>(AsyncAnnotation asyncAnnotation, string filename = null, T[] values = null)
public void ReportAsyncAnnotationResult<T>(AsyncAnnotation asyncAnnotation, string filename = null, NativeSlice<T> values = default) where T : struct
{
var jArray = new JArray();
foreach (var value in values)
jArray.Add(new JRaw(DatasetJsonUtility.ToJToken(value)));
ReportAsyncAnnotationResult<T>(asyncAnnotation, filename, jArray);
}
public void ReportAsyncAnnotationResult<T>(AsyncAnnotation asyncAnnotation, string filename = null, IEnumerable<T> values = null)
{
var jArray = values == null ? null : JArray.FromObject(values);
ReportAsyncAnnotationResult<T>(asyncAnnotation, filename, jArray);
}
void ReportAsyncAnnotationResult<T>(AsyncAnnotation asyncAnnotation, string filename, JArray jArray)
int annotationIndex = -1;
break;
annotationIndex = pendingCapture.Annotations.FindIndex(a => a.Item1.Equals(asyncAnnotation.Annotation));
if (annotationIndex != -1)
break;
Debug.Assert(pendingCapture != null);
Debug.Assert(pendingCapture != null && annotationIndex != -1);
var annotationIndex = pendingCapture.Annotations.FindIndex(a => a.Item1.Equals(asyncAnnotation.Annotation));
annotationData.ValuesJson = values == null ? null : JArray.FromObject(values);
annotationData.ValuesJson = jArray;
annotationTuple.Item2 = annotationData;
pendingCapture.Annotations[annotationIndex] = annotationTuple;

6
com.unity.perception/Tests/Editor/BuildPerceptionPlayer.cs


[Test]
public void BuildPlayerStandaloneWindows64()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, " BuildTarget.StandaloneWindows64 failed to build");
}

{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}

public void BuildPlayerOSX()
{
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, m_BuildPath, BuildOptions.IncludeTestAssemblies, out _, out m_Summary);
BuildPlayer(BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX, m_BuildPath, BuildOptions.None, out _, out m_Summary);
Assert.AreEqual(BuildResult.Succeeded, m_Summary.result, "BuildTarget.StandaloneLinux64 failed to build");
}

19
com.unity.perception/Tests/Editor/DatasetCaptureEditorTests.cs


using System;
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.TestTools;
[TestFixture]
[Serializable]
[SerializeField]
string expectedDatasetPath;
[Test]
public void RegisterEgo_InEditMode_Throws()
{

public void RegisterMetricDefinition_InEditMode_Throws()
{
Assert.Throws<InvalidOperationException>(() => DatasetCapture.RegisterMetricDefinition(""));
}
[UnityTest]
public IEnumerator SimpleData_GeneratesFullDataset_OnExitPlaymode()
{
yield return new EnterPlayMode();
var ego = DatasetCapture.RegisterEgo("ego");
var sensor = DatasetCapture.RegisterSensor(ego, "camera", "", 0.1f, 0);
sensor.ReportCapture("file.txt", new SensorSpatialData());
expectedDatasetPath = DatasetCapture.OutputDirectory;
yield return new ExitPlayMode();
FileAssert.Exists(Path.Combine(expectedDatasetPath, "sensors.json"));
}
}
}

64
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs


using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text.RegularExpressions;
using NUnit.Framework;
using UnityEngine;

namespace GroundTruthTests
{
// Provides accessors and invocation methods for members of SimulationState that would otherwise be in-accessible
// due to protection level - use only when testing protected logic is critical
class SimulationStateTestHelper
{
SimulationState m_State => DatasetCapture.SimulationState;
Dictionary<SensorHandle, SimulationState.SensorData> m_SensorsReference;
MethodInfo m_SequenceTimeOfNextCaptureMethod;
internal SimulationStateTestHelper()
{
var bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
m_SequenceTimeOfNextCaptureMethod = m_State.GetType().GetMethod("SequenceTimeOfNextCapture", bindingFlags);
Debug.Assert(m_SequenceTimeOfNextCaptureMethod != null, "Couldn't find sequence time method.");
var sensorsField = m_State.GetType().GetField("m_Sensors", bindingFlags);
Debug.Assert(sensorsField != null, "Couldn't find internal sensors field");
m_SensorsReference = (Dictionary<SensorHandle, SimulationState.SensorData>)(sensorsField.GetValue(m_State));
Debug.Assert(m_SensorsReference != null, "Couldn't cast sensor field to dictionary");
}
internal float CallSequenceTimeOfNextCapture(SimulationState.SensorData sensorData)
{
return (float)m_SequenceTimeOfNextCaptureMethod.Invoke(m_State, new object[] { sensorData });
}
internal SimulationState.SensorData GetSensorData(SensorHandle sensorHandle)
{
return m_SensorsReference[sensorHandle];
}
}
SimulationStateTestHelper m_TestHelper;
[SetUp]
public void SetUp()
{
m_TestHelper = new SimulationStateTestHelper();
}
[TearDown]
public void TearDown()
{

#if SIMULATION_TOOLS_PRESENT
[Unity.Simulation.Tools.CloudTest]
#endif
public IEnumerator SequenceTimeOfNextCapture_ReportsCorrectTime()
{
var ego = DatasetCapture.RegisterEgo("ego");
var firstCaptureTime = 1.5f;
var period = .4f;
var sensorHandle = DatasetCapture.RegisterSensor(ego, "cam", "", period, firstCaptureTime);
float[] sequenceTimesExpected =
{
firstCaptureTime,
period + firstCaptureTime,
period * 2 + firstCaptureTime,
period * 3 + firstCaptureTime
};
for (var i = 0; i < sequenceTimesExpected.Length; i++)
{
yield return null;
var sensorData = m_TestHelper.GetSensorData(sensorHandle);
var sequenceTimeActual = m_TestHelper.CallSequenceTimeOfNextCapture(sensorData);
Assert.AreEqual(sequenceTimesExpected[i], sequenceTimeActual, 0.0001f);
}
}
[UnityTest]
public IEnumerator FramesScheduledBySensorConfig()
{
var ego = DatasetCapture.RegisterEgo("ego");

6
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs.meta


defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
userData:
assetBundleName:
assetBundleVariant:

46
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs


using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;

StringAssert.Contains(TestHelper.NormalizeJson(expectedAnnotation), EscapeGuids(File.ReadAllText(capturesPath)));
}
[UnityTest]
public IEnumerator AnnotationAsyncReportResult_FindsCorrectPendingCaptureAfterStartingNewSequence()
{
const string fileName = "my/file.png";
var value = new[]
{
new TestValues()
{
a = "a string",
b = 10
}
};
var ego = DatasetCapture.RegisterEgo("");
var annotationDefinition = DatasetCapture.RegisterAnnotationDefinition("");
var sensorHandle = DatasetCapture.RegisterSensor(ego, "", "", 1, 0);
// Record one capture for this frame
sensorHandle.ReportCapture(fileName, default);
// Wait one frame
yield return null;
// Reset the capture step
DatasetCapture.StartNewSequence();
// Record a new capture on different frame that has the same step (0) as the first capture
sensorHandle.ReportCapture(fileName, default);
// Confirm that the annotation correctly skips the first pending capture to write to the second
var asyncAnnotation = sensorHandle.ReportAnnotationAsync(annotationDefinition);
Assert.DoesNotThrow(() => asyncAnnotation.ReportValues(value));
DatasetCapture.ResetSimulation();
}
[Test]
#if SIMULATION_TOOLS_PRESENT
[Unity.Simulation.Tools.CloudTest]

if (escapeGuids)
jsonActual = EscapeGuids(jsonActual);
if (ignoreFormatting)
{
jsonActual = Regex.Replace(jsonActual, "^\\s*", "", RegexOptions.Multiline);
jsonExpected = Regex.Replace(jsonExpected, "^\\s*", "", RegexOptions.Multiline);
}
jsonActual = TestHelper.NormalizeJson(jsonActual);
jsonExpected = TestHelper.NormalizeJson(jsonExpected);
jsonActual = TestHelper.NormalizeJson(jsonActual, ignoreFormatting);
jsonExpected = TestHelper.NormalizeJson(jsonExpected, ignoreFormatting);
Assert.AreEqual(jsonExpected, jsonActual, $"Expected:\n{jsonExpected}\nActual:\n{jsonActual}");
}

6
com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs.meta


defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
userData:
assetBundleName:
assetBundleVariant:

50
com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs


//give the screen a chance to resize
yield return null;
var jsonExpected = $@" {{
var jsonExpected = $@"[
{{
""label_id"": 100,
""label_name"": ""label"",
""instance_id"": 1,

""height"": {Screen.height / 2:F1}
}}";
}}
]";
var labelingConfiguration = CreateLabelingConfiguration();
SetupCamera(pc =>
{

AddTestObjectForCleanup(plane);
//a plane is 10x10 by default, so scale it down to be 10x1 to cover the center half of the image
plane.transform.localScale = new Vector3(10f, -1f, .1f);
plane.transform.localPosition = new Vector3(0, 0, 10);
var plane2 = TestHelper.CreateLabeledPlane(label: "nonmatching");
AddTestObjectForCleanup(plane2);
//place a smaller plane in front to test non-matching objects
plane2.transform.localScale = new Vector3(.1f, -1f, .1f);
plane2.transform.localPosition = new Vector3(0, 0, 5);
StringAssert.Contains(jsonExpected, capturesJson);
StringAssert.Contains(TestHelper.NormalizeJson(jsonExpected, true), TestHelper.NormalizeJson(capturesJson, true));
}
[UnityTest]
public IEnumerator EnableSemanticSegmentation_GeneratesCorrectDataset([Values(true, false)] bool enabled)
{
SetupCamera(pc =>
{
pc.AddLabeler(new SemanticSegmentationLabeler(CreateSemanticSegmentationLabelConfig()));
}, enabled);
string expectedImageFilename = $"segmentation_{Time.frameCount}.png";
this.AddTestObjectForCleanup(TestHelper.CreateLabeledPlane());
yield return null;
DatasetCapture.ResetSimulation();
if (enabled)
{
var capturesPath = Path.Combine(DatasetCapture.OutputDirectory, "captures_000.json");
var capturesJson = File.ReadAllText(capturesPath);
var imagePath = $"SemanticSegmentation/{expectedImageFilename}";
StringAssert.Contains(imagePath, capturesJson);
}
else
{
DirectoryAssert.DoesNotExist(DatasetCapture.OutputDirectory);
}
}
[UnityTest]

public IEnumerator EnableSemanticSegmentation_GeneratesCorrectDataset()
public IEnumerator Disabled_GeneratesCorrectDataset()
{
SetupCamera(pc =>
{

return labelingConfiguration;
}
void SetupCamera(Action<PerceptionCamera> initPerceptionCamera)
void SetupCamera(Action<PerceptionCamera> initPerceptionCamera, bool activate = true)
{
var cameraObject = new GameObject();
cameraObject.SetActive(false);

perceptionCamera.captureRgbImages = false;
initPerceptionCamera?.Invoke(perceptionCamera);
cameraObject.SetActive(true);
if (activate)
cameraObject.SetActive(true);
AddTestObjectForCleanup(cameraObject);
}
}

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


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Unity.Simulation;
using UnityEngine.Rendering.HighDefinition;
#elif URP_PRESENT
using UnityEngine.Rendering.Universal;
using UnityEngine.TestTools;
using Object = UnityEngine.Object;

Assert.AreEqual(4, timesSegmentationImageReceived);
}
// Lens Distortion is only applicable in URP or HDRP pipelines
// As such, this test will always fail if URP or HDRP are not present (and also not really compile either)
#if HDRP_PRESENT || URP_PRESENT
[UnityTest]
public IEnumerator SemanticSegmentationPass_WithLensDistortion()
{
GameObject cameraObject = null;
PerceptionCamera perceptionCamera;
bool fLensDistortionEnabled = false;
bool fDone = false;
int frames = 0;
var dataBBox = new uint[]
{
1, 1,
1, 1
};
Rect boundingBoxWithoutLensDistortion = new Rect();
Rect boundingBoxWithLensDistortion = new Rect();
void OnSegmentationImageReceived(int frameCount, NativeArray<uint> data, RenderTexture tex)
{
frames++;
if (frames < 10)
return;
// Calculate the bounding box
if (fLensDistortionEnabled == false)
{
fLensDistortionEnabled = true;
var renderedObjectInfoGenerator = new RenderedObjectInfoGenerator();
renderedObjectInfoGenerator.Compute(data, tex.width, BoundingBoxOrigin.TopLeft, out var boundingBoxes, Allocator.Temp);
boundingBoxWithoutLensDistortion = boundingBoxes[0].boundingBox;
// Add lens distortion
perceptionCamera.OverrideLensDistortionIntensity(0.715f);
frames = 0;
}
else
{
var renderedObjectInfoGenerator = new RenderedObjectInfoGenerator();
renderedObjectInfoGenerator.Compute(data, tex.width, BoundingBoxOrigin.TopLeft, out var boundingBoxes, Allocator.Temp);
boundingBoxWithLensDistortion = boundingBoxes[0].boundingBox;
Assert.AreNotEqual(boundingBoxWithoutLensDistortion, boundingBoxWithLensDistortion);
Assert.Greater(boundingBoxWithLensDistortion.width, boundingBoxWithoutLensDistortion.width);
fDone = true;
}
}
cameraObject = SetupCamera(out perceptionCamera, false);
perceptionCamera.InstanceSegmentationImageReadback += OnSegmentationImageReceived;
cameraObject.SetActive(true);
// Put a plane in front of the camera
var planeObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
planeObject.transform.SetPositionAndRotation(new Vector3(0, 0, 10), Quaternion.Euler(90, 0, 0));
planeObject.transform.localScale = new Vector3(0.1f, -1, 0.1f);
var labeling = planeObject.AddComponent<Labeling>();
labeling.labels.Add("label");
AddTestObjectForCleanup(planeObject);
perceptionCamera.OverrideLensDistortionIntensity(0.5f);
while (fDone != true)
{
yield return null;
}
// Destroy the object to force all pending segmented image readbacks to finish and events to be fired.
DestroyTestObject(cameraObject);
DestroyTestObject(planeObject);
}
#endif // ! HDRP_PRESENT || URP_PRESENT
[UnityTest]
#if SIMULATION_TOOLS_PRESENT
[Unity.Simulation.Tools.CloudTest]

AddTestObjectForCleanup(TestHelper.CreateLabeledPlane());
yield return null;
//NativeArray<Color32> readbackArray = new NativeArray<Color32>(targetTextureOverride.width * targetTextureOverride.height, Allocator.Temp);
var request = AsyncGPUReadback.Request(targetTextureOverride, callback: r =>
TestHelper.ReadRenderTextureRawData<Color32>(targetTextureOverride, data =>
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, targetTextureOverride.width * targetTextureOverride.height), r.GetData<Color32>());
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, targetTextureOverride.width * targetTextureOverride.height), data);
AsyncGPUReadback.WaitAllRequests();
//request.WaitForCompletion();
Assert.IsTrue(request.done);
Assert.IsFalse(request.hasError);
}
[UnityTest]
public IEnumerator SemanticSegmentationPass_WithMultiMaterial_ProducesCorrectValues([Values(true, false)] bool showVisualizations)
{
int timesSegmentationImageReceived = 0;
var expectedPixelValue = k_SemanticPixelValue;
void OnSegmentationImageReceived(NativeArray<Color32> data)
{
timesSegmentationImageReceived++;
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data);
}
var cameraObject = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceived(a.data), false);
var plane = TestHelper.CreateLabeledPlane();
var meshRenderer = plane.GetComponent<MeshRenderer>();
var baseMaterial = meshRenderer.material;
meshRenderer.materials = new[] { baseMaterial, baseMaterial };
MaterialPropertyBlock mpb = new MaterialPropertyBlock();
mpb.SetFloat("float", 1f);
for (int i = 0; i < 2; i++)
{
meshRenderer.SetPropertyBlock(mpb, i);
}
AddTestObjectForCleanup(plane);
yield return null;
//destroy the object to force all pending segmented image readbacks to finish and events to be fired.
DestroyTestObject(cameraObject);
Assert.AreEqual(1, timesSegmentationImageReceived);
}
[UnityTest]
public IEnumerator SemanticSegmentationPass_WithChangingLabeling_ProducesCorrectValues([Values(true, false)] bool showVisualizations)
{
int timesSegmentationImageReceived = 0;
var expectedPixelValue = k_SemanticPixelValue;
void OnSegmentationImageReceived(NativeArray<Color32> data)
{
if (timesSegmentationImageReceived == 1)
{
CollectionAssert.AreEqual(Enumerable.Repeat(expectedPixelValue, data.Length), data);
}
timesSegmentationImageReceived++;
}
var cameraObject = SetupCameraSemanticSegmentation(a => OnSegmentationImageReceived(a.data), false);
var plane = TestHelper.CreateLabeledPlane(label: "non-matching");
AddTestObjectForCleanup(plane);
yield return null;
var labeling = plane.GetComponent<Labeling>();
labeling.labels = new List<string> { "label" };
labeling.RefreshLabeling();
yield return null;
//destroy the object to force all pending segmented image readbacks to finish and events to be fired.
DestroyTestObject(cameraObject);
Assert.AreEqual(2, timesSegmentationImageReceived);
}
[UnityTest]

24
com.unity.perception/Tests/Runtime/GroundTruthTests/TestHelper.cs


using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Unity.Collections;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Perception.GroundTruth;
namespace GroundTruthTests

return planeObject;
}
public static void ReadRenderTextureRawData<T>(RenderTexture renderTexture, Action<NativeArray<T>> callback) where T : struct
{
RenderTexture.active = renderTexture;
var cpuTexture = new Texture2D(renderTexture.width, renderTexture.height, renderTexture.graphicsFormat, TextureCreationFlags.None);
cpuTexture.ReadPixels(new Rect(
Vector2.zero,
new Vector2(renderTexture.width, renderTexture.height)),
0, 0);
RenderTexture.active = null;
var data = cpuTexture.GetRawTextureData<T>();
callback(data);
}
#if UNITY_EDITOR
public static void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView)
{

}
#endif
public static string NormalizeJson(string json)
public static string NormalizeJson(string json, bool normalizeFormatting = false)
if (normalizeFormatting)
json = Regex.Replace(json, "^\\s*", "", RegexOptions.Multiline);
return json.Replace("\r\n", "\n");
}
}

152
com.unity.perception/Tests/Runtime/GroundTruthTests/VisualizationTests.cs


using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#endif
using Object = UnityEngine.Object;
namespace GroundTruthTests
{

[Test]
#if SIMULATION_TOOLS_PRESENT
[Unity.Simulation.Tools.CloudTest]
#endif
public void VisualizedCamera_SetsUpCanvasAndSecondCamera()
GameObject SetupCameraSemanticSegmentation(string name)
var object1 = new GameObject();
object1.name = nameof(VisualizedCamera_SetsUpCanvasAndSecondCamera);
var object1 = new GameObject(name);
object1.SetActive(true);
AddTestObjectForCleanup(object1);
#if HDRP_PRESENT
var hdAdditionalCameraData = object1.AddComponent<HDAdditionalCameraData>();
#endif
var labelConfig = ScriptableObject.CreateInstance<SemanticSegmentationLabelConfig>();
labelConfig.Init(new List<SemanticSegmentationLabelEntry>()
{
new SemanticSegmentationLabelEntry()
{
label = "label",
color = new Color32(10, 20, 30, System.Byte.MaxValue)
}
});
Assert.IsNotNull(camera.targetTexture);
Assert.IsNotNull(GameObject.Find(nameof(VisualizedCamera_SetsUpCanvasAndSecondCamera) + "_VisualizationCamera"));
Assert.IsNotNull(GameObject.Find(nameof(VisualizedCamera_SetsUpCanvasAndSecondCamera) + "_VisualizationCanvas"));
var semanticSegmentationLabeler = new SemanticSegmentationLabeler(labelConfig);
perceptionCamera1.AddLabeler(semanticSegmentationLabeler);
return object1;
[Test]
[UnityTest]
public IEnumerator VisualizedCamera_SetsUpCanvas()
{
var object1 = SetupCameraSemanticSegmentation(nameof(VisualizedCamera_SetsUpCanvas));
object1.SetActive(true);
AddTestObjectForCleanup(object1);
// Need to wait to make sure a visualization call is made so that the canvas will be constructed
yield return null;
Assert.IsNotNull(GameObject.Find(nameof(VisualizedCamera_SetsUpCanvas) + "_segmentation_canvas"));
}
[Test]
public void TwoCamerasVisualizing_CausesWarningAndDisablesVisualization()
{
var object1 = new GameObject();

#endif
public IEnumerator DestroyCamera_RemovesVisualization()
{
var object1 = new GameObject();
object1.name = nameof(DestroyCamera_RemovesVisualization);
object1.SetActive(false);
object1.AddComponent<Camera>();
var perceptionCamera1 = object1.AddComponent<PerceptionCamera>();
perceptionCamera1.showVisualizations = true;
var object1 = SetupCameraSemanticSegmentation(nameof(DestroyCamera_RemovesVisualization));
Assert.IsNotNull(GameObject.Find(nameof(DestroyCamera_RemovesVisualization) + "_VisualizationCamera"));
//wait a frame to make sure visualize is called once
yield return null;
Assert.IsNotNull(GameObject.Find(nameof(DestroyCamera_RemovesVisualization) + "_segmentation_canvas"));
Assert.IsNull(GameObject.Find(nameof(DestroyCamera_RemovesVisualization) + "_VisualizationCamera"));
Assert.IsNull(GameObject.Find(nameof(DestroyCamera_RemovesVisualization) + "_segmentation_canvas"));
[Test]
public void DestroyAndRecreateCamera_ProperlyVisualizes()
[UnityTest]
public IEnumerator DestroyAndRecreateCamera_ProperlyVisualizes()
var object1 = new GameObject();
object1.name = nameof(DestroyAndRecreateCamera_ProperlyVisualizes);
object1.SetActive(false);
object1.AddComponent<Camera>();
var perceptionCamera1 = object1.AddComponent<PerceptionCamera>();
perceptionCamera1.showVisualizations = true;
var object1 = SetupCameraSemanticSegmentation(nameof(DestroyAndRecreateCamera_ProperlyVisualizes));
//wait a frame to make sure visualize is called once
yield return null;
var object2 = new GameObject();
object2.name = nameof(DestroyAndRecreateCamera_ProperlyVisualizes) + "2";
object2.SetActive(false);
var camera2 = object2.AddComponent<Camera>();
var perceptionCamera2 = object2.AddComponent<PerceptionCamera>();
perceptionCamera2.showVisualizations = true;
var object2 = SetupCameraSemanticSegmentation(nameof(DestroyAndRecreateCamera_ProperlyVisualizes) + "2");
Assert.IsNotNull(camera2.targetTexture);
Assert.IsNotNull(GameObject.Find(nameof(DestroyAndRecreateCamera_ProperlyVisualizes) + "2_VisualizationCamera"));
//wait a frame to make sure visualize is called once
yield return null;
Assert.IsNotNull(GameObject.Find(nameof(DestroyAndRecreateCamera_ProperlyVisualizes) + "2_segmentation_canvas"));
}
[UnityTest]
public IEnumerator TwoLabelersOfSameType_ProperlyStoredInHud()
{
var label = "label";
var planeObject = TestHelper.CreateLabeledPlane(.1f, label);
AddTestObjectForCleanup(planeObject);
var object1 = new GameObject("PerceptionCamera");
object1.SetActive(false);
object1.AddComponent<Camera>();
var perceptionCamera = object1.AddComponent<PerceptionCamera>();
perceptionCamera.showVisualizations = true;
#if HDRP_PRESENT
var hdAdditionalCameraData = object1.AddComponent<HDAdditionalCameraData>();
#endif
var cfg = ScriptableObject.CreateInstance<IdLabelConfig>();
cfg.Init(new List<IdLabelEntry>
{
new IdLabelEntry
{
id = 1,
label = label
}
});
var labeler1 = new ObjectCountLabeler(cfg);
labeler1.objectCountMetricId = "a1da3c27-369d-4929-aea6-d01614635ce2";
var labeler2 = new ObjectCountLabeler(cfg);
labeler1.objectCountMetricId = "b1da3c27-369d-4929-aea6-d01614635ce2";
perceptionCamera.AddLabeler(labeler1);
perceptionCamera.AddLabeler(labeler2);
object1.SetActive(true);
AddTestObjectForCleanup(object1);
//wait a couple of frames to make sure visualize has been called
yield return null;
yield return null;
Assert.AreEqual(perceptionCamera.hudPanel.entryCount, 2);
labeler2.visualizationEnabled = false;
yield return null;
Assert.AreEqual(perceptionCamera.hudPanel.entryCount, 1);
}
}
}

16
com.unity.perception/package.json


"com.unity.nuget.newtonsoft-json": "1.1.2",
"com.unity.render-pipelines.core": "7.1.6",
"com.unity.entities": "0.8.0-preview.8",
"com.unity.simulation.capture": "0.0.10-preview.10",
"com.unity.simulation.core": "0.0.10-preview.17"
},
"description": "Tools for authoring and executing autonomous vehicle simulations.",
"displayName": "Perception",
"name": "com.unity.perception",
"unity": "2019.3",
"version": "0.3.0-preview.1"
"com.unity.simulation.capture": "0.0.10-preview.13",
"com.unity.simulation.core": "0.0.10-preview.19"
},
"description": "Tools for generating large-scale data sets for perception-based machine learning training and validation",
"displayName": "Perception",
"name": "com.unity.perception",
"unity": "2019.4",
"version": "0.4.0-preview.1"
}

984
TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &411238276
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 411238281}
- component: {fileID: 411238280}
- component: {fileID: 411238279}
- component: {fileID: 411238278}
- component: {fileID: 411238277}
- component: {fileID: 411238282}
m_Layer: 0
m_Name: Crate
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &411238277
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
labels:
- Crate
--- !u!65 &411238278
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
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 &411238279
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &411238280
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &411238281
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 187.1, y: 83.926025, z: -137.7}
m_LocalScale: {x: 36.249973, y: 100, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &411238282
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &464025704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 464025709}
- component: {fileID: 464025708}
- component: {fileID: 464025707}
- component: {fileID: 464025706}
- component: {fileID: 464025705}
- component: {fileID: 464025710}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &464025705
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
labels:
- Cube
--- !u!65 &464025706
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
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 &464025707
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &464025708
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &464025709
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 43.9, y: 83.926025, z: -71.3}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &464025710
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
- component: {fileID: 705507996}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 3.1415927
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 6.284e-41, z: 0, w: 2.8131285e+20}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 96.1856, y: 192.67596, z: -193.83864}
m_LocalScale: {x: 36.249973, y: 36.249977, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &705507996
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 10
m_ObsoleteShadowResolutionTier: 1
m_ObsoleteUseShadowQualitySettings: 0
m_ObsoleteCustomShadowResolution: 512
m_ObsoleteContactShadows: 0
m_PointlightHDType: 0
m_SpotLightShape: 0
m_AreaLightShape: 0
m_Intensity: 3.1415927
m_EnableSpotReflector: 0
m_LuxAtDistance: 1
m_InnerSpotPercent: 0
m_LightDimmer: 1
m_VolumetricDimmer: 1
m_LightUnit: 2
m_FadeDistance: 10000
m_AffectDiffuse: 1
m_AffectSpecular: 1
m_NonLightmappedOnly: 0
m_ShapeWidth: 0.5
m_ShapeHeight: 0.5
m_AspectRatio: 1
m_ShapeRadius: 0
m_SoftnessScale: 1
m_UseCustomSpotLightShadowCone: 0
m_CustomSpotLightShadowCone: 30
m_MaxSmoothness: 0.99
m_ApplyRangeAttenuation: 1
m_DisplayAreaLightEmissiveMesh: 0
m_AreaLightCookie: {fileID: 0}
m_AreaLightShadowCone: 120
m_UseScreenSpaceShadows: 0
m_InteractsWithSky: 1
m_AngularDiameter: 0
m_FlareSize: 2
m_FlareTint: {r: 1, g: 1, b: 1, a: 1}
m_FlareFalloff: 4
m_SurfaceTexture: {fileID: 0}
m_SurfaceTint: {r: 1, g: 1, b: 1, a: 1}
m_Distance: 150000000
m_UseRayTracedShadows: 0
m_NumRayTracingSamples: 4
m_FilterTracedShadow: 1
m_FilterSizeTraced: 16
m_SunLightConeAngle: 0.5
m_LightShadowRadius: 0.5
m_SemiTransparentShadow: 0
m_ColorShadow: 1
m_EvsmExponent: 15
m_EvsmLightLeakBias: 0
m_EvsmVarianceBias: 0.00001
m_EvsmBlurPasses: 0
m_LightlayersMask: 1
m_LinkShadowLayers: 1
m_ShadowNearPlane: 0.1
m_BlockerSampleCount: 24
m_FilterSampleCount: 16
m_MinFilterSize: 0.01
m_KernelSize: 5
m_LightAngle: 1
m_MaxDepthBias: 0.001
m_ShadowResolution:
m_Override: 512
m_UseOverride: 1
m_Level: 0
m_ShadowDimmer: 1
m_VolumetricShadowDimmer: 1
m_ShadowFadeDistance: 10000
m_UseContactShadow:
m_Override: 0
m_UseOverride: 1
m_Level: 0
m_RayTracedContactShadow: 0
m_ShadowTint: {r: 0, g: 0, b: 0, a: 1}
m_PenumbraTint: 0
m_NormalBias: 0.75
m_SlopeBias: 0.5
m_ShadowUpdateMode: 0
m_BarnDoorAngle: 90
m_BarnDoorLength: 0.05
m_ShadowCascadeRatios:
- 0.05
- 0.2
- 0.3
m_ShadowCascadeBorders:
- 0.2
- 0.2
- 0.2
- 0.2
m_ShadowAlgorithm: 0
m_ShadowVariant: 0
m_ShadowPrecision: 0
useOldInspector: 0
useVolumetric: 1
featuresFoldout: 1
showAdditionalSettings: 0
m_AreaLightEmissiveMeshShadowCastingMode: 0
m_AreaLightEmissiveMeshMotionVectorGenerationMode: 0
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
- component: {fileID: 963194229}
- component: {fileID: 963194230}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &963194226
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 2
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 35, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 12.228561
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 88.91903
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0, y: -0.3118126, z: 0, w: 0.95014364}
m_LocalPosition: {x: 198.01884, y: 87, z: -267.4195}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: -36.337, z: 0}
--- !u!114 &963194229
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 7
m_ObsoleteRenderingPath: 0
m_ObsoleteFrameSettings:
overrides: 0
enableShadow: 0
enableContactShadows: 0
enableShadowMask: 0
enableSSR: 0
enableSSAO: 0
enableSubsurfaceScattering: 0
enableTransmission: 0
enableAtmosphericScattering: 0
enableVolumetrics: 0
enableReprojectionForVolumetrics: 0
enableLightLayers: 0
enableExposureControl: 1
diffuseGlobalDimmer: 0
specularGlobalDimmer: 0
shaderLitMode: 0
enableDepthPrepassWithDeferredRendering: 0
enableTransparentPrepass: 0
enableMotionVectors: 0
enableObjectMotionVectors: 0
enableDecals: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 0
enableOpaqueObjects: 0
enableTransparentObjects: 0
enableRealtimePlanarReflection: 0
enableMSAA: 0
enableAsyncCompute: 0
runLightListAsync: 0
runSSRAsync: 0
runSSAOAsync: 0
runContactShadowsAsync: 0
runVolumeVoxelizationAsync: 0
lightLoopSettings:
overrides: 0
enableDeferredTileAndCluster: 0
enableComputeLightEvaluation: 0
enableComputeLightVariants: 0
enableComputeMaterialVariants: 0
enableFptlForForwardOpaque: 0
enableBigTilePrepass: 0
isFptlEnabled: 0
clearColorMode: 0
backgroundColorHDR: {r: 0.025, g: 0.07, b: 0.19, a: 0}
clearDepth: 1
volumeLayerMask:
serializedVersion: 2
m_Bits: 1
volumeAnchorOverride: {fileID: 0}
antialiasing: 0
SMAAQuality: 2
dithering: 0
stopNaNs: 0
taaSharpenStrength: 0.6
physicalParameters:
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
flipYMode: 0
fullscreenPassthrough: 0
allowDynamicResolution: 0
customRenderingSettings: 0
invertFaceCulling: 0
probeLayerMask:
serializedVersion: 2
m_Bits: 4294967295
hasPersistentHistory: 0
m_RenderingPathCustomFrameSettings:
bitDatas:
data1: 70280697347933
data2: 4539628424926265344
lodBias: 1
lodBiasMode: 0
lodBiasQualityLevel: 0
maximumLODLevel: 0
maximumLODLevelMode: 0
maximumLODLevelQualityLevel: 0
materialQuality: 0
renderingPathCustomFrameSettingsOverrideMask:
mask:
data1: 0
data2: 0
defaultFrameSettings: 0
--- !u!114 &963194230
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4467405dbcbd3d64ab4363e9ae8bb813, type: 3}
m_Name:
m_EditorClassIdentifier:
description: The main camera
period: 0.0166
startTime: 0
captureRgbImages: 1
m_Labelers:
- id: 0
- id: 1
- id: 2
- id: 3
showVisualizations: 1
references:
version: 1
00000000:
type: {class: BoundingBox2DLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
annotationId: f9f22e05-443f-4602-a422-ebe4ea9b55cb
idLabelConfig: {fileID: 11400000, guid: 258de5b48703743468d34fc5bbdfa3aa,
type: 2}
00000001:
type: {class: SemanticSegmentationLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
annotationId: 12f94d8d-5425-4deb-9b21-5e53ad957d66
labelConfig: {fileID: 11400000, guid: c140c5aa05dd09e4fadaa26de31b1f39, type: 2}
m_TargetTextureOverride: {fileID: 0}
00000002:
type: {class: ObjectCountLabeler, ns: UnityEngine.Perception.GroundTruth, asm: Unity.Perception.Runtime}
data:
enabled: 1
objectCountMetricId: 51da3c27-369d-4929-aea6-d01614635ce2
m_LabelConfig: {fileID: 11400000, guid: 258de5b48703743468d34fc5bbdfa3aa,
type: 2}
00000003:
type: {class: RenderedObjectInfoLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
objectInfoMetricId: 5ba92024-b3b7-41a7-9d3f-c03a6a8ddd01
idLabelConfig: {fileID: 11400000, guid: 258de5b48703743468d34fc5bbdfa3aa,
type: 2}
--- !u!1 &1562495298
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1562495300}
- component: {fileID: 1562495299}
m_Layer: 0
m_Name: Global Volume
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1562495299
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1562495298}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier:
isGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 6886180e6c51dac4f9ea4d9bcdaa6e13, type: 2}
--- !u!4 &1562495300
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1562495298}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1640252283}
- component: {fileID: 1640252282}
- component: {fileID: 1640252281}
- component: {fileID: 1640252280}
- component: {fileID: 1640252279}
- component: {fileID: 1640252284}
m_Layer: 0
m_Name: Box
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1640252279
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
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:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1640252282
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1640252283
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 65.9, y: 83.926025, z: -212.4}
m_LocalScale: {x: 36.249973, y: 100, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1640252284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180

7
TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion.unity.meta


fileFormatVersion: 2
guid: 626a1164e53022d4c93345d4666a6713
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
TestProjects/PerceptionURP/Assets/Scenes/SampleScene.meta


fileFormatVersion: 2
guid: c63d11a708fe3f047a545d7e457f6e81
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.meta


fileFormatVersion: 2
guid: fe6387cf00f889a4aa1829716e16631f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

840
TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &411238276
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 411238281}
- component: {fileID: 411238280}
- component: {fileID: 411238279}
- component: {fileID: 411238278}
- component: {fileID: 411238277}
- component: {fileID: 411238282}
m_Layer: 0
m_Name: Crate
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &411238277
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
labels:
- Crate
--- !u!65 &411238278
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
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 &411238279
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &411238280
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &411238281
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 155.99806, y: 83.926025, z: -149.97618}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &411238282
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 411238276}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &464025704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 464025709}
- component: {fileID: 464025708}
- component: {fileID: 464025707}
- component: {fileID: 464025706}
- component: {fileID: 464025705}
- component: {fileID: 464025710}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &464025705
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
labels:
- Cube
--- !u!65 &464025706
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
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 &464025707
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &464025708
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &464025709
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 92.92311, y: 83.926025, z: -136.20119}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &464025710
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 464025704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
- component: {fileID: 705507996}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 3.1415927
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 4.7e-43, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 96.1856, y: 192.67596, z: -193.83864}
m_LocalScale: {x: 36.249973, y: 36.249977, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &705507996
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194226}
- component: {fileID: 963194230}
- component: {fileID: 963194229}
- component: {fileID: 963194227}
- component: {fileID: 963194231}
- component: {fileID: 963194232}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &963194226
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!114 &963194227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: -0.17179534, y: 0.30667058, z: -0.056378223, w: -0.93448436}
m_LocalPosition: {x: 198.01884, y: 126.545494, z: -267.4195}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &963194229
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!114 &963194230
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4467405dbcbd3d64ab4363e9ae8bb813, type: 3}
m_Name:
m_EditorClassIdentifier:
description: The main camera
period: 0.0166
startTime: 0
captureRgbImages: 1
m_Labelers:
- id: 0
- id: 1
- id: 2
- id: 3
m_LensDistortion: {fileID: 0}
showVisualizations: 1
references:
version: 1
00000000:
type: {class: ObjectCountLabeler, ns: UnityEngine.Perception.GroundTruth, asm: Unity.Perception.Runtime}
data:
enabled: 1
objectCountMetricId: 51da3c27-369d-4929-aea6-d01614635ce2
m_LabelConfig: {fileID: 11400000, guid: cedcacfb1d9beb34fbbb231166c472fe,
type: 2}
00000001:
type: {class: BoundingBox2DLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
annotationId: f9f22e05-443f-4602-a422-ebe4ea9b55cb
idLabelConfig: {fileID: 11400000, guid: cedcacfb1d9beb34fbbb231166c472fe,
type: 2}
00000002:
type: {class: RenderedObjectInfoLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
objectInfoMetricId: 5ba92024-b3b7-41a7-9d3f-c03a6a8ddd01
idLabelConfig: {fileID: 11400000, guid: cedcacfb1d9beb34fbbb231166c472fe,
type: 2}
00000003:
type: {class: SemanticSegmentationLabeler, ns: UnityEngine.Perception.GroundTruth,
asm: Unity.Perception.Runtime}
data:
enabled: 1
annotationId: 12f94d8d-5425-4deb-9b21-5e53ad957d66
labelConfig: {fileID: 11400000, guid: c140c5aa05dd09e4fadaa26de31b1f39, type: 2}
m_TargetTextureOverride: {fileID: 0}
--- !u!114 &963194231
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c51d9f2c5784bb4aee3fdf021966e14, type: 3}
m_Name:
m_EditorClassIdentifier:
targetLight: {fileID: 705507993}
target: {fileID: 1640252278}
--- !u!114 &963194232
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53f4c974fdf704444959724a41de0cfe, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1257403327
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1257403328}
- component: {fileID: 1257403329}
m_Layer: 0
m_Name: Global Volume
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1257403328
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1257403327}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1257403329
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1257403327}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier:
isGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 1f38bcef59815b3429d705dd5e490517, type: 2}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1640252283}
- component: {fileID: 1640252282}
- component: {fileID: 1640252279}
- component: {fileID: 1640252284}
- component: {fileID: 1640252280}
m_Layer: 0
m_Name: Box1234
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1640252279
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b33f0bc2b78db642a758f07826d0dd0, type: 3}
m_Name:
m_EditorClassIdentifier:
labels:
- Box
--- !u!137 &1640252280
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
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
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1640252283
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 96.1856, y: 83.926025, z: -193.83864}
m_LocalScale: {x: 36.249973, y: 36.249973, z: 36.249973}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1640252284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1640252278}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 673a227032a8e4940b9828c5b6f852ab, type: 3}
m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180

7
TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion.unity.meta


fileFormatVersion: 2
guid: 158b39ade1e98d54f921da59e9c1197c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

31
TestProjects/PerceptionURP/Assets/TestMpbPerMaterial.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum MaterialPropertyTarget
{
Renderer,
Material
}
[ExecuteInEditMode]
public class TestMpbPerMaterial : MonoBehaviour
{
public MaterialPropertyTarget materialPropertyTarget = MaterialPropertyTarget.Material;
public Color color;
// Update is called once per frame
void Start()
{
var meshRenderer = GetComponent<MeshRenderer>();
MaterialPropertyBlock mpb = new MaterialPropertyBlock();
mpb.SetColor("_BaseColor", color);
if (materialPropertyTarget == MaterialPropertyTarget.Renderer)
meshRenderer.SetPropertyBlock(mpb);
else
{
for (int i = 0; i < meshRenderer.sharedMaterials.Length; i++)
{
meshRenderer.SetPropertyBlock(mpb, i);
}
}
}
}

11
TestProjects/PerceptionURP/Assets/TestMpbPerMaterial.cs.meta


fileFormatVersion: 2
guid: 695e410829600ff40bcdd76fa0818f6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Editor/Randomization.meta


fileFormatVersion: 2
guid: bc1c8d85f0374514ab4d1af6b3bbe6cd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

4
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/solid_white.png

之前 之后
宽度: 30  |  高度: 30  |  大小: 573 B

104
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/solid_white.png.meta


fileFormatVersion: 2
guid: bc6ed62c29e144961bc6ac55cc87f418
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 0
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 1, y: 1, z: 1, w: 1}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Shaders.meta


fileFormatVersion: 2
guid: 49685106b663d4ce2be106a7decb44fa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

200
com.unity.perception/Runtime/GroundTruth/LensDistortionCrossPipelinePass.cs


using System;
using Unity.Mathematics;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#elif URP_PRESENT
using UnityEngine.Rendering.Universal;
#endif
#if HDRP_PRESENT || URP_PRESENT
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// Custom Pass which will apply a lens distortion (per the respective volume override in URP or HDRP, or
/// through a custom override directly through the pass) to an incoming mask / texture. The purpose of this
/// is to allow the same lens distortion being applied to the RGB image ine the perception camera to be applied
/// to the respective ground truths generated.
/// </summary>
internal class LensDistortionCrossPipelinePass : GroundTruthCrossPipelinePass
{
const string k_ShaderName = "Perception/LensDistortion";
//Serialize the shader so that the shader asset is included in player builds when the SemanticSegmentationPass is used.
//Currently commented out and shaders moved to Resources folder due to serialization crashes when it is enabled.
//See https://fogbugz.unity3d.com/f/cases/1187378/
//[SerializeField]
// Lens Distortion Shader
Shader m_LensDistortionShader;
Material m_LensDistortionMaterial;
bool m_fInitialized = false;
public static readonly int _Distortion_Params1 = Shader.PropertyToID("_Distortion_Params1");
public static readonly int _Distortion_Params2 = Shader.PropertyToID("_Distortion_Params2");
LensDistortion m_lensDistortion;
internal float? lensDistortionOverride = null; // Largely for testing, but could be useful otherwise
RenderTexture m_TargetTexture;
RenderTexture m_distortedTexture;
//private LensDistortion m_LensDistortion;
public LensDistortionCrossPipelinePass(Camera targetCamera, RenderTexture targetTexture)
: base(targetCamera)
{
m_TargetTexture = targetTexture;
}
public override void Setup()
{
base.Setup();
m_LensDistortionShader = Shader.Find(k_ShaderName);
var shaderVariantCollection = new ShaderVariantCollection();
if (shaderVariantCollection != null)
shaderVariantCollection.Add(new ShaderVariantCollection.ShaderVariant(m_LensDistortionShader, PassType.ScriptableRenderPipeline));
m_LensDistortionMaterial = new Material(m_LensDistortionShader);
if(shaderVariantCollection != null)
shaderVariantCollection.WarmUp();
// Set up a new texture
if (m_distortedTexture == null || m_distortedTexture.width != Screen.width || m_distortedTexture.height != Screen.height) {
if (m_distortedTexture != null)
m_distortedTexture.Release();
m_distortedTexture = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
m_distortedTexture.enableRandomWrite = true;
m_distortedTexture.filterMode = FilterMode.Point;
m_distortedTexture.Create();
}
// Grab the lens distortion
#if HDRP_PRESENT
// Grab the Lens Distortion from Perception Camera stack
var hdCamera = HDCamera.GetOrCreate(targetCamera);
var stack = hdCamera.volumeStack;
m_lensDistortion = stack.GetComponent<LensDistortion>();
#elif URP_PRESENT
var stack = VolumeManager.instance.stack;
m_lensDistortion = stack.GetComponent<LensDistortion>();
#endif
m_fInitialized = true;
}
protected override void ExecutePass(ScriptableRenderContext renderContext, CommandBuffer cmd, Camera camera, CullingResults cullingResult)
{
if (m_fInitialized == false)
return;
if (SetLensDistortionShaderParameters() == false)
return;
// Blitmayhem
cmd.Blit(m_TargetTexture, m_distortedTexture, m_LensDistortionMaterial);
cmd.Blit(m_distortedTexture, m_TargetTexture);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Clear();
}
public bool SetLensDistortionShaderParameters()
{
if (m_fInitialized == false)
return false;
// This code is lifted from the SetupLensDistortion() function in
// https://github.com/Unity-Technologies/Graphics/blob/257b08bba6c11de0f894e42e811124247a522d3c/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs
// This is in UnityEngine.Rendering.Universal.Internal.PostProcessPass::SetupLensDistortion so it's
// unclear how to re-use this code
float intensity = 0.5f;
float scale = 1.0f;
var center = new Vector2(0.0f, 0.0f);
var mult = new Vector2(1.0f, 1.0f);
#if HDRP_PRESENT
if(m_lensDistortion == null)
return false;
#elif URP_PRESENT
if(targetCamera == null)
return false;
var UACD = targetCamera.GetUniversalAdditionalCameraData();
if(UACD.renderPostProcessing == false && lensDistortionOverride.HasValue == false)
return false;
if (m_lensDistortion.active == false)
return false;
#else
return false;
#endif
if (lensDistortionOverride.HasValue)
{
intensity = lensDistortionOverride.Value;
}
else if (m_lensDistortion != null)
{
// This is a bit finicky for URP - since Lens Distortion comes off the VolumeManager stack as active
// even if post processing is not enabled. An intensity of 0.0f is untenable, so the below checks
// ensures post processing hasn't been enabled but Lens Distortion actually overriden
if (m_lensDistortion.intensity.value != 0.0f)
{
intensity = m_lensDistortion.intensity.value;
center = m_lensDistortion.center.value * 2f - Vector2.one;
mult.x = Mathf.Max(m_lensDistortion.xMultiplier.value, 1e-4f);
mult.y = Mathf.Max(m_lensDistortion.yMultiplier.value, 1e-4f);
scale = 1.0f / m_lensDistortion.scale.value;
}
else
{
return false;
}
}
float amount = 1.6f * Mathf.Max(Mathf.Abs(intensity * 100.0f), 1.0f);
float theta = Mathf.Deg2Rad * Mathf.Min(160f, amount);
float sigma = 2.0f * Mathf.Tan(theta * 0.5f);
var p1 = new Vector4(
center.x,
center.y,
mult.x,
mult.y
);
var p2 = new Vector4(
intensity >= 0f ? theta : 1f / theta,
sigma,
scale,
intensity * 100.0f
);
// Set Shader Constants
m_LensDistortionMaterial.SetVector(_Distortion_Params1, p1);
m_LensDistortionMaterial.SetVector(_Distortion_Params2, p2);
return true;
}
public override void SetupMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId)
{
SetLensDistortionShaderParameters();
}
}
}
#endif // ! HDRP_PRESENT || URP_PRESENT

3
com.unity.perception/Runtime/GroundTruth/LensDistortionCrossPipelinePass.cs.meta


fileFormatVersion: 2
guid: ad37b813e25c450fbc65b2820a7d9dc2
timeCreated: 1598041907

54
com.unity.perception/Runtime/GroundTruth/LensDistortionPass.cs


#if HDRP_PRESENT
using System;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// Custom Pass which renders labeled images where each object with a Labeling component is drawn with the value
/// specified by the given LabelingConfiguration.
/// </summary>
public class LensDistortionPass : CustomPass
{
public RenderTexture targetTexture;
public Camera targetCamera;
internal LensDistortionCrossPipelinePass m_LensDistortionCrossPipelinePass;
public LensDistortionPass(Camera targetCamera, RenderTexture targetTexture)
{
this.targetTexture = targetTexture;
this.targetCamera = targetCamera;
EnsureInit();
}
public void EnsureInit()
{
if (m_LensDistortionCrossPipelinePass == null)
{
m_LensDistortionCrossPipelinePass = new LensDistortionCrossPipelinePass(targetCamera, targetTexture);
m_LensDistortionCrossPipelinePass.EnsureActivated();
}
}
public LensDistortionPass()
{
//
}
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
{
EnsureInit();
m_LensDistortionCrossPipelinePass.Setup();
}
protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult)
{
CoreUtils.SetRenderTarget(cmd, targetTexture);
m_LensDistortionCrossPipelinePass.Execute(renderContext, cmd, hdCamera.camera, cullingResult);
}
}
}
#endif

3
com.unity.perception/Runtime/GroundTruth/LensDistortionPass.cs.meta


fileFormatVersion: 2
guid: 7f243f0bc64f47db99fb540a718016dc
timeCreated: 1598041612

98
com.unity.perception/Runtime/GroundTruth/Resources/LensDistortion.shader


Shader "Perception/LensDistortion"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" "LightMode" = "SRP" }
LOD 100
ZTest Always ZWrite Off Cull Off
Pass
{
Name "LensDistortion"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
// Note: This is taken from the HDRP UberPost shader:
// https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader
// https://github.com/Unity-Technologies/Graphics/blob/257b08bba6c11de0f894e42e811124247a522d3c/com.unity.render-pipelines.universal/Runtime/Passes/PostProcessPass.cs
// TODO: Include this code somehow since we're really only using the DistortUV call
float4 _Distortion_Params1;
float4 _Distortion_Params2;
#define DistCenter _Distortion_Params1.xy
#define DistAxis _Distortion_Params1.zw
#define DistTheta _Distortion_Params2.x
#define DistSigma _Distortion_Params2.y
#define DistScale _Distortion_Params2.z
#define DistIntensity _Distortion_Params2.w
float2 DistortUV(float2 uv)
{
uv = (uv - 0.5) * DistScale + 0.5;
float2 ruv = DistAxis * (uv - 0.5 - DistCenter);
float ru = length(float2(ruv));
UNITY_BRANCH
if (DistIntensity > 0.0)
{
float wu = ru * DistTheta;
ru = tan(wu) * (rcp(ru * DistSigma));
uv = uv + ruv * (ru - 1.0);
}
else
{
ru = rcp(ru) * DistTheta * atan(ru * DistSigma);
uv = uv + ruv * (ru - 1.0);
}
return uv;
}
sampler2D _MainTex;
fixed4 frag(v2f input) : SV_Target
{
float2 uvDistorted = input.uv;
uvDistorted = DistortUV(uvDistorted);
float4 texValue = tex2D(_MainTex, uvDistorted);
return texValue;
}
ENDCG
}
}
}

9
com.unity.perception/Runtime/GroundTruth/Resources/LensDistortion.shader.meta


fileFormatVersion: 2
guid: fc985f5773827c7468c475fd7290d5e7
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

50
com.unity.perception/Runtime/GroundTruth/Resources/Packing.hlsl


#ifndef UNITY_PERCEPTION_PACKING_INCLUDED
#define UNITY_PERCEPTION_PACKING_INCLUDED
#define real float
#define real2 float2
#define real3 float3
#define real4 float4
// Packs an integer stored using at most 'numBits' into a [0..1] real.
real PackInt(uint i, uint numBits)
{
uint maxInt = (1u << numBits) - 1u;
return saturate(i * rcp(maxInt));
}
// Unpacks a [0..1] real into an integer of size 'numBits'.
uint UnpackInt(real f, uint numBits)
{
uint maxInt = (1u << numBits) - 1u;
return (uint)(f * maxInt + 0.5); // Round instead of truncating
}
#ifndef INTRINSIC_BITFIELD_EXTRACT
// Unsigned integer bit field extraction.
// Note that the intrinsic itself generates a vector instruction.
// Wrap this function with WaveReadLaneFirst() to get scalar output.
uint BitFieldExtract(uint data, uint offset, uint numBits)
{
uint mask = (1u << numBits) - 1u;
return (data >> offset) & mask;
}
#endif // INTRINSIC_BITFIELD_EXTRACT
//-----------------------------------------------------------------------------
// Float packing
//-----------------------------------------------------------------------------
// src must be between 0.0 and 1.0
uint PackFloatToUInt(real src, uint offset, uint numBits)
{
return UnpackInt(src, numBits) << offset;
}
real UnpackUIntToFloat(uint src, uint offset, uint numBits)
{
uint maxInt = (1u << numBits) - 1u;
return real(BitFieldExtract(src, offset, numBits)) * rcp(maxInt);
}
#endif // UNITY_PACKING_INCLUDED

3
com.unity.perception/Runtime/GroundTruth/Resources/Packing.hlsl.meta


fileFormatVersion: 2
guid: 9af0f66010764cc5a8ef4acccc164cdb
timeCreated: 1598539851

8
com.unity.perception/Runtime/Randomization.meta


fileFormatVersion: 2
guid: 511b2251e3510cd48a26b8a61f6911f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

93
com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs


using System.Collections;
using NUnit.Framework;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.TestTools;
namespace GroundTruthTests
{
[TestFixture]
public class LabelEntryMatchCacheTests : GroundTruthTestBase
{
[Test]
public void TryGet_ReturnsFalse_ForInvalidInstanceId()
{
var config = new IdLabelConfig();
using (var cache = new LabelEntryMatchCache(config))
{
Assert.IsFalse(cache.TryGetLabelEntryFromInstanceId(100, out var labelEntry, out var index));
Assert.AreEqual(-1, index);
Assert.AreEqual(default(IdLabelEntry), labelEntry);
}
}
[UnityTest]
public IEnumerator TryGet_ReturnsTrue_ForMatchingLabel()
{
var label = "label";
var labeledPlane = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane);
var config = new IdLabelConfig();
config.Init(new[]
{
new IdLabelEntry()
{
id = 1,
label = label
},
});
using (var cache = new LabelEntryMatchCache(config))
{
//allow label to be registered
yield return null;
Assert.IsTrue(cache.TryGetLabelEntryFromInstanceId(labeledPlane.GetComponent<Labeling>().instanceId, out var labelEntry, out var index));
Assert.AreEqual(0, index);
Assert.AreEqual(config.labelEntries[0], labelEntry);
}
}
[UnityTest]
public IEnumerator TryGet_ReturnsFalse_ForNonMatchingLabel()
{
var label = "label";
var labeledPlane = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane);
var config = new IdLabelConfig();
using (var cache = new LabelEntryMatchCache(config))
{
//allow label to be registered
yield return null;
Assert.IsFalse(cache.TryGetLabelEntryFromInstanceId(labeledPlane.GetComponent<Labeling>().instanceId, out var labelEntry, out var index));
Assert.AreEqual(-1, index);
Assert.AreEqual(default(IdLabelEntry), labelEntry);
}
}
[UnityTest]
public IEnumerator TryGet_ReturnsFalse_ForNonMatchingLabel_WithOtherMatches()
{
var label = "label";
//only way to guarantee registration order is to run frames.
//We want to ensure labeledPlane is registered before labeledPlane2 so that the cache does not early out
var labeledPlane = TestHelper.CreateLabeledPlane(label: "foo");
AddTestObjectForCleanup(labeledPlane);
yield return null;
var labeledPlane2 = TestHelper.CreateLabeledPlane(label: label);
AddTestObjectForCleanup(labeledPlane2);
var config = new IdLabelConfig();
config.Init(new[]
{
new IdLabelEntry()
{
id = 1,
label = label
},
});
using (var cache = new LabelEntryMatchCache(config))
{
//allow label to be registered
yield return null;
Assert.IsFalse(cache.TryGetLabelEntryFromInstanceId(labeledPlane.GetComponent<Labeling>().instanceId, out var labelEntry, out var index));
Assert.AreEqual(-1, index);
Assert.AreEqual(default(IdLabelEntry), labelEntry);
}
}
}
}

11
com.unity.perception/Tests/Runtime/GroundTruthTests/LabelEntryMatchCacheTests.cs.meta


fileFormatVersion: 2
guid: 8404035e89b3b1b4e87136d8a512b6f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.perception/Tests/Runtime/Randomization.meta


fileFormatVersion: 2
guid: 44d8bef3d43160b428851cccd5080624
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

53
TestProjects/PerceptionHDRP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Volume Profile
m_EditorClassIdentifier:
components:
- {fileID: 3741622219492366159}
--- !u!114 &3741622219492366159
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9c1bfcd0f0fa7b8468f281d6bbbaf320, type: 3}
m_Name: LensDistortion
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
intensity:
m_OverrideState: 1
m_Value: 0.805
min: -1
max: 1
xMultiplier:
m_OverrideState: 0
m_Value: 1
min: 0
max: 1
yMultiplier:
m_OverrideState: 0
m_Value: 1
min: 0
max: 1
center:
m_OverrideState: 0
m_Value: {x: 0.5, y: 0.5}
scale:
m_OverrideState: 0
m_Value: 1
min: 0.01
max: 5

53
TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Volume Profile
m_EditorClassIdentifier:
components:
- {fileID: 6059181497156826374}
--- !u!114 &6059181497156826374
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c5e1dc532bcb41949b58bc4f2abfbb7e, type: 3}
m_Name: LensDistortion
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
intensity:
m_OverrideState: 1
m_Value: 0.715
min: -1
max: 1
xMultiplier:
m_OverrideState: 1
m_Value: 1
min: 0
max: 1
yMultiplier:
m_OverrideState: 1
m_Value: 1
min: 0
max: 1
center:
m_OverrideState: 1
m_Value: {x: 0.5, y: 0.5}
scale:
m_OverrideState: 1
m_Value: 1
min: 0.01
max: 5

8
TestProjects/PerceptionURP/Assets/Scenes/SampleSceneLensDistortion/Global Volume Profile.asset.meta


fileFormatVersion: 2
guid: 1f38bcef59815b3429d705dd5e490517
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

85
com.unity.perception/Documentation~/Randomization/Images/ColorParameter.png

之前 之后
宽度: 455  |  高度: 307  |  大小: 30 KiB

206
com.unity.perception/Documentation~/Randomization/Images/ParameterConfiguration.png

之前 之后
宽度: 499  |  高度: 608  |  大小: 54 KiB

101
com.unity.perception/Documentation~/Randomization/Images/TestScenario.png

之前 之后
宽度: 499  |  高度: 285  |  大小: 24 KiB

93
com.unity.perception/Documentation~/Randomization/Images/TutorialBuild.png

之前 之后
宽度: 496  |  高度: 631  |  大小: 36 KiB

90
com.unity.perception/Documentation~/Randomization/Parameters.md


# Parameters
## Lookup Parameters
To obtain a parameter from a paramter configuration, use the GetParameter() method:
```
// Get a reference to the parameter configuration attached to this GameObject
var parameterConfiguration = GetComponent<ParameterConfiguration>();
// Lookup the parameter "ObjectWidth" by name
var parameter = GetComponent<FloatParameter>("ObjectWidth");
```
## Creating and Sampling Parameters
Parameters are typically managed by `ParameterConfigurations` in the Unity Editor. However, parameters can be instanced independently like a regular class too:
```
// Create a color parameter
var colorParameter = new HsvaColorParameter();
// Generate one color sample
var color = colorParameter.Sample();
```
Note that parameters, like samplers, generate new random values for each call to the Sample() method:
```
var color1 = colorParameter.Sample();
var color2 = colorParameter.Sample();
Assert.AreNotEqual(color1, color2);
```
## Defining Custom Parameters
All parameters derive from the `Parameter` abstract class, but all included perception package parameter types derive from two specialized Parameter base classes:
1. `CategoricalParameter`
2. `NumericParameter`
### Categorical Parameters
Categorical parameters choose a value from a list of options that have no intrinsic ordering. For example, a material paramater randomly chooses from a list of material options, but the list of material options itself can be rearranged into any particular order without affecting the distribution of materials selected.
If your custom parameter is a categorical in nature, take a look at the [StringParameter]() class included in the perception package as a reference for how to derive the `CategoricalParameter` class.
```
using UnityEngine.Perception.Randomization.Parameters.Attributes;
namespace UnityEngine.Perception.Randomization.Parameters
{
[AddComponentMenu("")]
[ParameterMetaData("String")]
public class StringParameter : CategoricalParameter<string> {}
}
```
**Note:** the AddComponentMenu attribute with an empty string prevents parameters from appearing in the Add Component GameObject menu. Randomization parameters should only be created with by a `ParameterConfiguration`
### Numeric Parameters
Numeric parameters use samplers to generate randomized structs. Take a look at the [ColorHsvaParameter]() class included in the perception package for an example on how to implement a numeric parameter.
## Improving Sampling Performance
For numeric parameters, it is recommended to use the JobHandle overload of the Samples() method when generating a large number of samples. The JobHandle overload will utilize the Unity Burst Compiler and Job System to automatically optimize and multithread parameter sampling jobs. The code block below is an example of how to use this overload to sample two parameters in parallel:
```
// Get a reference to the parameter configuration attached to this GameObject
var parameterConfiguration = GetComponent<ParameterConfiguration>();
// Lookup parameters
var cubeColorParameter = parameterConfiguration.GetParameter<HsvaColorParameter>("CubeColor");
var cubePositionParameter = parameterConfiguration.GetParameter<Vector3Parameter>("CubePosition");
// Schedule sampling jobs
var cubeColors = cubeColorParameter.Samples(constants.cubeCount, out var colorHandle);
var cubePositions = cubePositionParameter.Samples(constants.cubeCount, out var positionHandle);
// Combine job handles
var handles = JobHandle.CombineDependencies(colorHandle, positionHandle);
// Wait for the jobs to complete
handles.Complete();
// Use the created samples
for (var i = 0; i < constants.cubeCount; i++)
{
m_ObjectMaterials[i].SetColor(k_BaseColorProperty, cubeColors[i]);
m_Objects[i].transform.position = cubePositions[i];
}
// Dispose of the generated samples
cubeColors.Dispose();
cubePositions.Dispose();
```

87
com.unity.perception/Documentation~/Randomization/Samplers.md


# Samplers
Samplers in the perception package are classes that deterministically generate random float values from bounded probability distributions. Although samplers are often used in conjunction with parameters to generate arrays of typed random values, samplers can be instantiated and used from any ordinary script:
```
var sampler = new NormalSampler();
sampler.seed = 123456789u;
sampler.mean = 3;
sampler.stdDev = 2;
sampler.range = new FloatRange(-10, 10);
// Generate a sample
var sample = sampler.NextSample();
```
Four Samplers are included with the perception package:
1. Constant Sampler
2. Uniform Sampler
3. Normal Sampler
4. Placeholder Range Sampler
#### Constant Sampler
Generates constant valued samples
#### Uniform Sampler
Samples uniformly from a specified range
#### Normal Sampler
Generates random samples from a truncated normal distribution bounded by a specified range
#### Placeholder Range Sampler
Used to define a float range [minimum, maximum] for a particular component of a parameter (example: the hue component of a color parameter). This sampler is useful for configuring sample ranges for non-perception related scripts, particularly when these scripts have a public interface for manipulating a minimum and maximum bounds for their sample range but perform the actual sampling logic internally.
## Performance
Samplers are designed to be Unity Burst Compiler and Job System compatible to increase simulation performance when generating large numbers of samples. Below is an example of a simple job that uses a NormalSampler directly to create 100 normally distributed samples:
```
[BurstCompile]
public struct SampleJob : IJob
{
NormalSampler sampler;
public NativeArray<float> samples;
public void Execute()
{
for (var i = 0; i < samples.Length; i++)
samples[i] = sampler.NextSample();
}
}
```
Additionally, samplers have a NativeSamples() method that can schedule a ready-made multi-threaded job intended for generating a large array of samples. Below is an example of how to combine two job handles returned by NativeSamples() to generate two arrays of samples simultaneously:
```
// Create samplers
var uniformSampler = new UniformSampler
{
range = new FloatRange(0, 1),
seed = 123456789u
};
var normalSampler = new NormalSampler
{
range = new FloatRange(0, 1),
mean = 0,
stdDev = 1,
seed = 987654321u
};
// Create sample jobs
var uniformSamples = uniformSampler.NativeSamples(1000, out var uniformHandle);
var normalSamples = normalSampler.NativeSamples(1000, out var normalHandle);
// Combine job handles
var combinedJobHandles = JobHandle.CombineDependencies(uniformHandle, normalHandle);
// Wait for jobs to complete
combinedJobHandles.Complete();
//...
// Use samples
//...
// Dispose of sample arrays
uniformSamples.Dispose();
normalSamples.Dispose();
```
## Custom Samplers
Take a look at the [UniformSampler](../../Runtime/Randomization/Samplers/SamplerTypes/UniformSampler) and [NormalSampler](../../Runtime/Randomization/Samplers/SamplerTypes/NormalSampler) structs as references for implementing your own [ISampler](../../Runtime/Randomization/Samplers/ISampler). Note that the NativeSamples() method in the ISampler interface requires the usage of the Unity Job System. Take a look [here](https://docs.unity3d.com/Manual/JobSystem.html) to learn more about how to create jobs using the Unity Job System.

32
com.unity.perception/Documentation~/Randomization/Scenarios.md


# Scenarios
Scenarios have three responsibilities:
1. Controlling the execution flow of your simulation
2. Customizing the application of random parameters in your project
3. Defining constants that can be configured externally from a built Unity player
By default, the perception package includes one ready-made scenario, the `FixedFrameLengthScenario` class. This scenario is useful for when all created parameters have target GameObjects configured directly in the `ParameterConfiguration` and the scenario execution requires little modification.
More commonly, users will find the need to create their own Scenario class. Below is an overview of the more common scenario properties and methods a user can override:
1. **isIterationComplete** - determines the conditions that cause the end of a scenario iteration
2. **isScenarioComplete** - determines the conditions that cause the end of a scenario
3. **Initialize** - actions to complete before the scenario has begun iterating
4. **Setup** - actions to complete at the beginning of each iteration
5. **Teardown** - actions to complete at the end of each iteration
6. **OnComplete** - actions to complete after the scenario as completed
## Constants
Scenarios define constants from which to expose global simulation behaviors like a starting iteration value or a total iteration count. Users can serialize these scenario constants to JSON, modify them in an external program, and finally reimport the JSON constants at runtime to configure their simulation even after their project has been built. Below is an example of the constants used in the `FixedLengthScenario` class:
```
[Serializable]
public class Constants
{
public int iterationFrameLength = 1;
public int startingIteration;
public int totalIterations = 1000;
}
```
A few key things to note here:
1. Make sure to include the [Serializable] attribute on a constant class. This will ensure that the constants can be manipulated from the Unity inspector.
2. By default, UnityEngine.Object class references cannot be serialized to JSON in a meaningful way. This includes Monobehaviors and SerializedObjects. For more information on what can and can't be serialized, take a look at the [Unity JsonUtility manual](https://docs.unity3d.com/ScriptReference/JsonUtility.html).
3. A scenario class's Serialize() and Deserialized() methods can be overriden to implement custom serialization strategies.

182
com.unity.perception/Documentation~/Randomization/Tutorial.md


# Randomization Tutorial
This goal of this tutorial is to walk users through an example randomized perception project that explores the following activities:
1. Creating a parameter configuration
2. Customizing parameters and samplers
4. Configuring a scenario to run the simulation
5. Configure the perception camera
6. Building a simulation runtime
7. Modifying scenario constants
By the end of this guide, the user should have a new project that generates the perception data necessary to train a model to identify a cube from a solid colored background.
Note: Before beginning the tutorial, follow [this guide](../SetupSteps.md) to install the perception package into a new Unity project.
## Step 1: Create Scene and GameObjects
1. Create a new scene using `File -> New Scene`
2. Use the key combo `Ctrl+S` to save and name the new scene
3. Create a new cube GameObject
1. Create a new cube GameObject by navigating to `GameObject -> 3D Object -> Cube` in the menubar
2. Rename the new cube GameObject "Cube" by double clicking on the new GameObject that appeared in the hierarchy
3. Reset the cube's transform component by right clicking on transform component in the cube's inpector and clicking `Reset`
4. Create a new background GameObject
1. Create a new quad GameObject and rename it "Background"
2. Set the background quad's position to (0, 0, 2) to set it behind the cube and make the quad large enough to fill the camera by change the quad's scale to (30, 30, 1)
5. In the *MeshRenderer* component of the *Cube* and *Background* GameObjects, set `Lighting -> Cast shadows -> Off` to prevent the two objects from casting shadows on each other
## Step 2: Create Parameter Configuration
1. Create a new empty GameObject by using `GameObject -> Create Empty` from the menubar
2. Rename the new empty GameObject "Config" by double clicking on the new GameObject that appeared in the hierarchy
3. To add a new Parameter Configuration component to the Config GameObject, click on the GameObject in the hierarchy and then click the `Add Component` button in the inspector window. Select `Randomization -> Parameter Configuration` to add the new component.
## Step 3: Create and Customize Parameters
In this step, we will configure 6 parameters to randomize the scene: *CubePosition*, *CubeRotation*, *CubeScale*, *CubeColor*, *BackgroundColor*, and *CameraRotation*
#### Parameter 1: Cube Position
1. Create a new Vector3 parameter by clicking *Add New Parameter -> Vector3* on the parameter configuration inspector
2. Rename the parameter "CubePosition" by typing the text box next to the blue text indicating the parameter's type
3. Click the *Target GameObject* checkbox and select the *Cube* GameObject in the target object selector. Select the property *position* from the property dropdown.
4. Consider using the following sampler values:
* X : Uniform [-5, 5]
* Y : Uniform [-5, 5]
* Z : Constant [Value = 0]
#### Parameter 2: Cube Rotation
1. Create a new Vector3 parameter named "CubeRotation"
2. Select the *Cube* GameObject as the target GameObject and select the property *Transform.eulerAngles* from the property dropdown
3. Consider using the following component values:
* X : Uniform [0, 360]
* Y : Uniform [0, 360]
* Z : Uniform [0, 360]
#### Parameter 3: Cube Scale
1. Create a new Vector3 parameter named "CubeScale"
2. Select the *Cube* GameObject as the target GameObject and select the property *Transform.localScale* from the property dropdown
3. Consider using the following component values:
* X : Uniform [0.5, 2]
* Y : Uniform [0.5, 2]
* Z : Uniform [0.5, 2]
4. To ensure that the X, Y, and Z samplers all sample equal scale values, copy the X sampler's random seed to all three samplers
#### Parameter 4: Cube Color
1. Create a new ColorHSVA parameter named "CubeColor"
2. Skip setting the target GameObject. We will be using this parameter from within the scenario instead.
3. Consider using the following component values:
* Hue : Uniform [0, 1]
* Saturation : Uniform [0, 1]
* Value : Uniform [0.25, 1]
* Alpha : Constant [Value = 0]
#### Parameter 5: Background Color
1. Create a new ColorHSVA parameter named "BackgroundColor"
2. Skip setting the target GameObject. We will be using this parameter from within the scenario instead.
3. Consider using the following component values:
* Hue : Uniform [0, 1]
* Saturation : Uniform [0, 1]
* Value : Uniform [0.25, 1]
* Alpha : Constant [Value = 0]
#### Parameter 6: Camera Rotation
1. Create a new Vector3 parameter named "CameraRotation"
2. Select the *Main Camera* GameObject as the target GameObject and select the property *Transform.eulerAngles* from the property dropdown
3. Consider using the following component values:
* X : Constant [Value = 0]
* Y : Constant [Value = 0]
* Z : Uniform [0, 360]
## Step 4: Configure Scenario
1. Right click on the *Scripts* folder in the project hierarchy and select `Create -> C# Script`. Name the script "CubeScenario" and press enter.
2. Double click on the new "CubeScenario" script to open it for edit
3. In your code editor, paste the following C# code into the CubeScenario script:
```
using System;
using UnityEngine;
using UnityEngine.Perception.Randomization.Configuration;
using UnityEngine.Perception.Randomization.Parameters;
using UnityEngine.Perception.Randomization.Scenarios;
public class CubeScenario : Scenario<CubeScenario.Constants>
{
[Serializable]
public class Constants
{
public int totalIterations = 1000;
}
public override bool isIterationComplete => currentIterationFrame >= 1;
public override bool isScenarioComplete => currentIteration >= constants.totalIterations;
public ParameterConfiguration config;
public GameObject background;
public GameObject cube;
ColorHsvaParameter m_BackgroundColorParameter;
ColorHsvaParameter m_CubeColorParameter;
Material m_BackgroundMaterial;
Material m_CubeMaterial;
static readonly int k_BaseColor = Shader.PropertyToID("_BaseColor");
public override void OnInitialize()
{
m_BackgroundColorParameter = config.GetParameter<ColorHsvaParameter>("BackgroundColor");
m_CubeColorParameter = config.GetParameter<ColorHsvaParameter>("CubeColor");
m_BackgroundMaterial = background.GetComponent<MeshRenderer>().material;
m_CubeMaterial = cube.GetComponent<MeshRenderer>().material;
}
public override void OnIterationSetup()
{
m_BackgroundMaterial.SetColor(k_BaseColor, m_BackgroundColorParameter.Sample());
m_CubeMaterial.SetColor(k_BaseColor, m_CubeColorParameter.Sample());
}
}
```
So what is this CubeScenario script accomplishing?
1. The *Constants* nested class in this scenario script determines what scenario parameters can be JSON serialized. Only these parameters can be changed externally from a built player. In this example, we expose the number of total iterations the scenario will complete.
2. The overrided properties *isIterationComplete* and *isScenarioComplete* are checked before every frame to control the scenario's execution flow. In this case, the scenario will execute for only one frame for each iteration and continue executing until reaching the total iteration limit set by the *totalIterations* field in the constants class.
3. In Unity, manipulating the color of a material is a shader specific task that cannot be accomplished directly from a color parameter's target GameObject setting. Instead we:
1. Expose a reference to the parameter configuration this scenario's inspector as the public script variable
2. Cache the ID of the *_BaseColor* shader property
3. Override the OnInitialize() method to cache a few references. First, we lookup the parameters *BackgroundColor* and *CubeColor* by name from the the parameter configuration. Second, we grab the references to the materials attached to the cube and background GameObjects when the simulation starts.
4. Override the OnIterationSetup() method to apply randomly sampled color values to the shaders of the cached materials at the beginning of each scenario iteration
4. Back in the Unity editor, navigate to the inspector of the *Config* GameObject and use `Add Component -> CubeScenario` to add the new CubeScenario component to your parameter configuration.
5. Open the constants dropdown and confirm how many iterations the scenario should run (the default is 1000)
6. Use the *backgroundColorParameter* and *cubeColorParameter* dropdowns to inform the script of which parameters in the configuration to use for the BackgroundColor and CubeColor respectively.
7. Select the *Background* and *Cube* GameObjects from their respective GameObject field selectors
8. Confirm that the scenario and parameter configuration are composed properly by clicking the play button in the editor. In the Game window, a cube of different sizes, rotations, scales, and colors should be appearing against a color changing background.
9. To serialize the constants used in the scenario to JSON for external modification after this project has been built into a runtime, click the *Serialize Config* button on the parameter configuration
## Step 5: Configure Perception Camera
Read through the [general perception getting started guide](../GettingStarted.md) before completing the following steps:
1. (For URP projects) Add GroundTruthRendererFeature
2. Add a *PerceptionCamera* component to the MainCamera
3. Label the cube
1. Add a *Labeling* component to the cube GameObject
2. Create a *LabelingConfiguration* asset
3. Add the cube label to the new configuration
4. Select the new configuration asset from the perception camera
4. Enter play mode to confirm that labeled data is being generated
## Step 6: Build Simulation Runtime
1. Create a new sub-folder under "Assets" in the Project Hierarchy named "BuildConfigurations"
2. Right click on the BuildConfigurations folder and use `Create -> Build -> Empty Build Configuration` to create a new build configuration asset
3. Rename the build configuration asset "TutorialBuild"
4. Copy the settings from the example build configuration screenshot below:
![TutorialBuild](Images/TutorialBuild.png)
5. Click the "Build" button in the upper righthand corner of the build configuration inspector to create an executable of the tutorial scene.
## Step 7: Modify Scenario Constants
**Note**: Make sure that the "Deserialize On Start" field is checked in the scenario's inspector. A player built without this field checked will cause the player to not load serialized constants.
1. Navigate to the folder created during the build from the previous step of this tutorial (example: C:\projects\RandomizationTutorial\Builds\Tutorial)
2. Open the "_Data" folder (example: Tutorial_Data) and then open the "StreamingAssets" folder
3. Inside the folder should be the JSON scenario constants serialized from the parameter configuration in Step 4
4. Edit this JSON file to update the scenario constants used in the player
5. Confirm the new constants are deserialized at runtime by executing the simulation

69
com.unity.perception/Documentation~/Randomization/Index.md


# Overview
*NOTICE: The perception randomization toolset is currently marked as experimental and will experience a number of updates in the near future.*
The randomization toolset simplifies randomizing aspects of generating synthetic data. It facilitates exposing parameters for randomization, offers samplers to pick random values from parameters, and provides scenarios to define a full randomization process. Each of these also allows for custom implementations to fit particular randomization needs.
**What is Domain Randomization?**
Domain randomization is used to create variability in synthetic datasets to help ML models trained in a synthetic domain (Unity) work well in real world applications. The intuition is that the real world is complex and varies widely, while synthetic datasets have limited variation. By randomizing parts of the synthetic domain the ML model will be exposed to enough variability to perform well when deployed. Domain randomization techniques vary widely in what they randomize and how they choose the randomization to apply. The randomization toolset is intended to facilitate a broad variety of implementations and applications.
Our use of domain randomization draws from Tobin et al. (2017) work training robotic pick and place using purely synthetic data.
**How can a Unity project be randomized using the Perception Randomization toolset?**
Randomizing a project involves the following steps:
1. Create a parameter configuration
2. Add parameters to the parameter configuration
3. Customize parameter properties and samplers
4. Create a scenario to control simulation execution
As the first step mentions, randomization begins with creating a new ParameterConfiguration component. From here, users can configure and organize new random parameters to control various aspects of their simulation directly from the inspector in the Unity editor.
![Example Parameters](./Images/ParameterConfiguration.png)
Next, create a few parameters and modify their properties. Parameters often customize their random variables through the parameter configuration using samplers. Samplers enable users to specify a type of probabilty distribution to use when generating random values.
Finally, add a Scenario component to the scene. Scenarios are used to coordinate the application of randomizations during the execution of a simulation.
Continue reading for more details concerning the three primary components driving randomizations in the perception package: parameters, samplers, and scenarios.
## Parameters
Parameters are used to map common types of simulation properties to random variables. For example, a Vector3 size parameter can be used to randomize the x, y, and z dimensions of an obstacle. Or a material parameter can be used to swap between different terrain surface materials. Additionally, parameter sub-properties can be modified from the parameter configuration in playmode better visualize the impact of different randomization settings.
To read more about how to create custom parameter types, navigate over to the [parameters doc](Parameters.md).
## Samplers
Samplers generate random float values by sampling from probability distributions. They are considered bounded since each random sampler generates float values within a range defined by a minumum and maximum value. The values generated from samplers are often used to randomize the sub components of parameters.
![Example Parameters](./Images/ColorParameter.png)
For example, a color parameter has four independently randomizable components: hue, saturation, value, and alpha. Each of the four samplers attached to a color parameter can employ a unique probability distribution to customize how new colors are sampled within a simulation. Out of the box, the perception package supports uniform and normal distribution sampling. So in our color example, a user may choose a normal distribution for their hue, a uniform distribution for saturation, and a constant value sampler for the value and alpha color components.
Take a look at the [samplers doc](Samplers.md) to learn more about implementing custom probability distributions and samplers that can integrate with the perception package.
## Scenarios
Scenarios have three responsibilities:
1. Controlling the execution flow of your simulation
2. Customizing the application of random parameters in your project
3. Defining constants that can be configured externally from a built Unity player
The fundamental principle of domain randomization is to simulate environments under a variety of randomized conditions. Each **iteration** of a scenario is intended to encapsulate one complete run of a simulated environment under uniquely randomized conditions. Scenarios determine how to setup a new iteration, what conditions determine the end of an iteration, how to clean up a completed iteration, and finally how many iterations to perform. Each of these behaviors can be customized for a new scenario by deriving from the Scenario class in the perception package.
It is possible to configure parameters to affect simulation properties directly from the parameter configuration. While useful, this feature is constrained to a particular set of use cases. Instead, a user can reference existing parameters in their scenario to implement more intricate randomizations. For example, a user can reference a `SpawnCount` parameter and a `ObjectPosition` parameter to randomize the positions of a dynamic number of objects during the setup step of a scenario.
![Example Parameters](./Images/TestScenario.png)
Finally, scenarios define constants from which to expose global simulation behaviors automatically. By modifying serialized constants externally, users can customize their simulation runtime even after their project has been built.
## Getting Started
Visit our [randomization tutorial doc](Tutorial.md) to get started using the perception package's randomization tools in an example project.

3
com.unity.perception/Editor/Randomization/CategoricalOptionElement.cs.meta


fileFormatVersion: 2
guid: 3066f77d411047baafb6cc454adc6e37
timeCreated: 1595535184

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存