浏览代码

Fixing wrong colors in semantic segmentation due to sRGB conversion by changing the shader parameter to a Vector, bypassing sRGB conversion altogether. (#46)

/main
GitHub 4 年前
当前提交
41416247
共有 4 个文件被更改,包括 13 次插入6 次删除
  1. 11
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  2. 2
      com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader
  3. 2
      com.unity.perception/Runtime/GroundTruth/SemanticSegmentationCrossPipelinePass.cs
  4. 4
      com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs

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


m_AsyncAnnotations = new Dictionary<int, AsyncAnnotation>();
var renderTextureDescriptor = new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8);
{
if (targetTexture.sRGB)
{
Debug.LogError("targetTexture supplied to SemanticSegmentationLabeler must be in Linear mode. Disabling labeler.");
this.enabled = false;
}
var renderTextureDescriptor = new RenderTextureDescriptor(width, height, GraphicsFormat.R8G8B8A8_UNorm, 8);
}
m_TargetTextureOverride = new RenderTexture(renderTextureDescriptor);
m_TargetTextureOverride = new RenderTexture(width, height, 8, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
targetTexture.Create();
targetTexture.name = "Labeling";

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


{
Properties
{
[PerObjectData] LabelingId("Labeling Id", Color) = (0,0,0,1)
[PerObjectData] LabelingId("Labeling Id", Vector) = (0,0,0,1)
}
HLSLINCLUDE

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


//Set the labeling ID so that it can be accessed in ClassSemanticSegmentationPass.shader
if (found)
mpb.SetColor(k_LabelingId, entry.color);
mpb.SetVector(k_LabelingId, entry.color);
}
}
}

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


[UnityPlatform(exclude = new[] {RuntimePlatform.LinuxEditor, RuntimePlatform.LinuxPlayer})]
public class SegmentationPassTests : GroundTruthTestBase
{
static readonly Color32 k_SemanticPixelValue = Color.blue;
static readonly Color32 k_SemanticPixelValue = new Color32(10, 20, 30, Byte.MaxValue);
public enum SegmentationKind
{

catch (Exception)
{
//uncomment to get RenderDoc captures while this check is failing
//RenderDoc.EndCaptureRenderDoc(gameView);
//UnityEditorInternal.RenderDoc.EndCaptureRenderDoc(gameView);
throw;
}
}

正在加载...
取消
保存