比较提交

...

1 次代码提交

作者 SHA1 备注 提交日期
Jon Hogins 1b0468fe Hacky support for transparency in semantic segmentation 4 年前
共有 2 个文件被更改,包括 25 次插入20 次删除
  1. 11
      com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs
  2. 34
      com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader

11
com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs


if (shaderVariantCollection != null)
{
shaderVariantCollection.Add(
new ShaderVariantCollection.ShaderVariant(m_ClassLabelingShader, PassType.ScriptableRenderPipeline));
// shaderVariantCollection.Add(
// new ShaderVariantCollection.ShaderVariant(m_ClassLabelingShader, PassType.N));
}
m_OverrideMaterial = new Material(m_ClassLabelingShader);

// Set the labeling ID so that it can be accessed in ClassSemanticSegmentationPass.shader
mpb.SetVector(k_LabelingId, found ? entry.color : Color.black);
if (renderer != null && renderer.material != null && renderer.material.HasProperty("_MainTex"))
{
var maintex = renderer.material.GetTexture("_MainTex");
if (maintex != null)
mpb.SetTexture("_MainTex", renderer.material.GetTexture("_MainTex"));
}
}
public override void ClearMaterialProperties(MaterialPropertyBlock mpb, Renderer renderer, Labeling labeling, uint instanceId)

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


Properties
{
[PerObjectData] LabelingId("Labeling Id", Vector) = (0,0,0,1)
_MainTex ("Main Texture", 2D) = "white" { }
HLSLINCLUDE
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
//enable GPU instancing support
#pragma multi_compile_instancing
ENDHLSL
Tags { "RenderType"="Opaque" }
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
ZWrite on
Blend SrcAlpha OneMinusSrcAlpha
Tags { "LightMode" = "SRP" }
Blend Off
ZWrite On
ZTest LEqual
Cull Back
//Tags { "LightMode" = "SRP" }
CGPROGRAM

#include "UnityCG.cginc"
float4 LabelingId;
sampler2D _MainTex;
float4 _MainTex_ST;
float2 uv : TEXCOORD0;
float2 uv : TEXCOORD0;
};
vertexToFragment semanticSegmentationVertexStage (in_vert vertWorldSpace)

vertScreenSpace.uv = TRANSFORM_TEX(vertWorldSpace.uv, _MainTex);
// sample the texture
fixed4 col = tex2D(_MainTex, vertScreenSpace.uv);
if (col.a == 0)
return fixed4(0, 0, 0, 0);
return LabelingId;
}

正在加载...
取消
保存