Skip to content

Commit

Permalink
Merge from 'develop' into 'main' for CLOiSim-4.4.0 (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang authored Mar 8, 2024
2 parents 80989e0 + 7c327b7 commit 3b46ae2
Show file tree
Hide file tree
Showing 78 changed files with 1,632 additions and 385 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"**/*.meta": true,
"Library": true,
"Temp": true,
"UserSettings": true
"UserSettings": true,
"obj": true,
"**/TextMesh Pro": true,
"**/VSCode": true
},
"editor.detectIndentation": false,
"editor.indentSize": "tabSize",
Expand Down
46 changes: 46 additions & 0 deletions Assets/Resources/Materials/Segmentation.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Segmentation
m_Shader: {fileID: 4800000, guid: 419a697b1455619dea4cc9d729b3d0c8, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats:
- _DisableColor: 0
- _Hide: 0
m_Colors:
- _SegmentationClassId: {r: 0, g: 0, b: 0, a: 1}
- _SegmentationColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &6202412140821847777
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7
8 changes: 8 additions & 0 deletions Assets/Resources/Materials/Segmentation.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Resources/PhysicsMaterials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions Assets/Resources/RenderPipelines/SegmentationRenderer.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-5373475574186842855
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: 6b3d386ba5cd94485973aee1479b272e, type: 3}
m_Name: RenderObjects
m_EditorClassIdentifier:
m_Active: 1
settings:
passTag: RenderObjects
Event: 550
filterSettings:
RenderQueueType: 0
LayerMask:
serializedVersion: 2
m_Bits: 9
PassNames: []
overrideMaterial: {fileID: 2100000, guid: 748cb5dd9e7f8a9f7b5d0712426cd62c, type: 2}
overrideMaterialPassIndex: 0
overrideShader: {fileID: 4800000, guid: 419a697b1455619dea4cc9d729b3d0c8, type: 3}
overrideShaderPassIndex: 0
overrideMode: 1
overrideDepthState: 0
depthCompareFunction: 2
enableWrite: 0
stencilSettings:
overrideStencilState: 0
stencilReference: 5
stencilCompareFunction: 5
passOperation: 1
failOperation: 1
zFailOperation: 1
cameraSettings:
overrideCamera: 0
restoreCamera: 1
offset: {x: 0, y: 0, z: 0, w: 0}
cameraFieldOfView: 25
--- !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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
m_Name: SegmentationRenderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
m_RendererFeatures:
- {fileID: -5373475574186842855}
m_RendererFeatureMap: 19e55a676f946db5
m_UseNativeRenderPass: 0
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
screenSpaceShadowPS: {fileID: 0}
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
type: 3}
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
type: 3}
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
type: 3}
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
type: 3}
m_AssetVersion: 2
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 9
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 0
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 2
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 0
m_RenderingMode: 1
m_DepthPrimingMode: 0
m_CopyDepthMode: 0
m_AccurateGbufferNormals: 0
m_IntermediateTextureMode: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MonoBehaviour:
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: a079301ff0f3b5c48ac29edc3797d4c7, type: 2}
- {fileID: 11400000, guid: e7e5daae73c962ecbbb5651a07d8ffe4, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 0
Expand Down Expand Up @@ -83,11 +84,11 @@ MonoBehaviour:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 3
m_PrefilteringModeAdditionalLight: 0
m_PrefilteringModeAdditionalLight: 4
m_PrefilteringModeAdditionalLightShadows: 2
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 2
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeForwardPlus: 1
m_PrefilteringModeDeferredRendering: 1
m_PrefilteringModeScreenSpaceOcclusion: 0
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1
Expand Down
73 changes: 73 additions & 0 deletions Assets/Resources/Shader/Segmentation.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Shader "Sensor/Segmentation"
{
Properties
{
_SegmentationColor ("Segmentation Color", Color) = (1, 1, 1, 1)
_SegmentationClassId ("Segmentation Class ID Value in 16bits", Color) = (0, 0, 0, 1)
_DisableColor ("Disable Color output", int) = 0
_Hide ("Hide this label", int) = 0
}

SubShader
{
Tags {
"RenderType" = "Opaque"
}

Pass
{
Name "Segmentation"


HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

#pragma vertex vert
#pragma fragment frag

CBUFFER_START(UnityPerMaterial)
half4 _SegmentationColor;
half4 _SegmentationClassId;
int _DisableColor;
int _Hide;
CBUFFER_END

struct Attributes
{
float4 positionOS : POSITION;
};

struct Varyings
{
float4 positionCS : SV_POSITION;
half4 color : COLOR;
};

Varyings vert(Attributes input)
{
Varyings output = (Varyings)0;
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
output.positionCS = vertexInput.positionCS;

half4 output_color = half4(0, 0, 0, 1);
if (_Hide == 0)
{
output_color = (_DisableColor == 0)? _SegmentationColor : _SegmentationClassId;
}
output.color = output_color;
return output;
}

half4 frag(Varyings i) : SV_Target
{
half4 output_color = half4(0, 0, 0, 1);
if (_Hide == 0)
{
output_color = (_DisableColor == 0)? _SegmentationColor : _SegmentationClassId;
}
return output_color;
}
ENDHLSL
}
}
}
9 changes: 9 additions & 0 deletions Assets/Resources/Shader/Segmentation.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -5207,7 +5207,7 @@ Camera:
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_projectionMatrixMode: 2
m_GateFitMode: 2
m_FOVAxisMode: 0
Expand Down
53 changes: 30 additions & 23 deletions Assets/Scripts/CLOiSimPlugins/CameraPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,29 @@

public class CameraPlugin : CLOiSimPlugin
{
private SensorDevices.Camera cam = null;

public SensorDevices.Camera GetCamera()
{
return cam;
}

public SensorDevices.DepthCamera GetDepthCamera()
{
return GetCamera() as SensorDevices.DepthCamera;
}
protected SensorDevices.Camera _cam = null;

protected override void OnAwake()
{
var depthcam = gameObject.GetComponent<SensorDevices.DepthCamera>();
if (depthcam is null)
var depthCam = gameObject.GetComponent<SensorDevices.DepthCamera>();

var deviceName = string.Empty;
if (depthCam is not null)
{
ChangePluginType(ICLOiSimPlugin.Type.CAMERA);
cam = gameObject.GetComponent<SensorDevices.Camera>();
attachedDevices.Add("Camera", cam);
ChangePluginType(ICLOiSimPlugin.Type.DEPTHCAMERA);
deviceName = "DepthCamera";
_cam = depthCam;
}
else
{
ChangePluginType(ICLOiSimPlugin.Type.DEPTHCAMERA);
cam = depthcam;
attachedDevices.Add("DepthCamera", cam);
ChangePluginType(ICLOiSimPlugin.Type.CAMERA);
deviceName = "Camera";
_cam = gameObject.GetComponent<SensorDevices.Camera>();
}

if (!string.IsNullOrEmpty(deviceName))
attachedDevices.Add(deviceName, _cam);

partsName = DeviceHelper.GetPartName(gameObject);
}

Expand All @@ -48,7 +43,19 @@ protected override void OnStart()

if (RegisterTxDevice(out var portTx, "Data"))
{
AddThread(portTx, SenderThread, cam);
AddThread(portTx, SenderThread, _cam);
}
}

protected override void OnPluginLoad()
{
if (GetPluginParameters() != null && type == ICLOiSimPlugin.Type.DEPTHCAMERA)
{
var depthScale = GetPluginParameters().GetValue<uint>("configuration/depth_scale", 1000);
if (_cam != null)
{
((SensorDevices.DepthCamera)_cam).SetDepthScale(depthScale);
}
}
}

Expand All @@ -57,13 +64,13 @@ protected override void HandleCustomRequestMessage(in string requestType, in Any
switch (requestType)
{
case "request_camera_info":
var cameraInfoMessage = cam.GetCameraInfo();
var cameraInfoMessage = _cam.GetCameraInfo();
SetCameraInfoResponse(ref response, cameraInfoMessage);
break;

case "request_transform":
var devicePose = cam.GetPose();
var deviceName = cam.DeviceName;
var devicePose = _cam.GetPose();
var deviceName = _cam.DeviceName;
SetTransformInfoResponse(ref response, deviceName, devicePose);
break;

Expand Down
Loading

0 comments on commit 3b46ae2

Please sign in to comment.