我正在尝试创建一种 UI/HUD 栏来计算角色背面的弹药,例如 astroneer 或死区中的健康栏。我试图跟随这个reddid thred
https://www.reddit.com/r/Unity3D/comments/6pixhk/how_to_build_the_hudui_on_the_player_like_in/
但我无法让它工作,而且我没有使用着色器的经验。有人可以帮助我吗?
编辑:我发现了问题,基本上着色器与 HDR Pipeline 不兼容。是否有一种方法可以转换它或使用着色器图重新创建它?
这是着色器源代码,但您也可以在 thred 上找到它。你可以下载一个统一包。
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Threshold ("Threshold", Range(0,1)) = 0.0
_EmissionColor ("Emission Color", Color) = (1,1,1,1)
_EmissionPower ("Emission Power", Range(0,10)) = 1.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
float _Threshold;
fixed4 _Color;
fixed4 _EmissionColor;
float _EmissionPower;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = _Color; tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
if(IN.uv_MainTex.y < _Threshold) {
o.Emission = _EmissionColor * _EmissionPower;
}
}
ENDCG
}
FallBack "Diffuse"
}