Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Runtime/Tx/DepthCameraTx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class DepthCameraTx : ProBridgeTxStamped<CompressedImage>
public int textureHeight = 1024;
public RawImage _rawImage;
[Range(1, 100)] public int CompressionQuality = 90;
public Shader depthShader;


private DepthCameraSensor _cameraSensor;
Expand All @@ -29,6 +30,7 @@ public class DepthCameraTx : ProBridgeTxStamped<CompressedImage>
protected override void AfterEnable()
{
_cameraSensor = renderCamera.gameObject.AddComponent<DepthCameraSensor>();
_cameraSensor.mat = new Material(depthShader);
_cameraSensor._camera = renderCamera;
_cameraSensor.onSensorUpdated += OnSensorUpdated;
_cameraSensor._minRange = _minRange;
Expand Down
16 changes: 14 additions & 2 deletions Runtime/Tx/DepthCameraTx.cs.meta

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 @@ -7,6 +7,7 @@
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine.Serialization;
using UnityEngine.UI;
using UnitySensors.Data.PointCloud;
using UnitySensors.Interface.Sensor;
Expand All @@ -31,7 +32,7 @@ public class DepthCameraSensor : CameraSensor, ITextureInterface, IPointCloudInt
private RenderTexture _rt = null;
private Texture2D _texture;

private Material _mat;
public Material mat;

private JobHandle _jobHandle;

Expand Down Expand Up @@ -63,9 +64,8 @@ public override void Init()

_texture = new Texture2D(_resolution.x, _resolution.y, TextureFormat.RGBAFloat, false);

_mat = new Material(Shader.Find("UnitySensors/Color2Depth"));
float f = m_camera.farClipPlane;
_mat.SetFloat("_F", f);
mat.SetFloat("_F", f);

SetupDirections();
SetupJob();
Expand Down Expand Up @@ -177,7 +177,7 @@ protected override void OnSensorDestroy()

private void OnRenderImage(RenderTexture source, RenderTexture dest)
{
Graphics.Blit(source, dest, _mat);
Graphics.Blit(source, dest, mat);
}
}
}

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