浏览代码

Fixes so that rendering is not a frame behind

/aisv647_visualizations
Steven Borkman 4 年前
当前提交
bff81d36
共有 3 个文件被更改,包括 179 次插入4 次删除
  1. 124
      TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
  2. 2
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab
  3. 57
      com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs

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


debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &334211407
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 334211410}
- component: {fileID: 334211409}
- component: {fileID: 334211408}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &334211408
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 334211407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &334211409
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 334211407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &334211410
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 334211407}
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: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &411238276
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:
light: {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:
cam: {fileID: 963194229}
--- !u!1 &1640252278
GameObject:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
yDegreesPerSecond: 180
--- !u!1 &1784690340
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1784690342}
- component: {fileID: 1784690341}
m_Layer: 0
m_Name: VisualizationManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1784690341
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1784690340}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 53f4c974fdf704444959724a41de0cfe, type: 3}
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 963194229}
--- !u!4 &1784690342
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1784690340}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1862.3339, y: 948.3081, z: 49.613728}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

2
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab


m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 2100000, guid: f562a5a621358402796352af288935cc, type: 2}
m_Material: {fileID: 2100000, guid: f81ae556e923c4b1d9a6047faeaa99aa, type: 2}
m_Color: {r: 0.40000004, g: 0.46274513, b: 0.73333335, a: 1}
m_RaycastTarget: 0
m_Maskable: 1

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


using UnityEngine.Experimental.Rendering;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
#if HDRP_PRESENT
using UnityEngine.Rendering.HighDefinition;
#endif

//only used to confirm that GroundTruthRendererFeature is present in URP
bool m_GroundTruthRendererFeatureRun;
private static Camera visualizationCamera;
/// <summary>
/// The <see cref="SensorHandle"/> associated with this camera. Use this to report additional annotations and metrics at runtime.
/// </summary>

DatasetCapture.SimulationEnding += OnSimulationEnding;
}
void Start()
{
SetupVisualizationCamera();
}
void SetupVisualizationCamera()
{
if (visualizationCamera != null)
Debug.LogWarning("Currently only support one visualization camera at a time. User should switch main camera in project hierarchy to visualize a different camera");
var cam = GetComponent<Camera>();
cam.enabled = false;
// set up to render to a render texture instead of the screen
var visualizationRenderTexture = new RenderTexture(new RenderTextureDescriptor(cam.pixelWidth, cam.pixelHeight, UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm, 8));
visualizationRenderTexture.name = cam.name + "_visualization_texture";
cam.targetTexture = visualizationRenderTexture;
// set up to not render the UI layer
int layerMask = 1 << LayerMask.NameToLayer("UI");
cam.cullingMask = ~layerMask;
var camera2 = new GameObject(cam.name + "_VisualizationCamera");
visualizationCamera = camera2.AddComponent<Camera>();
visualizationCamera.cullingMask = layerMask;
var canvasObj = new GameObject(cam.name + "_VisualizationImageUI");
var canvas = canvasObj.AddComponent<Canvas>();
canvasObj.AddComponent<CanvasScaler>();
canvasObj.AddComponent<GraphicRaycaster>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
var imgObj = new GameObject(cam.name + "_Image");
var img = imgObj.AddComponent<RawImage>();
img.texture = visualizationRenderTexture;
var rect = imgObj.transform as RectTransform;
rect.SetParent(canvasObj.transform, false);
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;
}
void CheckForRendererFeature(ScriptableRenderContext context, Camera camera)
{

if (!SensorHandle.IsValid)
return;
var cam = GetComponent<Camera>();
cam.enabled = SensorHandle.ShouldCaptureThisFrame;
foreach (var labeler in m_Labelers)
{
if (!labeler.enabled)

labeler.InternalOnUpdate();
}
}
void LateUpdate()
{
var cam = GetComponent<Camera>();
if (SensorHandle.ShouldCaptureThisFrame) cam.Render();
}
void OnValidate()

正在加载...
取消
保存