浏览代码

Fix for _MainTex test error

/aisv647_visualizations
Steven Borkman 4 年前
当前提交
7e27bca9
共有 4 个文件被更改,包括 24 次插入25 次删除
  1. 7
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  2. 4
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat
  3. 13
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader
  4. 25
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegmentTexture.prefab

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


int camHeight = 0;
private GameObject segVisual = null;
private Image segImage = null;
private RawImage segImage = null;
/// <inheritdoc/>
protected override bool supportsVisualization => true;

segVisual = GameObject.Instantiate(Resources.Load<GameObject>("SegmentTexture"));
segImage = segVisual.GetComponent<Image>();
segImage = segVisual.GetComponent<RawImage>();
segImage.material.SetFloat("_SegmentTransparency", defaultSegmentTransparency);
segImage.material.SetFloat("_BackTransparency", defaultBackgroundTransparency);

var cpuTexture = new Texture2D(texture.width, texture.height, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None);
cpuTexture.LoadRawTextureData(data);
cpuTexture.Apply();
segImage.material.SetTexture("_BaseMap", cpuTexture);
segImage.texture = cpuTexture;
}
/// <inheritdoc/>

4
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat


m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

13
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Resources/SegRemoveBackgroundShader.shader


{
Properties
{
_BaseMap ("Base (RGB) Trans (A)", 2D) = "white" { }
_MainTex ("Main Texture", 2D) = "defaulttexture" { }
_RemoveColor ("Remove Color", Color) = (0, 0, 0, 1)
_SegmentTransparency("Segment Transparency", Range(0.0,1.0)) = 0.5
_BackTransparency("Background Transparency", Range(0.0,1.0)) = 0

CGPROGRAM
#pragma vertex vert
#pragma fragment frag Lambert alpha
#include "UnityCG.cginc"
struct appdata

float4 vertex : SV_POSITION;
};
sampler2D _BaseMap;
sampler2D _MainTex;
fixed4 _RemoveColor;
float _SegmentTransparency;
float _BackTransparency;

v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
//o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.uv = v.uv;
return o;
}

// sample the texture
fixed4 col = tex2D(_BaseMap, i.uv);
fixed4 col = tex2D(_MainTex, i.uv);
if (abs(col.r - _RemoveColor.r) < .01f)
{
if (abs(col.g - _RemoveColor.g) < .01f)

}
}
}
if (abs(col.a - _BackTransparency) > .01f) col.a = _SegmentTransparency;
return col;

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


m_Component:
- component: {fileID: 968786849326295845}
- component: {fileID: 84779842494960409}
- component: {fileID: 5755782579398516696}
- component: {fileID: 5662008187905630377}
m_Layer: 5
m_Name: SegmentTexture
m_TagString: Untagged

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6732225215165335482}
m_CullTransparentMesh: 0
--- !u!114 &5755782579398516696
--- !u!114 &5662008187905630377
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Color: {r: 0.40000004, g: 0.46274513, b: 0.73333335, a: 1}
m_Color: {r: 0.4, g: 0.4627451, b: 0.73333335, a: 1}
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
正在加载...
取消
保存