unity3d - 着色器错误:函数返回值缺少语义
问题描述
我在着色器代码中缺少语义错误。我该如何解决?
“文本框/平滑渐变”中的着色器错误:“vert”:函数返回值在第 39 行缺少语义(在 d3d9 上)。
“文本框/平滑渐变”中的着色器错误:“frag”:输入参数“f”在第 48 行缺少语义(在 d3d9 上)。
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Copyright 2012, Catlike Coding
// http://catlikecoding.com/
// Version 1.0
// Variant of the "Text Box/Smooth" shader that subtly fades by increasing Edge Maximum.
Shader "Text Box/Smooth Fade"{
Properties{
_MainTex("Distance Map (Alpha)", 2D) = "white" {}
_EdgeMin("Edge Minimum (Outside)", Float) = 0.45
_EdgeMax("Edge Maximum (Inside)", Float) = 0.55
_FadeDistance("Fade Distance (Begin)", Float) = 10
_FadeStrength("Fade Strength (Increase per Unit)", Float) = 1
}
SubShader{
Tags{ "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
Blend SrcAlpha OneMinusSrcAlpha
// Cull Off // use this to make it visible from behind
Lighting Off
ZWrite Off
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "CC Text CG.cginc"
sampler2D _MainTex;
fixed _EdgeMin, _EdgeMax;
float _FadeDistance, _FadeStrength;
struct v2f {
float4 pos : SV_POSITION;
fixed4 color: COLOR;
half2 uv : TEXCOORD0;
fixed fade;
};
v2f vert (cc_text_u2v v) { // <========= error1
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.uv = v.texcoord;
o.fade = lerp(_EdgeMax, 1, saturate(((length(mul(UNITY_MATRIX_MV, v.vertex)) - _FadeDistance)) * _FadeStrength));
return o;
}
fixed4 frag(v2f f) : COLOR { // <========= error2
f.color.a *= smoothstep(_EdgeMin, f.fade, tex2D(_MainTex, f.uv).a);
return f.color;
}
// version that includes texture RGB
// fixed4 frag(v2f f) : COLOR {
// fixed4 t = tex2D(_MainTex, f.uv);
// f.color.rgb *= t;
// f.color.a *= smoothstep(_EdgeMin, f.fade, t.a);
// return f.color;
// }
ENDCG
}
}
Fallback "Text Box/Smooth"
}
解决方案
推荐阅读
- python - 如何将元组转换为简单数字?
- javascript - 从 JS 迁移,tsc 构建中的错误
- android - 如何避免在 Workmanager 中立即执行定期请求
- java - 给定一个字符串列表,以相同的顺序返回一个包含相同字符串的数组
- debian - 带有无头 Chrome 的 Wallaby 崩溃
- database - 如何在 Postgres 中对文件系统和数据库进行原子操作?
- azure-active-directory - AAD B2C 添加/映射来自外部/委托身份提供者的声明?
- database - MongoDB是非关系的缺点
- azure-data-lake - 带有 DVC 的 Azure DataLake
- java - Python 到 java 图像处理翻译