diff --git a/Assets/Resources/RenderPipelines/SegmentationRenderer.asset b/Assets/Resources/RenderPipelines/SegmentationRenderer.asset
index ba74a7dc..5fe7ffbb 100644
--- a/Assets/Resources/RenderPipelines/SegmentationRenderer.asset
+++ b/Assets/Resources/RenderPipelines/SegmentationRenderer.asset
@@ -10,12 +10,12 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6b3d386ba5cd94485973aee1479b272e, type: 3}
- m_Name: RenderObjects
+ m_Name: SegmentationRenderObjects
m_EditorClassIdentifier:
m_Active: 1
settings:
- passTag: RenderObjects
- Event: 600
+ passTag: SegmentationRenderObjects
+ Event: 300
filterSettings:
RenderQueueType: 0
LayerMask:
@@ -28,7 +28,7 @@ MonoBehaviour:
overrideShaderPassIndex: 0
overrideMode: 2
overrideDepthState: 0
- depthCompareFunction: 2
+ depthCompareFunction: 0
enableWrite: 0
stencilSettings:
overrideStencilState: 0
@@ -97,8 +97,8 @@ MonoBehaviour:
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 0
- m_RenderingMode: 0
+ m_RenderingMode: 1
m_DepthPrimingMode: 0
- m_CopyDepthMode: 2
+ m_CopyDepthMode: 0
m_AccurateGbufferNormals: 0
m_IntermediateTextureMode: 0
diff --git a/Assets/Resources/Shader/GeometryGrass.shader b/Assets/Resources/Shader/GeometryGrass.shader
index 53ff0394..8b882727 100644
--- a/Assets/Resources/Shader/GeometryGrass.shader
+++ b/Assets/Resources/Shader/GeometryGrass.shader
@@ -44,9 +44,10 @@ Shader "Custom/GeometryGrass"
{
Tags
{
+ "RenderPipeline" = "UniversalPipeline"
"RenderType" = "Opaque"
"Queue" = "Geometry"
- "RenderPipeline" = "UniversalPipeline"
+ "IgnoreProjector" = "True"
}
LOD 100
@@ -56,6 +57,9 @@ Shader "Custom/GeometryGrass"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
+ #pragma require geometry
+ #pragma require tessellation tessHW
+
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ _SHADOWS_SOFT
@@ -65,6 +69,8 @@ Shader "Custom/GeometryGrass"
#pragma multi_compile_local WIND_OFF _
#pragma multi_compile_instancing
+ #pragma instancing_options renderinglayer
+ #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#define BLADE_SEGMENTS 4
@@ -311,7 +317,7 @@ Shader "Custom/GeometryGrass"
float4 tangent = (input[0].tangentWS + input[1].tangentWS + input[2].tangentWS) / 3.0f;
float3 bitangent = cross(normal, tangent.xyz) * tangent.w;
- pos -= _GrassOffset;
+ pos -= _GrassOffset.xyz;
float3x3 tangentToLocal = float3x3
(
@@ -390,25 +396,17 @@ Shader "Custom/GeometryGrass"
"LightMode" = "UniversalForward"
}
- ZWrite On
- ZTest LEqual
-
HLSLPROGRAM
- #pragma require geometry
- #pragma require tessellation tessHW
-
#pragma vertex vert
#pragma hull hull
#pragma domain domain
#pragma geometry geom
#pragma fragment frag
- #pragma multi_compile_instancing
-
// The lighting sections of the frag shader taken from this helpful post by Ben Golus:
// https://forum.unity.com/threads/water-shader-graph-transparency-and-shadows-universal-render-pipeline-order.748142/#post-5518747
- float4 frag (g2f i) : SV_Target
+ float4 frag(g2f i) : SV_Target
{
float4 color = tex2D(_BaseTex, i.uv);
@@ -437,9 +435,6 @@ Shader "Custom/GeometryGrass"
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
- ZWrite On
- ZTest LEqual
-
HLSLPROGRAM
#pragma vertex shadowVert
#pragma hull hull
@@ -447,8 +442,6 @@ Shader "Custom/GeometryGrass"
#pragma geometry geom
#pragma fragment shadowFrag
- // #pragma multi_compile_instancing
-
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
diff --git a/Assets/Resources/Shader/Segmentation.shader b/Assets/Resources/Shader/Segmentation.shader
index 36a0bdbe..2148f3b4 100644
--- a/Assets/Resources/Shader/Segmentation.shader
+++ b/Assets/Resources/Shader/Segmentation.shader
@@ -4,35 +4,43 @@ Shader "Sensor/Segmentation"
{
_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
+ [Toggle] _DisableColor ("Disable Color method", int) = 0
+ [Toggle] _Hide ("Hide this label", int) = 0
}
SubShader
{
- Tags {
+ Tags
+ {
+ "RenderPipeline" = "UniversalPipeline"
"RenderType" = "Opaque"
+ "Queue" = "Geometry"
}
+ Cull Off // Disable backface culling
+ Lighting Off
+
+ HLSLINCLUDE
+ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
+
+ CBUFFER_START(UnityPerMaterial)
+ half4 _SegmentationColor;
+ half4 _SegmentationClassId;
+ int _DisableColor;
+ int _Hide;
+ CBUFFER_END
+
+ ENDHLSL
+
Pass
{
- Name "Segmentation"
-
- Cull Off // Disable backface culling
+ Name "PixelSegmentation"
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;
@@ -41,32 +49,24 @@ Shader "Sensor/Segmentation"
struct Varyings
{
float4 positionCS : SV_POSITION;
- half4 color : COLOR;
};
- Varyings vert(Attributes input)
+ Varyings vert(Attributes i)
{
- 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;
+ Varyings o;
+ VertexPositionInputs vertexInput = GetVertexPositionInputs(i.positionOS.xyz);
+ o.positionCS = vertexInput.positionCS;
+ return o;
}
half4 frag(Varyings i) : SV_Target
{
- half4 output_color = half4(0, 0, 0, 1);
+ half4 segColor = half4(0, 0, 0, 0);
if (_Hide == 0)
{
- output_color = (_DisableColor == 0)? _SegmentationColor : _SegmentationClassId;
+ segColor = (_DisableColor == 0)? _SegmentationColor : _SegmentationClassId;
}
- return output_color;
+ return segColor;
}
ENDHLSL
}
diff --git a/Assets/Scripts/CLOiSimPlugins/MowingPlugin.cs b/Assets/Scripts/CLOiSimPlugins/MowingPlugin.cs
index dd6e0913..ba76c6c9 100644
--- a/Assets/Scripts/CLOiSimPlugins/MowingPlugin.cs
+++ b/Assets/Scripts/CLOiSimPlugins/MowingPlugin.cs
@@ -39,7 +39,7 @@ public void SetBladingRatio(in float bladeMin, in float bladeMax, in float bladi
{
this.heightThreshold = bladingHeight;
this.ratio = Mathf.Lerp(bladeMin, bladeMax, bladingHeight);
- Debug.Log("_bladingRatio: " + this.ratio);
+ // Debug.Log("_bladingRatio: " + this.ratio);
}
}
@@ -298,10 +298,9 @@ private bool FindTargetBlade(Target targetBlade)
var bladeBounds = new Bounds();
foreach (var meshFilter in meshFilters)
{
- Debug.Log(meshFilter.name);
- Debug.Log(meshFilter.sharedMesh.bounds);
+ // Debug.Log(meshFilter.name);
+ // Debug.Log(meshFilter.sharedMesh.bounds);
var bounds = meshFilter.sharedMesh.bounds;
- // bounds.center = Vector3.zero;
bladeBounds.Encapsulate(bounds);
}
diff --git a/Assets/Scripts/Core/Modules/SegmentationTag.cs b/Assets/Scripts/Core/Modules/SegmentationTag.cs
index d4ae173d..3a0ee1ac 100644
--- a/Assets/Scripts/Core/Modules/SegmentationTag.cs
+++ b/Assets/Scripts/Core/Modules/SegmentationTag.cs
@@ -47,7 +47,7 @@ public bool Hide
get => _hide;
set {
_hide = value;
- HideLabelForMaterialPropertyBlock(_hide);
+ HideLabelForMaterialPropertyBlock(value);
}
}
@@ -89,6 +89,7 @@ public void Refresh()
mpb.SetColor("_SegmentationColor", color);
mpb.SetColor("_SegmentationClassId", classValue);
+ mpb.SetInt("_Hide", 0);
// Debug.Log(TagName + ": mode=" + Main.SegmentationManager.Mode +
// " color=" + color +
@@ -119,7 +120,7 @@ private void UpdateClass()
default:
return;
}
-
+ // Debug.Log("UpdateClass(): " + _className);
Main.SegmentationManager.AddClass(_className, this);
}
@@ -130,8 +131,13 @@ private void AllocateMaterialPropertyBlock(in MaterialPropertyBlock mpb)
foreach (var renderer in renderers)
{
// Debug.Log($"{this.name} material length {renderer.materials.Length}");
- for (var i =0 ; i < renderer.materials.Length; i++)
+ for (var i = 0; i < renderer.materials.Length; i++)
{
+ var existMpb = new MaterialPropertyBlock();
+ renderer.GetPropertyBlock(existMpb, i);
+ var hide = existMpb.GetInt("_Hide");
+ // Debug.Log($"{this.name} {i} hide={hide}");
+ mpb.SetInt("_Hide", hide);
renderer.SetPropertyBlock(mpb, i);
}
}
@@ -147,15 +153,19 @@ private void AllocateMaterialPropertyBlock(in MaterialPropertyBlock mpb)
/// Hides the label in material property block.
///
/// if set to true, hide this segmentation.
- private void HideLabelForMaterialPropertyBlock(in bool value)
+ public void HideLabelForMaterialPropertyBlock(in bool value)
{
+ // Debug.Log("HideLabelForMaterialPropertyBlock: " + name);
var mpb = new MaterialPropertyBlock();
var renderers = GetComponentsInChildren();
foreach (var renderer in renderers)
{
- renderer.GetPropertyBlock(mpb);
- mpb.SetInt("_Hide", value? 1 : 0);
- renderer.SetPropertyBlock(mpb);
+ for (var i = 0; i < renderer.materials.Length; i++)
+ {
+ renderer.GetPropertyBlock(mpb, i);
+ mpb.SetInt("_Hide", value ? 1 : 0);
+ renderer.SetPropertyBlock(mpb, i);
+ }
}
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/Core/ObjectSpawning.cs b/Assets/Scripts/Core/ObjectSpawning.cs
index bc0bdf93..4cf93763 100644
--- a/Assets/Scripts/Core/ObjectSpawning.cs
+++ b/Assets/Scripts/Core/ObjectSpawning.cs
@@ -72,9 +72,7 @@ void OnDestroy()
// Update is called once per frame
void LateUpdate()
{
- var leftControlPressed = Input.GetKey(KeyCode.LeftControl);
-
- if (leftControlPressed)
+ if (Input.GetKey(KeyCode.LeftControl))
{
if (Input.GetMouseButtonUp(0))
{
diff --git a/Assets/Scripts/Core/SegmentationManager.cs b/Assets/Scripts/Core/SegmentationManager.cs
index fe87a04f..ccc6d664 100644
--- a/Assets/Scripts/Core/SegmentationManager.cs
+++ b/Assets/Scripts/Core/SegmentationManager.cs
@@ -39,9 +39,7 @@ public void AttachTag(string className, Transform target)
private static IEnumerator AttachTagCoroutine(string className, Transform target)
{
- yield return new WaitForEndOfFrame();
-
- var segmentationTag = target?.gameObject.GetComponentInChildren();
+ var segmentationTag = target?.GetComponentInChildren();
if (segmentationTag == null)
{
segmentationTag = target?.gameObject.AddComponent();
diff --git a/Assets/Scripts/Devices/DepthCamera.cs b/Assets/Scripts/Devices/DepthCamera.cs
index 1a3b3c93..0f9dd2f7 100644
--- a/Assets/Scripts/Devices/DepthCamera.cs
+++ b/Assets/Scripts/Devices/DepthCamera.cs
@@ -153,6 +153,7 @@ protected override void SetupCamera()
camSensor.clearFlags = CameraClearFlags.Depth;
camSensor.allowHDR = false;
+ camSensor.allowMSAA = false;
camSensor.depthTextureMode = DepthTextureMode.Depth;
_universalCamData.requiresColorOption = CameraOverrideOption.Off;
diff --git a/Assets/Scripts/Devices/MicomSensor.cs b/Assets/Scripts/Devices/MicomSensor.cs
index 0ed4051c..0819bed6 100644
--- a/Assets/Scripts/Devices/MicomSensor.cs
+++ b/Assets/Scripts/Devices/MicomSensor.cs
@@ -50,7 +50,7 @@ public void SetIMU(in string sensorName)
var imuList = gameObject.GetComponentsInChildren();
foreach (var imu in imuList)
{
- Debug.Log(imu.name + " , " + imu.DeviceName);
+ // Debug.Log(imu.name + " , " + imu.DeviceName);
if (imu.DeviceName.Contains("::" + sensorName + "::") ||
imu.name.CompareTo(sensorName) == 0)
{
diff --git a/Assets/Scripts/Devices/SegmentationCamera.cs b/Assets/Scripts/Devices/SegmentationCamera.cs
index cf7b7fda..22a887fb 100644
--- a/Assets/Scripts/Devices/SegmentationCamera.cs
+++ b/Assets/Scripts/Devices/SegmentationCamera.cs
@@ -43,17 +43,19 @@ protected override void SetupCamera()
camSensor.backgroundColor = Color.black;
camSensor.clearFlags = CameraClearFlags.SolidColor;
camSensor.allowHDR = false;
- camSensor.allowMSAA = false;
+ camSensor.allowMSAA = true;
// Refer to SegmentationRenderer (Universal Renderer Data)
_universalCamData.SetRenderer(1);
_universalCamData.renderPostProcessing = true;
- _universalCamData.requiresColorOption = CameraOverrideOption.On;
+ _universalCamData.requiresColorOption = CameraOverrideOption.Off;
_universalCamData.requiresDepthOption = CameraOverrideOption.Off;
- _universalCamData.requiresColorTexture = true;
+ _universalCamData.requiresColorTexture = false;
_universalCamData.requiresDepthTexture = false;
_universalCamData.renderShadows = false;
- _universalCamData.dithering = false;
+ _universalCamData.dithering = true;
+ _universalCamData.antialiasing = AntialiasingMode.FastApproximateAntialiasing;
+
}
protected override void InitializeMessages()
diff --git a/Assets/Scripts/Main.cs b/Assets/Scripts/Main.cs
index 8f44dcf4..0ea1fa29 100644
--- a/Assets/Scripts/Main.cs
+++ b/Assets/Scripts/Main.cs
@@ -484,15 +484,21 @@ private void SaveWorld()
void LateUpdate()
{
+#if UNITY_EDITOR
+ if (Input.GetKey(KeyCode.LeftAlt))
+#else
if (Input.GetKey(KeyCode.LeftControl))
+#endif
{
+ // Debug.Log("LeftControl Triggered");
if (Input.GetKeyUp(KeyCode.R))
{
- _resetTriggered = true;
// Debug.Log("Reset Triggered");
+ _resetTriggered = true;
}
else if (Input.GetKeyUp(KeyCode.S))
{
+ // Debug.Log("Save World");
OnSaveButtonClicked();
}
}
diff --git a/Assets/Scripts/UI/CameraControl.cs b/Assets/Scripts/UI/CameraControl.cs
index 33672dfe..be166fca 100644
--- a/Assets/Scripts/UI/CameraControl.cs
+++ b/Assets/Scripts/UI/CameraControl.cs
@@ -274,7 +274,7 @@ private Vector3 GetBaseInput()
baseDirection.x += 1;
}
- if (Input.GetKey(KeyCode.R))
+ if (Input.GetKey(KeyCode.G))
{
baseDirection.y += 1;
}
@@ -285,7 +285,7 @@ private Vector3 GetBaseInput()
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) ||
Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) ||
- Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.F))
+ Input.GetKey(KeyCode.G) || Input.GetKey(KeyCode.F))
{
_terminateMoving = true;
}
diff --git a/Assets/Scripts/UI/FollowingCamera.cs b/Assets/Scripts/UI/FollowingCamera.cs
index 0e0a7499..afa244c0 100644
--- a/Assets/Scripts/UI/FollowingCamera.cs
+++ b/Assets/Scripts/UI/FollowingCamera.cs
@@ -82,7 +82,7 @@ private void ChangeParameterByBaseInput()
followingAngle -= (angleStep);
}
- if (Input.GetKey(KeyCode.R))
+ if (Input.GetKey(KeyCode.G))
{
height += moveAmount;
}
diff --git a/Assets/UI Toolkit/SimulationDisplay.uxml b/Assets/UI Toolkit/SimulationDisplay.uxml
index 1780903e..d9efad97 100644
--- a/Assets/UI Toolkit/SimulationDisplay.uxml
+++ b/Assets/UI Toolkit/SimulationDisplay.uxml
@@ -19,7 +19,7 @@
-
+